Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tun0 is not assigned IP and routes on OpenBSD #1372

Closed
FiloSottile opened this issue Feb 19, 2021 · 5 comments · Fixed by #1469
Closed

tun0 is not assigned IP and routes on OpenBSD #1372

FiloSottile opened this issue Feb 19, 2021 · 5 comments · Fixed by #1469

Comments

@FiloSottile
Copy link
Contributor

Describe the bug

tailscaled seems to successfully bring up the interface, but the tun0 interface is left unconfigured.

To Reproduce

I am using the following rc unit on an OpenBSD 6.8 machine.

#!/bin/ksh

daemon="/usr/local/sbin/tailscaled"
daemon_flags="--port 0 --tun tun0"

rc_bg="YES"
rc_reload="NO"

. /etc/rc.d/rc.subr

rc_start() {
        ${rcexec} "${daemon} ${daemon_flags} 2>&1 | logger -t tailscaled ${_bg}"
}

rc_stop() {
        ${rcexec} "${daemon} --cleanup ${daemon_flags} 2>&1 | logger -t tailscaled"
        pkill -xf "${pexp}"
}

rc_cmd $1

After starting tailscaled, the interface has no IP.

tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
        index 9 priority 0 llprio 3
        groups: tun
        status: active

If I manually configure the interface, everything works great!

ifconfig tun0 100.114.190.103 255.192.0.0
route add -inet 100.114.190.103/10 100.114.190.103

Version information:

  • Device: x86_64 box
  • OS: OpenBSD
  • OS version: 6.8
  • Tailscale version: date.20210104 (built from @latest)

Additional context

I am told by a very reliable source that

the openbsd router implementation is choking on the v6 addrs + routes being sent from the control plane

@bradfitz
Copy link
Member

bradfitz commented Feb 20, 2021

Confirmed. You're hitting:

freebsd doesn't support setting multiple local addrs yet

(Yes, the error message says freebsd on OpenBSD too, yay)

@FiloSottile
Copy link
Contributor Author

Looks like a duplicate of #1160.

@DentonGentry
Copy link
Contributor

DentonGentry commented Mar 9, 2021

I installed tailscale built from today's tree on an OpenBSD 6.8 VM, and see the same symptom: control: controlclient: restarting map request for "router" health change to new state: freebsd doesn't support setting multiple local addrs yet

tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
        index 5 priority 0 llprio 3
        groups: tun
        status: active

This happens in wgengine/router/router_openbsd.go in the Set() routine:

        // TODO: support configuring multiple local addrs on interface.
        if len(cfg.LocalAddrs) == 0 {
                return nil
        }
        if len(cfg.LocalAddrs) > 1 {
                return errors.New("freebsd doesn't support setting multiple local addrs yet")
        }

This was intended to apply to having multiple IPv4 addresses, where we don't have a suitable aliases implementation for OpenBSD. However with the addition of IPv6 we now have len(cfg.LocalAddrs) == 2, which we definitely could support.

@DentonGentry
Copy link
Contributor

I think this can be pretty straightforward to resolve, if we want to support one IPv4 and one IPv6 address on the interface. I had it use a /48 prefix, like FreeBSD now does, so as to not need to deal with IPv6 routes.

openbsd# ifconfig tun0
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
        index 9 priority 0 llprio 3
        groups: tun
        status: active
        inet6 fe80::7cb3:edff:feb9:61f8%tun0 ->  prefixlen 64 scopeid 0x9
        inet 100.69.155.47 --> 0.0.0.0 netmask 0xffffffff
        inet6 fd7a:115c:a1e0:ab12:4843:cd96:6245:9b2f ->  prefixlen 48

@DentonGentry
Copy link
Contributor

Seems to work, I can ping another machine on my tailnet using both IPv4 and IPv6:

openbsd# ping 100.84.216.111
PING 100.84.216.111 (100.84.216.111): 56 data bytes
64 bytes from 100.84.216.111: icmp_seq=0 ttl=64 time=31.461 ms
64 bytes from 100.84.216.111: icmp_seq=1 ttl=64 time=3.798 ms
64 bytes from 100.84.216.111: icmp_seq=2 ttl=64 time=1.576 ms
^C
--- 100.84.216.111 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.576/12.278/31.461/13.595 ms
openbsd#

openbsd# ping6 fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f
PING fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f (fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f): 56 data bytes
64 bytes from fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f: icmp_seq=0 hlim=64 time=20.596 ms
64 bytes from fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f: icmp_seq=1 hlim=64 time=1.742 ms
64 bytes from fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f: icmp_seq=2 hlim=64 time=1.869 ms
^C64 bytes from fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f: icmp_seq=3 hlim=64 time=1.519 ms
^C
--- fd7a:115c:a1e0:ab12:4843:cd96:6254:d86f ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.519/6.432/20.596/8.179 ms
openbsd#

DentonGentry added a commit that referenced this issue Mar 9, 2021
Similar to FreeBSD in #1307,
add IPv6 addresses with a prefix length of 48.

Fixes #1372

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
DentonGentry added a commit that referenced this issue Mar 9, 2021
Similar to FreeBSD in #1307,
add IPv6 addresses with a prefix length of 48.

Fixes #1372

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
DentonGentry added a commit that referenced this issue Mar 9, 2021
Similar to FreeBSD in #1307,
add IPv6 addresses with a prefix length of 48.

Fixes #1372

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
jonrzhang pushed a commit to jonrzhang/tailscale that referenced this issue Mar 16, 2021
Similar to FreeBSD in tailscale#1307,
add IPv6 addresses with a prefix length of 48.

Fixes tailscale#1372

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
fnichol added a commit to fnichol/tailscale that referenced this issue Jun 2, 2021
The route creation for the `tun` device was augmented in tailscale#1469 but
didn't account for adding IPv4 vs. IPv6 routes. There are 2 primary
changes as a result:

* Ensure that either `-inet` or `-inet6` was used in the
  [`route(8)`](https://man.openbsd.org/route) command
* Use either the `localAddr4` or `localAddr6` for the gateway argument
  depending which destination network is being added

The basis for the approach is based on the implementation from
`router_userspace_bsd.go`, including the `inet()` helper function.

Fixes tailscale#1372
References tailscale#1469

Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants