Skip to content
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: create utility funcs for BridgeVlanAdd for PVID and Trunk #129

Open
glimchb opened this issue Aug 26, 2023 · 0 comments
Open

bridge: create utility funcs for BridgeVlanAdd for PVID and Trunk #129

glimchb opened this issue Aug 26, 2023 · 0 comments

Comments

@glimchb
Copy link
Member

glimchb commented Aug 26, 2023

for example in https://github.com/opiproject/opi-evpn-bridge/blob/main/pkg/utils/netlink.go add :

// BridgePVIDVlanAdd configure port VLAN id for link
func BridgePVIDVlanAdd(nlink Netlink, link netlink.Link, vlanID int) error {
	// pvid, egress untagged
	return nlink.BridgeVlanAdd(link, uint16(vlanID), true, true, false, true)
}

// BridgeTrunkVlanAdd configure vlan trunk on link
func BridgeTrunkVlanAdd(nlink Netlink, link netlink.Link, vlans []int) error {
	// egress tagged
	for _, vlanID := range vlans {
		if err := nlink.BridgeVlanAdd(link, uint16(vlanID), false, false, false, true); err != nil {
			return err
		}
	}
	return nil
}

because this is hard to read

if err := netlink.BridgeVlanAdd(iface, vid, true, true, false, false); err != nil {
:

netlink.BridgeVlanAdd(iface, vid, true, true, false, false)
@glimchb glimchb changed the title bridge: create utility func for BridgeVlanAdd for VID and TRUNK bridge: create utility func for BridgeVlanAdd for PVID and Trunk Aug 26, 2023
@glimchb glimchb changed the title bridge: create utility func for BridgeVlanAdd for PVID and Trunk bridge: create utility funcs for BridgeVlanAdd for PVID and Trunk Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant