net/netutil: only check Linux sysctls w/ procfs, assume absent means false

Fixes #7217

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-02-08 20:11:25 +00:00
committed by Brad Fitzpatrick
parent 05adf22383
commit 2477fc4952
2 changed files with 27 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ package netutil
import (
"io"
"net"
"runtime"
"testing"
)
@@ -51,3 +52,16 @@ func TestOneConnListener(t *testing.T) {
t.Errorf("nil Addr")
}
}
func TestIPForwardingEnabledLinux(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skipf("skipping on %s", runtime.GOOS)
}
got, err := ipForwardingEnabledLinux(ipv4, "some-not-found-interface")
if err != nil {
t.Fatal(err)
}
if got {
t.Errorf("got true; want false")
}
}