diff options
| -rw-r--r-- | interface-definitions/interfaces_bonding.xml.in | 12 | ||||
| -rw-r--r-- | python/vyos/ifconfig/bond.py | 27 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_interfaces_bonding.py | 16 | 
3 files changed, 55 insertions, 0 deletions
| diff --git a/interface-definitions/interfaces_bonding.xml.in b/interface-definitions/interfaces_bonding.xml.in index 92c0911db..e6baed590 100644 --- a/interface-definitions/interfaces_bonding.xml.in +++ b/interface-definitions/interfaces_bonding.xml.in @@ -176,6 +176,18 @@              </properties>              <defaultValue>0</defaultValue>            </leafNode> +          <leafNode name="system-mac"> +            <properties> +              <help>System MAC address for 802.3ad</help> +              <valueHelp> +                <format>macaddr</format> +                <description>MAC address</description> +              </valueHelp> +              <constraint> +                <validator name="mac-address"/> +              </constraint> +            </properties> +          </leafNode>            <leafNode name="lacp-rate">              <properties>                <help>Rate in which we will ask our link partner to transmit LACPDU packets</help> diff --git a/python/vyos/ifconfig/bond.py b/python/vyos/ifconfig/bond.py index c6d0f1cff..b381ba0e1 100644 --- a/python/vyos/ifconfig/bond.py +++ b/python/vyos/ifconfig/bond.py @@ -18,6 +18,7 @@ import os  from vyos.ifconfig.interface import Interface  from vyos.utils.dict import dict_search  from vyos.utils.assertion import assert_list +from vyos.utils.assertion import assert_mac  from vyos.utils.assertion import assert_positive  @Interface.register @@ -54,6 +55,10 @@ class BondIf(Interface):              'validate': lambda v: assert_list(v, ['slow', 'fast']),              'location': '/sys/class/net/{ifname}/bonding/lacp_rate',          }, +        'bond_system_mac': { +            'validate': assert_mac, +            'location': '/sys/class/net/{ifname}/bonding/ad_actor_system', +        },          'bond_miimon': {              'validate': assert_positive,              'location': '/sys/class/net/{ifname}/bonding/miimon' @@ -385,6 +390,24 @@ class BondIf(Interface):          """          return self.set_interface('bond_mode', mode) +    def set_system_mac(self, mac): +        """ +        In an AD system, this specifies the mac-address for the actor in +	    protocol packet exchanges (LACPDUs). The value cannot be NULL or +	    multicast. It is preferred to have the local-admin bit set for this +	    mac but driver does not enforce it. If the value is not given then +	    system defaults to using the masters' mac address as actors' system +	    address. + +	    This parameter has effect only in 802.3ad mode and is available through +	    SysFs interface. + +        Example: +        >>> from vyos.ifconfig import BondIf +        >>> BondIf('bond0').set_system_mac('00:50:ab:cd:ef:01') +        """ +        return self.set_interface('bond_system_mac', mac) +      def update(self, config):          """ General helper function which works on a dictionary retrived by          get_config_dict(). It's main intention is to consolidate the scattered @@ -433,6 +456,10 @@ class BondIf(Interface):              if 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']:                  tmp = dict_search('arp_monitor.interval', config)                  value = tmp if (tmp != None) else '0' 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: | 
