From 93b071e21e7e31b2f168702230bad110bd80e12c Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Mon, 30 Sep 2024 00:17:26 +0300 Subject: [PATCH] tun: OpenBSD: use proper ioctl API, not raw syscall Direct syscalls are discouraged and usually do not work. (Not entirely sure why they do with Golang, but that is another story.) --- src/tun/tun_openbsd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tun/tun_openbsd.go b/src/tun/tun_openbsd.go index 7dd3e23..714db3a 100644 --- a/src/tun/tun_openbsd.go +++ b/src/tun/tun_openbsd.go @@ -113,9 +113,9 @@ func (tun *TunAdapter) setupAddress(addr string) error { 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 - tun.log.Errorf("Error in SIOCAIFADDR_IN6: %v", errno) + if err = unix.IoctlSetInt(sfd, SIOCAIFADDR_IN6, int(uintptr(unsafe.Pointer(&ar)))); err != nil { + tun.log.Errorf("Error in SIOCAIFADDR_IN6: %v", err) + return err } return nil