Skip to content

Commit

Permalink
lxd/network: Support VLAN tagging for OVN uplinks with native bridge …
Browse files Browse the repository at this point in the history
…parents

Signed-off-by: Mark Bolton <[email protected]>
  • Loading branch information
boltmark committed Oct 10, 2024
1 parent 62a97d6 commit 0d0a24d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lxd/network/driver_ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,14 @@ func (n *ovn) startUplinkPortBridgeNative(uplinkNet Network, bridgeDevice string
return fmt.Errorf("Failed to bring up uplink veth interface %q: %w", vars.uplinkEnd, err)
}

// Add VLAN filter entry to the uplink end of the veth interface.
if uplinkNetConfig["vlan"] != "" {
err = link.BridgeVLANAdd(uplinkNetConfig["vlan"], true, true, false)
if err != nil {
return fmt.Errorf("Failed to configure VLAN for uplink veth interface %q: %w", vars.uplinkEnd, err)
}
}

// Ensure uplink OVS end veth interface is up.
link = &ip.Link{Name: vars.ovsEnd}
err = link.SetUp()
Expand Down Expand Up @@ -1646,6 +1654,11 @@ func (n *ovn) startUplinkPortPhysical(uplinkNet Network) error {
return n.startUplinkPortBridgeNative(uplinkNet, uplinkHostName)
}

// Handle case where uplink interface is bridge and VLAN is specified.
if IsNativeBridge(uplinkConfig["parent"]) && uplinkConfig["vlan"] != "" {
return n.startUplinkPortBridgeNative(uplinkNet, uplinkConfig["parent"])
}

// Detect if uplink interface is a OVS bridge.
ovs := openvswitch.NewOVS()
isOVSBridge, _ := ovs.BridgeExists(uplinkHostName)
Expand Down Expand Up @@ -1853,7 +1866,7 @@ func (n *ovn) deleteUplinkPortPhysical(uplinkNet Network) error {
uplinkHostName := GetHostDevice(uplinkConfig["parent"], uplinkConfig["vlan"])

// Detect if uplink interface is a native bridge.
if IsNativeBridge(uplinkHostName) {
if IsNativeBridge(uplinkHostName) || IsNativeBridge(uplinkConfig["parent"]) && uplinkConfig["vlan"] != "" {
return n.deleteUplinkPortBridgeNative(uplinkNet)
}

Expand Down

0 comments on commit 0d0a24d

Please sign in to comment.