Skip to content

Commit

Permalink
Network: Add support for OVN uplink networks attached to a VLAN (#14196)
Browse files Browse the repository at this point in the history
This PR adds support for OVN uplink networks attached to a VLAN. The
implementation details closely track
#12234 (comment).

Testing here: canonical/lxd-ci#302.

Closes #12234.
  • Loading branch information
tomponline authored Oct 15, 2024
2 parents 45f4cd6 + 920700b commit dcaabf6
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 dcaabf6

Please sign in to comment.