mirror of https://github.com/vishvananda/netlink
Add BridgeSetVlanFiltering to change VlanFiltering on an existing bridge
Signed-off-by: stffabi <stffabi@pm.me>
This commit is contained in:
parent
bfba8e4149
commit
5f2fc868c2
|
@ -247,6 +247,16 @@ func (h *Handle) BridgeSetMcastSnoop(link Link, on bool) error {
|
|||
return h.linkModify(bridge, unix.NLM_F_ACK)
|
||||
}
|
||||
|
||||
func BridgeSetVlanFiltering(link Link, on bool) error {
|
||||
return pkgHandle.BridgeSetVlanFiltering(link, on)
|
||||
}
|
||||
|
||||
func (h *Handle) BridgeSetVlanFiltering(link Link, on bool) error {
|
||||
bridge := link.(*Bridge)
|
||||
bridge.VlanFiltering = &on
|
||||
return h.linkModify(bridge, unix.NLM_F_ACK)
|
||||
}
|
||||
|
||||
func SetPromiscOn(link Link) error {
|
||||
return pkgHandle.SetPromiscOn(link)
|
||||
}
|
||||
|
|
39
link_test.go
39
link_test.go
|
@ -1784,6 +1784,45 @@ func expectMcastSnooping(t *testing.T, linkName string, expected bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBridgeSetVlanFiltering(t *testing.T) {
|
||||
minKernelRequired(t, 4, 4)
|
||||
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
bridgeName := "foo"
|
||||
bridge := &Bridge{LinkAttrs: LinkAttrs{Name: bridgeName}}
|
||||
if err := LinkAdd(bridge); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expectVlanFiltering(t, bridgeName, false)
|
||||
|
||||
if err := BridgeSetVlanFiltering(bridge, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expectVlanFiltering(t, bridgeName, true)
|
||||
|
||||
if err := BridgeSetVlanFiltering(bridge, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expectVlanFiltering(t, bridgeName, false)
|
||||
|
||||
if err := LinkDel(bridge); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func expectVlanFiltering(t *testing.T, linkName string, expected bool) {
|
||||
bridge, err := LinkByName(linkName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if actual := *bridge.(*Bridge).VlanFiltering; actual != expected {
|
||||
t.Fatalf("expected %t got %t", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBridgeCreationWithHelloTime(t *testing.T) {
|
||||
minKernelRequired(t, 3, 18)
|
||||
|
||||
|
|
Loading…
Reference in New Issue