summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjack9603301 <jack9603301@163.com>2020-12-12 21:07:40 +0800
committerjack9603301 <jack9603301@163.com>2020-12-13 02:12:47 +0800
commit9863c5773e87a0a40eabdd135f3defb953a364de (patch)
treef39d1be2207b09b130d6d56f04e5338a50b83ad8
parent078671898eacb0ef4ccec7c13db77c1359597c1c (diff)
downloadvyos-1x-9863c5773e87a0a40eabdd135f3defb953a364de.tar.gz
vyos-1x-9863c5773e87a0a40eabdd135f3defb953a364de.zip
interfaces: T3114: Improve VLAN ID setting logic in `bridge`
-rw-r--r--python/vyos/ifconfig/interface.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index eba3f3b99..495e96600 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -928,6 +928,8 @@ class Interface(Control):
vlan_bridge_ids = Section.klass(bridge)(bridge, create=True).get_vlan_ids()
+ apply_vlan_ids = set()
+
# Delete VLAN ID for the bridge
for vlan in vlan_del:
if int(vlan) == 1:
@@ -936,16 +938,16 @@ class Interface(Control):
# Setting VLAN ID for the bridge
for vlan in vlan_add:
- if isinstance(vlan,str) and vlan.isnumeric():
- if int(vlan) not in vlan_bridge_ids:
- cmd = f'bridge vlan add dev {bridge} vid {vlan} self'
- self._cmd(cmd)
- elif isinstance(vlan,str) and not vlan.isnumeric():
- vlan_range = vlan.split('-')
- for vlan_id in range(int(vlan_range[0]),int(vlan_range[1]) + 1):
+ vlan_range = vlan.split('-')
+ apply_vlan_ids.add(int(vlan_range[0]))
+ if(len(vlan_range) == 2):
+ for vlan_id in range(int(vlan_range[0])+1,int(vlan_range[1]) + 1):
if int(vlan_id) not in vlan_bridge_ids:
- cmd = f'bridge vlan add dev {bridge} vid {vlan_id} self'
- self._cmd(cmd)
+ apply_vlan_ids.add(int(vlan_id))
+
+ for vlan in apply_vlan_ids:
+ cmd = f'bridge vlan add dev {bridge} vid {vlan} self'
+ self._cmd(cmd)
# enable/disable Vlan Filter
# When the VLAN aware option is not detected, the setting of `bridge` should not be overwritten