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
This commit is contained in:
snow flurry 2022-02-18 19:04:30 -08:00
parent c644c61a8e
commit ff49dc80a3

View file

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