From ff49dc80a3fad4412eab7f1b923c8bd609506188 Mon Sep 17 00:00:00 2001 From: snow flurry Date: Fri, 18 Feb 2022 19:04:30 -0800 Subject: [PATCH] tun_netbsd: support unpatched kernels for IFHEAD This previously assumed a user's kernel was patched a la http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55463, making it effectively useless for most people. Since we know IFHEAD will always be one of 0 (false) or something that isn't 0 (true), we can generalize things a bit more. Suggestion provided by artemis https://artemis.sh/2022/02/16/tailscale-on-netbsd-proof-of-concept.html --- tun/tun_netbsd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tun/tun_netbsd.go b/tun/tun_netbsd.go index e5834c1..9c8a0fe 100644 --- a/tun/tun_netbsd.go +++ b/tun/tun_netbsd.go @@ -164,7 +164,7 @@ func CreateTUN(name string, mtu int) (Device, error) { uintptr(unsafe.Pointer(&ifheadmode)), ) - if errno != 0 || ifheadmode != 1 { + if errno != 0 || ifheadmode == 0 { tunfile.Close() return nil, fmt.Errorf("Unable to validate IFHEAD mode: %v (ifheadmode = %d)", errno, ifheadmode) }