diff options
| -rwxr-xr-x | smoketest/scripts/cli/test_interfaces_bonding.py | 24 | ||||
| -rwxr-xr-x | src/conf_mode/interfaces_bonding.py | 11 |
2 files changed, 35 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py index 21918282d..b6eb5328d 100755 --- a/smoketest/scripts/cli/test_interfaces_bonding.py +++ b/smoketest/scripts/cli/test_interfaces_bonding.py @@ -334,5 +334,29 @@ class BondingInterfaceTest(BasicInterfaceTest.TestCase): id = int(id) + 1 + def test_bonding_member_mtu(self): + # This Smoketest only works on our CI platform where we force the NIC + # to virtio and an MTU of only 1500 bytes max + if not os.path.exists('/tmp/vyos.smoketests.hint'): + self.skipTest('Not running under VyOS CI/CD QEMU environment!') + + 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, 'mtu', '10000']) + + # check validate() - MTU of bond higher then virtio max MTU + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + for interface in self._interfaces: + for option in self._options.get(interface, []): + self.cli_set(self._base_path + [interface] + option.split()) + + self.cli_delete(self._base_path + [interface, 'mtu']) + + self.cli_commit() + if __name__ == '__main__': unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on()) diff --git a/src/conf_mode/interfaces_bonding.py b/src/conf_mode/interfaces_bonding.py index 68c2885bc..f844d0a21 100755 --- a/src/conf_mode/interfaces_bonding.py +++ b/src/conf_mode/interfaces_bonding.py @@ -248,6 +248,17 @@ def verify(bond): continue raise ConfigError(error_msg + f'it has a "{option_path.replace(".", " ")}" assigned!') + if mtu := bond.get('mtu'): + mtu = int(mtu) + max_mtu = int(EthernetIf(interface).get_max_mtu()) + min_mtu = int(EthernetIf(interface).get_min_mtu()) + if mtu > max_mtu: + raise ConfigError('Configured MTU is greater then member '\ + f'interface "{interface}" maximum of {max_mtu}!') + if mtu < min_mtu: + raise ConfigError('Configured MTU is less then member '\ + f'interface "{interface}" minimum of {min_mtu}!') + if 'primary' in bond: if bond['primary'] not in bond['member']['interface']: raise ConfigError(f'Primary interface of bond "{bond_name}" must be a member interface') |
