summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorinitramfs <initramfs@initramfs.io>2022-09-01 20:51:21 +0800
committerinitramfs <initramfs@initramfs.io>2022-09-02 19:36:01 +0800
commit95e7676aa8ae5b3476b14a334b3815c2ae59f8d6 (patch)
tree941712a056349f620004eb8609fe7fd4a646937d /src/conf_mode
parent6287cc214be8f506f0656b7ad75143265213d140 (diff)
downloadvyos-1x-95e7676aa8ae5b3476b14a334b3815c2ae59f8d6.tar.gz
vyos-1x-95e7676aa8ae5b3476b14a334b3815c2ae59f8d6.zip
bonding: T4668: fix live bonding member add or remove
Fixes several bugs around bonding member interface states not matching the committed configuration, including: - Disabled removed interfaces coming back up - Newly added disabled interfaces not staying down - Newly added interfaces not showing up in the bond
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-bonding.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py
index 8ef3d9990..21cf204fc 100755
--- a/src/conf_mode/interfaces-bonding.py
+++ b/src/conf_mode/interfaces-bonding.py
@@ -89,6 +89,11 @@ def get_config(config=None):
# determine which members have been removed
interfaces_removed = leaf_node_changed(conf, base + [ifname, 'member', 'interface'])
+
+ # Reset config level to interfaces
+ old_level = conf.get_level()
+ conf.set_level(['interfaces'])
+
if interfaces_removed:
bond['shutdown_required'] = {}
if 'member' not in bond:
@@ -97,7 +102,7 @@ def get_config(config=None):
tmp = {}
for interface in interfaces_removed:
section = Section.section(interface) # this will be 'ethernet' for 'eth0'
- if conf.exists(['insterfaces', section, interface, 'disable']):
+ if conf.exists([section, interface, 'disable']):
tmp[interface] = {'disable': ''}
else:
tmp[interface] = {}
@@ -105,8 +110,24 @@ def get_config(config=None):
# also present the interfaces to be removed from the bond as dictionary
bond['member']['interface_remove'] = tmp
+ # Restore existing config level
+ conf.set_level(old_level)
+
if dict_search('member.interface', bond):
for interface, interface_config in bond['member']['interface'].items():
+ # Check if member interface is a new member
+ if not conf.exists_effective(['member', 'interface', interface]):
+ bond['shutdown_required'] = {}
+
+ # Check if member interface is disabled
+ conf.set_level(['interfaces'])
+
+ section = Section.section(interface) # this will be 'ethernet' for 'eth0'
+ if conf.exists([section, interface, 'disable']):
+ interface_config['disable'] = ''
+
+ conf.set_level(old_level)
+
# Check if member interface is already member of another bridge
tmp = is_member(conf, interface, 'bridge')
if tmp: interface_config['is_bridge_member'] = tmp