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.)
This commit is contained in:
Klemens Nanni 2024-09-30 00:17:26 +03:00
parent dcec376b7b
commit 93b071e21e
No known key found for this signature in database

View file

@ -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