From 2cbcf73e3dcdaa63941d0ec4008e69c089434756 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Sat, 21 Jul 2018 09:17:07 -0400 Subject: [PATCH] Add a test for Vlan filtering support for bridges. --- link_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/link_test.go b/link_test.go index 22b7f2f..d1ca9f8 100644 --- a/link_test.go +++ b/link_test.go @@ -1615,6 +1615,52 @@ func TestBridgeCreationWithHelloTime(t *testing.T) { } } +func TestBridgeCreationWithVlanFiltering(t *testing.T) { + minKernelRequired(t, 3, 18) + + tearDown := setUpNetlinkTest(t) + defer tearDown() + + bridgeWithVlanFilteringEnabledName := "foo" + vlanFiltering := true + bridgeWithVlanFilteringEnabled := &Bridge{LinkAttrs: LinkAttrs{Name: bridgeWithVlanFilteringEnabledName}, VlanFiltering: &vlanFiltering} + if err := LinkAdd(bridgeWithVlanFilteringEnabled); err != nil { + t.Fatal(err) + } + + retrievedBridge, err := LinkByName(bridgeWithVlanFilteringEnabledName) + if err != nil { + t.Fatal(err) + } + + retrievedVlanFilteringState := *retrievedBridge.(*Bridge).VlanFiltering + if retrievedVlanFilteringState != vlanFiltering { + t.Fatalf("expected %t got %t", vlanFiltering, retrievedVlanFilteringState) + } + if err := LinkDel(bridgeWithVlanFilteringEnabled); err != nil { + t.Fatal(err) + } + + bridgeWithDefaultVlanFilteringName := "bar" + bridgeWIthDefaultVlanFiltering := &Bridge{LinkAttrs: LinkAttrs{Name: bridgeWithDefaultVlanFilteringName}} + if err := LinkAdd(bridgeWIthDefaultVlanFiltering); err != nil { + t.Fatal(err) + } + + retrievedBridge, err = LinkByName(bridgeWithDefaultVlanFilteringName) + if err != nil { + t.Fatal(err) + } + + retrievedVlanFilteringState = *retrievedBridge.(*Bridge).VlanFiltering + if retrievedVlanFilteringState != false { + t.Fatalf("expected %t got %t", false, retrievedVlanFilteringState) + } + if err := LinkDel(bridgeWIthDefaultVlanFiltering); err != nil { + t.Fatal(err) + } +} + func TestLinkSubscribeWithProtinfo(t *testing.T) { tearDown := setUpNetlinkTest(t) defer tearDown()