diff options
| author | Nataliia Solomko <natalirs1985@gmail.com> | 2026-03-23 13:36:00 +0200 |
|---|---|---|
| committer | Nataliia Solomko <natalirs1985@gmail.com> | 2026-03-23 13:36:00 +0200 |
| commit | d922f888dc822cc4e3b7ce70a4402ece7eef6e41 (patch) | |
| tree | f5a8072535f189c3985929280434d7d2f395ed60 /src | |
| parent | 42b2376e030f85b602862632b3e8e8534a3a5ef1 (diff) | |
| download | vyos-1x-d922f888dc822cc4e3b7ce70a4402ece7eef6e41.tar.gz vyos-1x-d922f888dc822cc4e3b7ce70a4402ece7eef6e41.zip | |
vpp: T8355: Set MTU for vpp interfaces
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_mode/vpp_interfaces_bonding.py | 17 | ||||
| -rw-r--r-- | src/conf_mode/vpp_interfaces_gre.py | 3 | ||||
| -rw-r--r-- | src/conf_mode/vpp_interfaces_ipip.py | 3 | ||||
| -rw-r--r-- | src/conf_mode/vpp_interfaces_vxlan.py | 28 |
4 files changed, 51 insertions, 0 deletions
diff --git a/src/conf_mode/vpp_interfaces_bonding.py b/src/conf_mode/vpp_interfaces_bonding.py index 8d9930a20..80356ce2b 100644 --- a/src/conf_mode/vpp_interfaces_bonding.py +++ b/src/conf_mode/vpp_interfaces_bonding.py @@ -19,10 +19,12 @@ from vyos.config import Config from vyos.configdict import get_interface_dict from vyos.configdep import set_dependents, call_dependents +from vyos.configverify import verify_mtu_ipv6 from vyos import ConfigError from vyos.utils.assertion import assert_mac from vyos.utils.process import is_systemd_service_active +from vyos.ifconfig import Interface from vyos.ifconfig.vpp import VPPBondInterface from vyos.vpp.config_deps import deps_bond_dict from vyos.vpp.config_deps import deps_bridge_dict @@ -174,6 +176,19 @@ def verify(config): f'it already belongs to bridge interface: {", ".join(bridge_members)}.' ) + if mtu := config.get('mtu'): + mtu = int(mtu) + max_mtu = Interface(iface).get_max_mtu() + min_mtu = Interface(iface).get_min_mtu() + if mtu > max_mtu: + raise ConfigError( + f'Configured MTU is greater than member interface "{iface}" maximum of {max_mtu}!' + ) + if mtu < min_mtu: + raise ConfigError( + f'Configured MTU is less than member interface "{iface}" minimum of {min_mtu}!' + ) + if 'mac' in config: mac = config['mac'] try: @@ -190,6 +205,8 @@ def verify(config): f'Cannot remove interface {vif_iface}: it is still in use by the PPPoE server' ) + verify_mtu_ipv6(config) + def generate(config): pass diff --git a/src/conf_mode/vpp_interfaces_gre.py b/src/conf_mode/vpp_interfaces_gre.py index 1258f906c..3756449a2 100644 --- a/src/conf_mode/vpp_interfaces_gre.py +++ b/src/conf_mode/vpp_interfaces_gre.py @@ -21,6 +21,7 @@ from vyos import ConfigError from vyos.config import Config from vyos.configdict import get_interface_dict from vyos.configdep import set_dependents, call_dependents +from vyos.configverify import verify_mtu_ipv6 from vyos.utils.process import is_systemd_service_active from vyos.ifconfig.vpp import VPPGREInterface @@ -128,6 +129,8 @@ def verify(config): if config.get('source_address') == config.get('remote'): raise ConfigError('Remote address must not be the same as source address') + verify_mtu_ipv6(config) + # Disable checks as point-to-multipoint mode does not work without 'teib' feature that is not implemented yet # # check multipoint mode # if config.get('mode') == 'point-to-multipoint': diff --git a/src/conf_mode/vpp_interfaces_ipip.py b/src/conf_mode/vpp_interfaces_ipip.py index d029f3619..dd4a19e36 100644 --- a/src/conf_mode/vpp_interfaces_ipip.py +++ b/src/conf_mode/vpp_interfaces_ipip.py @@ -21,6 +21,7 @@ from vyos import ConfigError from vyos.config import Config from vyos.configdict import get_interface_dict from vyos.configdep import set_dependents, call_dependents +from vyos.configverify import verify_mtu_ipv6 from vyos.utils.process import is_systemd_service_active from vyos.ifconfig.vpp import VPPIPIPInterface @@ -102,6 +103,8 @@ def verify(config): if config.get('source_address') == config.get('remote'): raise ConfigError('Remote address must not be the same as source address') + verify_mtu_ipv6(config) + def generate(config): pass diff --git a/src/conf_mode/vpp_interfaces_vxlan.py b/src/conf_mode/vpp_interfaces_vxlan.py index 38349cb4c..ac9a9517b 100644 --- a/src/conf_mode/vpp_interfaces_vxlan.py +++ b/src/conf_mode/vpp_interfaces_vxlan.py @@ -18,9 +18,14 @@ from vyos import ConfigError +from vyos.base import Warning from vyos.config import Config from vyos.configdict import get_interface_dict from vyos.configdep import set_dependents, call_dependents +from vyos.configverify import verify_mtu_ipv6 +from vyos.ifconfig import Interface +from vyos.template import is_ipv6 +from vyos.utils.network import get_interfaces_by_ip from vyos.utils.process import is_systemd_service_active from vyos.ifconfig.vpp import VPPVXLANInterface @@ -117,6 +122,29 @@ def verify(config): if config.get('source_address') == config.get('remote'): raise ConfigError('Remote address must not be the same as source address') + # VXLAN adds at least an overhead of 50 bytes - we need to check the + # underlying device if our VXLAN package is not going to be fragmented! + source_address = config['source_address'] + vxlan_overhead = 50 + if is_ipv6(source_address): + # IPv6 adds an extra 20 bytes overhead because the IPv6 header is 20 + # bytes larger than the IPv4 header - assuming no extra options are + # in use. + vxlan_overhead += 20 + + ifaces_with_ip = get_interfaces_by_ip(source_address) + vpp_ifaces = config['vpp_ether_vif_ifaces'] + matching_iface = next((iface for iface in ifaces_with_ip if iface in vpp_ifaces)) + + lower_mtu = Interface(matching_iface).get_mtu() + if lower_mtu < (int(config['mtu']) + vxlan_overhead): + Warning( + f'Underlying device MTU is too small ({lower_mtu} bytes) ' + f'for VXLAN overhead ({vxlan_overhead} bytes!)' + ) + + verify_mtu_ipv6(config) + def generate(config): pass |
