diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-10-01 21:30:23 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-10-01 21:30:23 +0200 |
commit | 4cfb3515475d95313ad1840978ee09704bd6351a (patch) | |
tree | 418c2fddcef56583a66e993ed5efd64efe3e4c69 /python | |
parent | a91b9e6805c61c58cdca83ffa7a47182831d8652 (diff) | |
download | vyos-1x-4cfb3515475d95313ad1840978ee09704bd6351a.tar.gz vyos-1x-4cfb3515475d95313ad1840978ee09704bd6351a.zip |
vlan: configdict: T2945: determine if vlan is part of bridge
Every interface knows if it is part of a bridge or not - except a VLAN (VIF)
interface. Also VLANs should be aware of its master bridge.
Add a testcase to ensure when VIFs on an interface change the bridge does not
loos one of it's members.
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configdict.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 660d779d4..ce6d58693 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -360,6 +360,10 @@ def get_interface_dict(config, base, ifname=''): # XXX: T2665: blend in proper DHCPv6-PD default values dict['vif'][vif] = T2665_set_dhcpv6pd_defaults(dict['vif'][vif]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif}', 'bridge') + if bridge: dict['vif'][vif].update({'is_bridge_member' : bridge}) + for vif_s, vif_s_config in dict.get('vif_s', {}).items(): default_vif_s_values = defaults(base + ['vif-s']) # XXX: T2665: we only wan't the vif-s defaults - do not care about vif-c @@ -375,6 +379,10 @@ def get_interface_dict(config, base, ifname=''): dict['vif_s'][vif_s] = T2665_set_dhcpv6pd_defaults( dict['vif_s'][vif_s]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif_s}', 'bridge') + if bridge: dict['vif_s'][vif_s].update({'is_bridge_member' : bridge}) + for vif_c, vif_c_config in vif_s_config.get('vif_c', {}).items(): default_vif_c_values = defaults(base + ['vif-s', 'vif-c']) @@ -389,6 +397,11 @@ def get_interface_dict(config, base, ifname=''): dict['vif_s'][vif_s]['vif_c'][vif_c] = T2665_set_dhcpv6pd_defaults( dict['vif_s'][vif_s]['vif_c'][vif_c]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif_s}.{vif_c}', 'bridge') + if bridge: dict['vif_s'][vif_s]['vif_c'][vif_c].update( + {'is_bridge_member' : bridge}) + # Check vif, vif-s/vif-c VLAN interfaces for removal dict = get_removed_vlans(config, dict) return dict |