summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig_vlan.py
diff options
context:
space:
mode:
authorJernej Jakob <jernej.jakob@gmail.com>2020-05-03 16:01:53 +0200
committerJernej Jakob <jernej.jakob@gmail.com>2020-05-04 22:25:48 +0200
commit963dcd509fa491a30d0dd6266d827fb60bb9e27b (patch)
treefd731e52ba0da0ac9b6e1847c644b065ffb62715 /python/vyos/ifconfig_vlan.py
parente35807b209e3de77b09082a74d2b0f0b1a802206 (diff)
downloadvyos-1x-963dcd509fa491a30d0dd6266d827fb60bb9e27b.tar.gz
vyos-1x-963dcd509fa491a30d0dd6266d827fb60bb9e27b.zip
vlan: T2241: fix falling out of bridge when changing settings
Previously, set_vrf was always called, which uses the same master and nomaster commands as bridge, so it removed the interface from the bridge. - add checks to make VRF and bridge membership mutually exclusive - always re-add the interface back to any bridge it is part of in case it is deleted and recreated (e.g. changing egress/ingress-qos)
Diffstat (limited to 'python/vyos/ifconfig_vlan.py')
-rw-r--r--python/vyos/ifconfig_vlan.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py
index 079118df6..bc43ff6db 100644
--- a/python/vyos/ifconfig_vlan.py
+++ b/python/vyos/ifconfig_vlan.py
@@ -63,8 +63,10 @@ def apply_vlan_config(vlan, config):
# Maximum Transmission Unit (MTU)
vlan.set_mtu(config['mtu'])
- # assign/remove VRF
- vlan.set_vrf(config['vrf'])
+ # assign/remove VRF (ONLY when not a member of a bridge,
+ # otherwise 'nomaster' removes it from it)
+ if not config['is_bridge_member']:
+ vlan.set_vrf(config['vrf'])
# Delete old IPv6 EUI64 addresses before changing MAC
for addr in config['ipv6_eui64_prefix_remove']:
@@ -92,6 +94,10 @@ def apply_vlan_config(vlan, config):
for addr in config['address']:
vlan.add_addr(addr)
+ # re-add ourselves to any bridge we might have fallen out of
+ if config['is_bridge_member']:
+ vlan.add_to_bridge(config['is_bridge_member'])
+
def verify_vlan_config(config):
"""
Generic function to verify VLAN config consistency. Instead of re-
@@ -103,7 +109,6 @@ def verify_vlan_config(config):
if vif['dhcpv6_prm_only'] and vif['dhcpv6_temporary']:
raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!')
-
if vif['vrf']:
if vif['vrf'] not in interfaces():
raise ConfigError(f'VRF "{vif["vrf"]}" does not exist')
@@ -127,7 +132,6 @@ def verify_vlan_config(config):
if vif_s['dhcpv6_prm_only'] and vif_s['dhcpv6_temporary']:
raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!')
-
if vif_s['vrf']:
if vif_s['vrf'] not in interfaces():
raise ConfigError(f'VRF "{vif_s["vrf"]}" does not exist')
@@ -142,7 +146,6 @@ def verify_vlan_config(config):
if vif_c['dhcpv6_prm_only'] and vif_c['dhcpv6_temporary']:
raise ConfigError('DHCPv6 temporary and parameters-only options are mutually exclusive!')
-
if vif_c['vrf']:
if vif_c['vrf'] not in interfaces():
raise ConfigError(f'VRF "{vif_c["vrf"]}" does not exist')