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.
This commit is contained in:
Klemens Nanni 2024-09-30 00:10:56 +03:00
parent 94ed9445df
commit dcec376b7b
No known key found for this signature in database

View file

@ -14,7 +14,10 @@ import (
wgtun "golang.zx2c4.com/wireguard/tun" wgtun "golang.zx2c4.com/wireguard/tun"
) )
const SIOCAIFADDR_IN6 = 0x8080691a const (
SIOCAIFADDR_IN6 = 0x8080691a
ND6_INFINITE_LIFETIME = 0xffffffff
)
type in6_addrlifetime struct { type in6_addrlifetime struct {
ia6t_expire int64 ia6t_expire int64
@ -106,6 +109,9 @@ func (tun *TunAdapter) setupAddress(addr string) error {
prefixmask := net.CIDRMask(prefix.Mask.Size()) prefixmask := net.CIDRMask(prefix.Mask.Size())
ar.ifra_prefixmask.setSockaddr(prefixmask) 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 // Set the interface address
if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(sfd), uintptr(SIOCAIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 { if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(sfd), uintptr(SIOCAIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 {
err = errno err = errno