net/netutil: add function to check rp_filter value (#5703)

Updates #4432


Change-Id: Ifc332a5747fc1feffdbb87437308cf8ecb21b0b0

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
This commit is contained in:
Andrew Dunham
2023-12-20 00:02:37 -05:00
committed by GitHub
parent 65f2d32300
commit 09136e5995
2 changed files with 128 additions and 0 deletions
+12
View File
@@ -6,6 +6,7 @@ package netutil
import (
"io"
"net"
"net/netip"
"runtime"
"testing"
)
@@ -65,3 +66,14 @@ func TestIPForwardingEnabledLinux(t *testing.T) {
t.Errorf("got true; want false")
}
}
func TestCheckReversePathFiltering(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skipf("skipping on %s", runtime.GOOS)
}
warn, err := CheckReversePathFiltering([]netip.Prefix{
netip.MustParsePrefix("192.168.1.1/24"),
}, nil)
t.Logf("err: %v", err)
t.Logf("warnings: %v", warn)
}