61 lines
2.4 KiB
Diff
61 lines
2.4 KiB
Diff
From bc677dc4f356a89a9af5cf45e80d31afff44c6d7 Mon Sep 17 00:00:00 2001
|
|
From: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
Date: Fri, 25 Mar 2022 13:27:16 +0100
|
|
Subject: [PATCH] python, bridge: clear vlan filtering when set empty
|
|
|
|
When the user specifies 'vlan: {}', Nmstate should clear the vlan
|
|
configuration for that port instead of merging it.
|
|
|
|
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
|
|
(cherry picked from commit 8b87c7d533dfb568f9a1715d7b2c59c415c9470a)
|
|
---
|
|
libnmstate/ifaces/linux_bridge.py | 23 +++++++++++++++++++++++
|
|
1 file changed, 23 insertions(+)
|
|
|
|
diff --git a/libnmstate/ifaces/linux_bridge.py b/libnmstate/ifaces/linux_bridge.py
|
|
index ce331692..950e8c9e 100644
|
|
--- a/libnmstate/ifaces/linux_bridge.py
|
|
+++ b/libnmstate/ifaces/linux_bridge.py
|
|
@@ -124,15 +124,38 @@ class LinuxBridgeIface(BridgeIface):
|
|
def gen_metadata(self, ifaces):
|
|
super().gen_metadata(ifaces)
|
|
if not self.is_absent:
|
|
+ original_ports_config = self.original_desire_dict.get(
|
|
+ LinuxBridge.CONFIG_SUBTREE, {}
|
|
+ ).get(LinuxBridge.PORT_SUBTREE, [])
|
|
for port_config in self.port_configs:
|
|
port_iface = ifaces.all_kernel_ifaces.get(
|
|
port_config[LinuxBridge.Port.NAME]
|
|
)
|
|
if port_iface:
|
|
+ original_port = self._get_port_config(
|
|
+ original_ports_config, port_iface.name
|
|
+ )
|
|
+ if (
|
|
+ original_port
|
|
+ and original_port.get(
|
|
+ LinuxBridge.Port.VLAN_SUBTREE, None
|
|
+ )
|
|
+ == {}
|
|
+ ):
|
|
+ port_config[
|
|
+ LinuxBridge.Port.VLAN_SUBTREE
|
|
+ ] = original_port.get(LinuxBridge.Port.VLAN_SUBTREE)
|
|
port_iface.update(
|
|
{BridgeIface.BRPORT_OPTIONS_METADATA: port_config}
|
|
)
|
|
|
|
+ def _get_port_config(self, ports, port_name):
|
|
+ for port_config in ports:
|
|
+ if port_config[LinuxBridge.Port.NAME] == port_name:
|
|
+ return port_config
|
|
+
|
|
+ return None
|
|
+
|
|
def remove_port(self, port_name):
|
|
if self._bridge_config:
|
|
self.raw[LinuxBridge.CONFIG_SUBTREE][LinuxBridge.PORT_SUBTREE] = [
|
|
--
|
|
2.35.1
|
|
|