From d36c0d3566ee097fe69882771835a2f1434d0fbc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 28 Oct 2021 11:11:37 -0700 Subject: [PATCH] wgengine/router: add debug test to enumerate rules No non-test changes. Updates #391 Change-Id: Ia88610c08e07a119d002e58250463cb4659b9f54 Signed-off-by: Brad Fitzpatrick --- wgengine/router/router_linux_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wgengine/router/router_linux_test.go b/wgengine/router/router_linux_test.go index 906b82d2f..0b12e4740 100644 --- a/wgengine/router/router_linux_test.go +++ b/wgengine/router/router_linux_test.go @@ -733,3 +733,23 @@ func TestDebugListRoutes(t *testing.T) { t.Logf("Route: %+v", r) } } + +var famName = map[int]string{ + netlink.FAMILY_ALL: "all", + netlink.FAMILY_V4: "v4", + netlink.FAMILY_V6: "v6", +} + +func TestDebugListRules(t *testing.T) { + for _, fam := range []int{netlink.FAMILY_V4, netlink.FAMILY_V6, netlink.FAMILY_ALL} { + t.Run(famName[fam], func(t *testing.T) { + rules, err := netlink.RuleList(fam) + if err != nil { + t.Fatal(err) + } + for _, r := range rules { + t.Logf("Rule: %+v", r) + } + }) + } +}