From dcec376b7bf0882f8cb103f9992ff5e64025520f Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Mon, 30 Sep 2024 00:10:56 +0300 Subject: [PATCH] tun: OpenBSD: set address lifetime At this point, the ioctl success without any error, but no address appears on the interface. Turns out telling NDP to not expire helps. Congrats, yggdrasil is now operational on OpenBSD. --- src/tun/tun_openbsd.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tun/tun_openbsd.go b/src/tun/tun_openbsd.go index 359e6e2d..7dd3e237 100644 --- a/src/tun/tun_openbsd.go +++ b/src/tun/tun_openbsd.go @@ -14,7 +14,10 @@ import ( wgtun "golang.zx2c4.com/wireguard/tun" ) -const SIOCAIFADDR_IN6 = 0x8080691a +const ( + SIOCAIFADDR_IN6 = 0x8080691a + ND6_INFINITE_LIFETIME = 0xffffffff +) type in6_addrlifetime struct { ia6t_expire int64 @@ -106,6 +109,9 @@ func (tun *TunAdapter) setupAddress(addr string) error { prefixmask := net.CIDRMask(prefix.Mask.Size()) ar.ifra_prefixmask.setSockaddr(prefixmask) + ar.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME + ar.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME + // Set the interface address if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(sfd), uintptr(SIOCAIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 { err = errno