diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-04-07 19:37:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-07 19:37:22 +0200 |
commit | 96f7fb69fb6ba34f15e35b4cddbb108eebda6199 (patch) | |
tree | 1046cc126729244a7c74472454318c164516a89b | |
parent | b286552f1d0f1bfa23eea29ab92426db27efc425 (diff) | |
parent | fbaa707f72ac1a0214ca57c8768fefa4b818738b (diff) | |
download | vyos-1x-96f7fb69fb6ba34f15e35b4cddbb108eebda6199.tar.gz vyos-1x-96f7fb69fb6ba34f15e35b4cddbb108eebda6199.zip |
Merge pull request #3276 from vyos/mergify/bp/sagitta/pr-3265
ethernet: T5862: default MTU is not acceptable in some environments (backport #3265)
-rw-r--r-- | interface-definitions/include/interface/mtu-68-16000.xml.i | 1 | ||||
-rw-r--r-- | interface-definitions/interfaces_bonding.xml.in | 3 | ||||
-rw-r--r-- | interface-definitions/interfaces_bridge.xml.in | 3 | ||||
-rw-r--r-- | interface-definitions/interfaces_dummy.xml.in | 3 | ||||
-rw-r--r-- | interface-definitions/interfaces_vti.xml.in | 3 | ||||
-rw-r--r-- | interface-definitions/interfaces_wireguard.xml.in | 2 | ||||
-rw-r--r-- | python/vyos/configverify.py | 6 | ||||
-rw-r--r-- | smoketest/scripts/cli/base_interfaces_test.py | 3 | ||||
-rwxr-xr-x | src/conf_mode/interfaces_ethernet.py | 13 |
9 files changed, 30 insertions, 7 deletions
diff --git a/interface-definitions/include/interface/mtu-68-16000.xml.i b/interface-definitions/include/interface/mtu-68-16000.xml.i index cb666f470..df1b7b716 100644 --- a/interface-definitions/include/interface/mtu-68-16000.xml.i +++ b/interface-definitions/include/interface/mtu-68-16000.xml.i @@ -11,6 +11,5 @@ </constraint> <constraintErrorMessage>MTU must be between 68 and 16000</constraintErrorMessage> </properties> - <defaultValue>1500</defaultValue> </leafNode> <!-- include end --> diff --git a/interface-definitions/interfaces_bonding.xml.in b/interface-definitions/interfaces_bonding.xml.in index 62ee0bdc7..92c0911db 100644 --- a/interface-definitions/interfaces_bonding.xml.in +++ b/interface-definitions/interfaces_bonding.xml.in @@ -261,6 +261,9 @@ </children> </node> #include <include/interface/mtu-68-16000.xml.i> + <leafNode name="mtu"> + <defaultValue>1500</defaultValue> + </leafNode> <leafNode name="primary"> <properties> <help>Primary device interface</help> diff --git a/interface-definitions/interfaces_bridge.xml.in b/interface-definitions/interfaces_bridge.xml.in index 7fb5f121a..29dd61df5 100644 --- a/interface-definitions/interfaces_bridge.xml.in +++ b/interface-definitions/interfaces_bridge.xml.in @@ -41,6 +41,9 @@ #include <include/interface/disable.xml.i> #include <include/interface/vrf.xml.i> #include <include/interface/mtu-68-16000.xml.i> + <leafNode name="mtu"> + <defaultValue>1500</defaultValue> + </leafNode> <leafNode name="forwarding-delay"> <properties> <help>Forwarding delay</help> diff --git a/interface-definitions/interfaces_dummy.xml.in b/interface-definitions/interfaces_dummy.xml.in index ef8ee78e7..36b4e41f2 100644 --- a/interface-definitions/interfaces_dummy.xml.in +++ b/interface-definitions/interfaces_dummy.xml.in @@ -46,6 +46,9 @@ </children> </node> #include <include/interface/mtu-68-16000.xml.i> + <leafNode name="mtu"> + <defaultValue>1500</defaultValue> + </leafNode> #include <include/interface/mirror.xml.i> #include <include/interface/netns.xml.i> #include <include/interface/redirect.xml.i> diff --git a/interface-definitions/interfaces_vti.xml.in b/interface-definitions/interfaces_vti.xml.in index 158d9afd0..39fb3131e 100644 --- a/interface-definitions/interfaces_vti.xml.in +++ b/interface-definitions/interfaces_vti.xml.in @@ -22,6 +22,9 @@ #include <include/interface/ipv4-options.xml.i> #include <include/interface/ipv6-options.xml.i> #include <include/interface/mtu-68-16000.xml.i> + <leafNode name="mtu"> + <defaultValue>1500</defaultValue> + </leafNode> #include <include/interface/mirror.xml.i> #include <include/interface/redirect.xml.i> #include <include/interface/vrf.xml.i> diff --git a/interface-definitions/interfaces_wireguard.xml.in b/interface-definitions/interfaces_wireguard.xml.in index fba1064ef..ce49de038 100644 --- a/interface-definitions/interfaces_wireguard.xml.in +++ b/interface-definitions/interfaces_wireguard.xml.in @@ -21,10 +21,10 @@ #include <include/interface/disable.xml.i> #include <include/port-number.xml.i> #include <include/interface/mtu-68-16000.xml.i> - #include <include/interface/mirror.xml.i> <leafNode name="mtu"> <defaultValue>1420</defaultValue> </leafNode> + #include <include/interface/mirror.xml.i> #include <include/interface/ipv4-options.xml.i> #include <include/interface/ipv6-options.xml.i> <leafNode name="fwmark"> 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) |