Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethernet: T5862: default MTU is not acceptable in some environments (backport #3265) #3276

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
</constraint>
<constraintErrorMessage>MTU must be between 68 and 16000</constraintErrorMessage>
</properties>
<defaultValue>1500</defaultValue>
</leafNode>
<!-- include end -->
3 changes: 3 additions & 0 deletions interface-definitions/interfaces_bonding.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions interface-definitions/interfaces_bridge.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions interface-definitions/interfaces_dummy.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions interface-definitions/interfaces_vti.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion interface-definitions/interfaces_wireguard.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
6 changes: 3 additions & 3 deletions python/vyos/configverify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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']:
Expand Down
3 changes: 1 addition & 2 deletions smoketest/scripts/cli/base_interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ def test_vif_8021q_mtu_limits(self):
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()

Expand Down
13 changes: 13 additions & 0 deletions src/conf_mode/interfaces_ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading