From ad5f14c783c18d48f678d8ab89afc02b6d5d215c Mon Sep 17 00:00:00 2001 From: l0crian1 Date: Thu, 10 Apr 2025 11:03:33 -0400 Subject: bridge:T7322: Fix bridge allowed-vlan handling Allowed VLAN ranges are unnecessarily deconstructed into individual vlans, and then added one by one to the bridge. This can take a long time if a large range like 1-4084 is used. - python/vyos/configdict.py - Added get_vlans_ids_and_range function to return configured ranges - python/vyos/ifconfig/bridge.py - Modified add and delete vlan section to not loop unnecessarily --- python/vyos/configdict.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'python/vyos/configdict.py') diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 78b98a3eb..73372022b 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -626,6 +626,23 @@ def get_vlan_ids(interface): return vlan_ids +def get_vlans_ids_and_range(interface): + vlan_ids = set() + + vlan_filter_status = json.loads(cmd(f'bridge -j -d vlan show dev {interface}')) + + if vlan_filter_status is not None: + for interface_status in vlan_filter_status: + for vlan_entry in iface.get("vlans", []): + start = vlan_entry["vlan"] + end = vlan_entry.get("vlanEnd") + if end: + vlan_ids.add(f"{start}-{end}") + else: + vlan_ids.add(str(start)) + + return vlan_ids + def get_accel_dict(config, base, chap_secrets, with_pki=False): """ Common utility function to retrieve and mangle the Accel-PPP configuration -- cgit v1.2.3 From 1d636f4c3779f4b5b08ccb1643dd80bc86c10fbf Mon Sep 17 00:00:00 2001 From: l0crian1 Date: Thu, 10 Apr 2025 11:21:39 -0400 Subject: bridge:T7322: Fix bridge allowed-vlan handling Fix indentation error in get_vlans_ids_and_range function. --- python/vyos/configdict.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'python/vyos/configdict.py') diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 73372022b..586ddf632 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -627,21 +627,21 @@ def get_vlan_ids(interface): return vlan_ids def get_vlans_ids_and_range(interface): - vlan_ids = set() + vlan_ids = set() - vlan_filter_status = json.loads(cmd(f'bridge -j -d vlan show dev {interface}')) + vlan_filter_status = json.loads(cmd(f'bridge -j -d vlan show dev {interface}')) if vlan_filter_status is not None: for interface_status in vlan_filter_status: - for vlan_entry in iface.get("vlans", []): - start = vlan_entry["vlan"] - end = vlan_entry.get("vlanEnd") - if end: - vlan_ids.add(f"{start}-{end}") - else: - vlan_ids.add(str(start)) - - return vlan_ids + for vlan_entry in interface_status.get("vlans", []): + start = vlan_entry["vlan"] + end = vlan_entry.get("vlanEnd") + if end: + vlan_ids.add(f"{start}-{end}") + else: + vlan_ids.add(str(start)) + + return vlan_ids def get_accel_dict(config, base, chap_secrets, with_pki=False): """ -- cgit v1.2.3