From 920700be6403f89a1fcd793b9f355d4845c77fc3 Mon Sep 17 00:00:00 2001 From: Mark Bolton Date: Wed, 9 Oct 2024 20:58:27 -0700 Subject: [PATCH] lxd/network: Support VLAN tagging for OVN uplinks with native bridge parents Signed-off-by: Mark Bolton --- lxd/network/driver_ovn.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lxd/network/driver_ovn.go b/lxd/network/driver_ovn.go index 4c0010fa7605..c3615bccc4ab 100644 --- a/lxd/network/driver_ovn.go +++ b/lxd/network/driver_ovn.go @@ -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() @@ -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) @@ -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) }