summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-04-06 12:15:25 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-04-07 14:40:30 +0000
commitfbaa707f72ac1a0214ca57c8768fefa4b818738b (patch)
tree1046cc126729244a7c74472454318c164516a89b
parent11b2c478b7652ff38b378c8495aa45c8453b09f2 (diff)
downloadvyos-1x-fbaa707f72ac1a0214ca57c8768fefa4b818738b.tar.gz
vyos-1x-fbaa707f72ac1a0214ca57c8768fefa4b818738b.zip
ethernet: T5862: default MTU is not acceptable in some environments
There are cloud environments available where the maximum supported ethernet MTU is e.g. 1450 bytes, thus we clamp this to the adapters maximum MTU value or 1500 bytes - whatever is lower. (cherry picked from commit 8296cc727066e739c178918a91cfc11d20d26fe1)
-rw-r--r--python/vyos/configverify.py6
-rw-r--r--smoketest/scripts/cli/base_interfaces_test.py3
-rwxr-xr-xsrc/conf_mode/interfaces_ethernet.py13
3 files changed, 17 insertions, 5 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index 18642877a..4cb84194a 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -60,8 +60,8 @@ def verify_mtu_parent(config, parent):
mtu = int(config['mtu'])
parent_mtu = int(parent['mtu'])
if mtu > parent_mtu:
- raise ConfigError(f'Interface MTU ({mtu}) too high, ' \
- f'parent interface MTU is {parent_mtu}!')
+ raise ConfigError(f'Interface MTU "{mtu}" too high, ' \
+ f'parent interface MTU is "{parent_mtu}"!')
def verify_mtu_ipv6(config):
"""
@@ -76,7 +76,7 @@ def verify_mtu_ipv6(config):
if int(config['mtu']) < min_mtu:
interface = config['ifname']
error_msg = f'IPv6 address will be configured on interface "{interface}",\n' \
- f'the required minimum MTU is {min_mtu}!'
+ f'the required minimum MTU is "{min_mtu}"!'
if 'address' in config:
for address in config['address']:
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index a106ebe61..9be2c2f1a 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -519,8 +519,7 @@ class BasicInterfaceTest:
base = self._base_path + [interface, 'vif', vlan]
self.cli_set(base + ['mtu', mtu_9000])
- # check validate() - VIF MTU must not be larger the parent interface
- # MTU size.
+ # check validate() - Interface MTU "9000" too high, parent interface MTU is "1500"!
with self.assertRaises(ConfigSessionError):
self.cli_commit()
diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py
index 41efdb03c..6da7e6a69 100755
--- a/src/conf_mode/interfaces_ethernet.py
+++ b/src/conf_mode/interfaces_ethernet.py
@@ -152,6 +152,19 @@ def get_config(config=None):
base = ['interfaces', 'ethernet']
ifname, ethernet = get_interface_dict(conf, base, with_pki=True)
+ # T5862 - default MTU is not acceptable in some environments
+ # There are cloud environments available where the maximum supported
+ # ethernet MTU is e.g. 1450 bytes, thus we clamp this to the adapters
+ # maximum MTU value or 1500 bytes - whatever is lower
+ if 'mtu' not in ethernet:
+ try:
+ ethernet['mtu'] = '1500'
+ max_mtu = EthernetIf(ifname).get_max_mtu()
+ if max_mtu < int(ethernet['mtu']):
+ ethernet['mtu'] = str(max_mtu)
+ except:
+ pass
+
if 'is_bond_member' in ethernet:
update_bond_options(conf, ethernet)