diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-07-14 21:46:55 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-07-15 07:10:29 +0200 |
commit | 3592f56a8deb6c44dcdd7a44ef54fc2c39eb1a3b (patch) | |
tree | 99e64b38e8e6eade84781939d32fec070be53c01 /python/vyos/ifconfig/interface.py | |
parent | 5b4f76429989a6ab8ca64aeed5a1fae09fe7c6ca (diff) | |
download | vyos-1x-3592f56a8deb6c44dcdd7a44ef54fc2c39eb1a3b.tar.gz vyos-1x-3592f56a8deb6c44dcdd7a44ef54fc2c39eb1a3b.zip |
bond: T4525: fix adding member interface to bond after removing VRF
When removing a VRF from an ethernet interface and adding the interface to a
bond in the same commit led to an OSError: [Errno 16] Device or resource busy!
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
-rw-r--r-- | python/vyos/ifconfig/interface.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index b9001d1f2..555494f80 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -1454,14 +1454,22 @@ class Interface(Control): if dhcpv6pd: self.set_dhcpv6(True) - # There are some items in the configuration which can only be applied - # if this instance is not bound to a bridge. This should be checked - # by the caller but better save then sorry! - if not any(k in ['is_bond_member', 'is_bridge_member'] for k in config): - # Bind interface to given VRF or unbind it if vrf node is not set. - # unbinding will call 'ip link set dev eth0 nomaster' which will - # also drop the interface out of a bridge or bond - thus this is - # checked before + # XXX: Bind interface to given VRF or unbind it if vrf is not set. Unbinding + # will call 'ip link set dev eth0 nomaster' which will also drop the + # interface out of any bridge or bond - thus this is checked before. + if 'is_bond_member' in config: + bond_if = next(iter(config['is_bond_member'])) + tmp = get_interface_config(config['ifname']) + if 'master' in tmp and tmp['master'] != bond_if: + self.set_vrf('') + + elif 'is_bridge_member' in config: + bridge_if = next(iter(config['is_bridge_member'])) + tmp = get_interface_config(config['ifname']) + if 'master' in tmp and tmp['master'] != bridge_if: + self.set_vrf('') + + else: self.set_vrf(config.get('vrf', '')) # Add this section after vrf T4331 @@ -1575,8 +1583,8 @@ class Interface(Control): # re-add ourselves to any bridge we might have fallen out of if 'is_bridge_member' in config: - bridge_dict = config.get('is_bridge_member') - self.add_to_bridge(bridge_dict) + tmp = config.get('is_bridge_member') + self.add_to_bridge(tmp) # eXpress Data Path - highly experimental self.set_xdp('xdp' in config) |