From 234f35d8bae71b5d33ad97cdabc236ec6b13c3a2 Mon Sep 17 00:00:00 2001 From: fett0 Date: Sat, 4 May 2024 17:07:26 +0000 Subject: bond: T6303: add system mac address on bond --- smoketest/scripts/cli/test_interfaces_bonding.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'smoketest/scripts') diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py index 419de774a..091a7a3c5 100755 --- a/smoketest/scripts/cli/test_interfaces_bonding.py +++ b/smoketest/scripts/cli/test_interfaces_bonding.py @@ -241,6 +241,22 @@ class BondingInterfaceTest(BasicInterfaceTest.TestCase): for member in self._members: self.assertIn(member, slaves) + def test_bonding_system_mac(self): + # configure member interfaces and system-mac + system_mac = '00:50:ab:cd:ef:11' + for interface in self._interfaces: + for option in self._options.get(interface, []): + self.cli_set(self._base_path + [interface] + option.split()) + + self.cli_set(self._base_path + [interface, 'system-mac', system_mac]) + + self.cli_commit() + + # verify config + for interface in self._interfaces: + defined_mac = read_file(f'/sys/class/net/{interface}/bonding/ad_actor_system') + self.assertIn(defined_mac, system_mac) + def test_bonding_evpn_multihoming(self): id = '5' for interface in self._interfaces: -- cgit v1.2.3 From 314901e7b45782fb6266b35b0e788ab7ea1404b8 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Fri, 10 May 2024 15:17:22 +0200 Subject: bond: T6303: must reset system-mac to 00:00:00:00:00:00 on deletion --- python/vyos/ifconfig/bond.py | 19 +++++++++++-------- smoketest/scripts/cli/test_interfaces_bonding.py | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'smoketest/scripts') diff --git a/python/vyos/ifconfig/bond.py b/python/vyos/ifconfig/bond.py index f26426915..b8ea90049 100644 --- a/python/vyos/ifconfig/bond.py +++ b/python/vyos/ifconfig/bond.py @@ -449,18 +449,13 @@ class BondIf(Interface): Interface(interface).set_admin_state('up') # Bonding policy/mode - default value, always present - mode = config.get('mode') - self.set_mode(mode) + self.set_mode(config['mode']) # LACPDU transmission rate - default value - if mode == '802.3ad': + if config['mode'] == '802.3ad': self.set_lacp_rate(config.get('lacp_rate')) - # Add system mac address for 802.3ad - if mode == '802.3ad' and 'system_mac' in config: - self.set_system_mac(config.get('system_mac')) - - if mode not in ['802.3ad', 'balance-tlb', 'balance-alb']: + if config['mode'] not in ['802.3ad', 'balance-tlb', 'balance-alb']: tmp = dict_search('arp_monitor.interval', config) value = tmp if (tmp != None) else '0' self.set_arp_interval(value) @@ -495,6 +490,14 @@ class BondIf(Interface): Interface(interface).flush_addrs() self.add_port(interface) + # Add system mac address for 802.3ad - default address is all zero + # mode is always present (defaultValue) + if config['mode'] == '802.3ad': + mac = '00:00:00:00:00:00' + if 'system_mac' in config: + mac = config['system_mac'] + self.set_system_mac(mac) + # Primary device interface - must be set after 'mode' value = config.get('primary') if value: self.set_primary(value) diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py index 091a7a3c5..f436424b8 100755 --- a/smoketest/scripts/cli/test_interfaces_bonding.py +++ b/smoketest/scripts/cli/test_interfaces_bonding.py @@ -243,7 +243,9 @@ class BondingInterfaceTest(BasicInterfaceTest.TestCase): def test_bonding_system_mac(self): # configure member interfaces and system-mac + default_system_mac = '00:00:00:00:00:00' # default MAC is all zeroes system_mac = '00:50:ab:cd:ef:11' + for interface in self._interfaces: for option in self._options.get(interface, []): self.cli_set(self._base_path + [interface] + option.split()) @@ -254,8 +256,18 @@ class BondingInterfaceTest(BasicInterfaceTest.TestCase): # verify config for interface in self._interfaces: - defined_mac = read_file(f'/sys/class/net/{interface}/bonding/ad_actor_system') - self.assertIn(defined_mac, system_mac) + tmp = read_file(f'/sys/class/net/{interface}/bonding/ad_actor_system') + self.assertIn(tmp, system_mac) + + for interface in self._interfaces: + self.cli_delete(self._base_path + [interface, 'system-mac']) + + self.cli_commit() + + # verify default value + for interface in self._interfaces: + tmp = read_file(f'/sys/class/net/{interface}/bonding/ad_actor_system') + self.assertIn(tmp, default_system_mac) def test_bonding_evpn_multihoming(self): id = '5' -- cgit v1.2.3