-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bridge: add/del vlan range #863
Conversation
@vishvananda @aboch please take a look |
Thanks @tjjh89017 |
Hi @aboch |
vlanEndInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_END | ||
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanEndInfo.Serialize()) | ||
} else { | ||
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the else
and have only one instance of
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
invoked after the if
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the testing.
We can not add "vlanInfo" after the "vlanEndInfo".
It will cause that only the last vlan will be added into the bridge.
e.g. add vlan 4~6, but only vlan6 is added.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for checking.
sorry, I published the comments now |
Hi @aboch |
Signed-off-by: Date Huang <tjjh89017@hotmail.com>
@aboch
It should be vlan4,5,6. Failed Code diff --git a/bridge_linux.go b/bridge_linux.go
index 6c340b0..9f0903b 100644
--- a/bridge_linux.go
+++ b/bridge_linux.go
@@ -134,14 +134,12 @@ func (h *Handle) bridgeVlanModify(cmd int, link Link, vid, vidEnd uint16, pvid,
vlanEndInfo := &nl.BridgeVlanInfo{Vid: vidEnd}
vlanEndInfo.Flags = vlanInfo.Flags
- vlanInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_BEGIN
- br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
vlanEndInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_END
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanEndInfo.Serialize())
- } else {
- br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
+ vlanInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_BEGIN
}
+ br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
req.AddData(br)
_, err := req.Execute(unix.NETLINK_ROUTE, 0) |
LGTM |
Allow user to add vlan range in one rtnetlink call.
Usually, users will want to allow all vlans (2~4094) for some ports via iproute2 command (as below)
Avoid to call rtnetlink 4000 times.
We should invlove vlan range to the modify function.
NOTE: original function didn't check if the vlan value is valid, so I didn't add validation.