diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-01-31 18:06:14 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-01-31 18:10:56 +0100 |
commit | ff3e3b1dc75f63284fc93e788415dca87d9015ee (patch) | |
tree | c7892837e2166aa98c7c33e3a5896e7c5c488c52 /src/conf_mode/interfaces-bonding.py | |
parent | 4a4e2b6386b4c036bbf4486a8a7ac7002d08158b (diff) | |
download | vyos-1x-ff3e3b1dc75f63284fc93e788415dca87d9015ee.tar.gz vyos-1x-ff3e3b1dc75f63284fc93e788415dca87d9015ee.zip |
bond: T1992: only tear down interface if it's really required
Without this change the bond interface is always torn down prior changing it's
parameters. This will also reset BGP sessions on other VLAN interfaces which
is more then bad.
This change will only tear down the interface when it is really required,
indicated by bond['shutdown_required'], which is required by certain operations
as e.g. changing the operating mode.
Diffstat (limited to 'src/conf_mode/interfaces-bonding.py')
-rwxr-xr-x | src/conf_mode/interfaces-bonding.py | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index c798fd44e..ac4f213ec 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -52,6 +52,7 @@ default_config_data = { 'mac': '', 'mode': '802.3ad', 'member': [], + 'shutdown_required': False, 'mtu': 1500, 'primary': '', 'vif_s': [], @@ -193,7 +194,12 @@ def get_config(): # Bonding mode if conf.exists('mode'): - bond['mode'] = get_bond_mode(conf.return_value('mode')) + act_mode = conf.return_value('mode') + eff_mode = conf.return_effective_value('mode') + if not (act_mode == eff_mode): + bond['shutdown_required'] = True + + bond['mode'] = get_bond_mode(act_mode) # Maximum Transmission Unit (MTU) if conf.exists('mtu'): @@ -202,6 +208,9 @@ def get_config(): # determine bond member interfaces (currently configured) if conf.exists('member interface'): bond['member'] = conf.return_values('member interface') + eff_member = conf.return_effective_values('member interface') + if not (bond['member'] == eff_member): + bond['shutdown_required'] = True # Primary device interface if conf.exists('primary'): @@ -333,7 +342,6 @@ def verify(bond): def generate(bond): return None - def apply(bond): b = BondIf(bond['intf']) @@ -341,15 +349,6 @@ def apply(bond): # delete interface b.remove() else: - # Some parameters can not be changed when the bond is up. - # Always disable the bond prior changing anything - b.set_state('down') - - # The bonding mode can not be changed when there are interfaces enslaved - # to this bond, thus we will free all interfaces from the bond first! - for intf in b.get_slaves(): - b.del_port(intf) - # ARP link monitoring frequency, reset miimon when arp-montior is inactive # this is done inside BondIf automatically b.set_arp_interval(bond['arp_mon_intvl']) @@ -398,7 +397,7 @@ def apply(bond): if bond['dhcpv6_temporary']: opt['dhcpv6_temporary'] = True - # store DHCPv6 config dictionary - used later on when addresses are aquired + # store DHCPv6 config dictionary - used later on when addresses are required b.set_dhcpv6_options(opt) # ignore link state changes @@ -424,8 +423,6 @@ def apply(bond): if bond['mac']: b.set_mac(bond['mac']) - # Bonding policy - b.set_mode(bond['mode']) # Maximum Transmission Unit (MTU) b.set_mtu(bond['mtu']) @@ -433,15 +430,30 @@ def apply(bond): if bond['primary']: b.set_primary(bond['primary']) - # Add (enslave) interfaces to bond - for intf in bond['member']: - b.add_port(intf) + # Some parameters can not be changed when the bond is up. + if bond['shutdown_required']: + # Disable bond prior changing of certain properties + b.set_state('down') + + # The bonding mode can not be changed when there are interfaces enslaved + # to this bond, thus we will free all interfaces from the bond first! + for intf in b.get_slaves(): + b.del_port(intf) + + # Bonding policy/mode + b.set_mode(bond['mode']) + + # Add (enslave) interfaces to bond + for intf in bond['member']: + b.add_port(intf) # As the bond interface is always disabled first when changing # parameters we will only re-enable the interface if it is not # administratively disabled if not bond['disable']: b.set_state('up') + else: + b.set_state('down') # Configure interface address(es) # - not longer required addresses get removed first |