From 2935d13e45fd63cc9b8d85e7e0b7c5d74cef43f1 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 16 Aug 2023 15:14:26 +0200 Subject: [PATCH] interfaces: adjust MTU for VLAN parents For a VLAN on top of HW this doesn't seem required (although it makes sense) the VLAN on top of VLAN actually needs this so add it for both. It should be said that this is simply trying to fix setting oversize MTU values and therefore now backs off when the parent MTU fits the requirement. Still try to set any bad MTU value configured by the user. --- src/etc/inc/interfaces.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index e7164db73..d05991758 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2168,15 +2168,19 @@ function interface_configure_mtu($device, $mtu, $ifconfig_details) { if (strstr($device, 'vlan') || strstr($device, 'qinq')) { $parent_device = interface_parent_devices($device)[0]; - $parent_mtu = $mtu; + $parent_mtu = $mtu + 4; + $force = false; $parent_cfg = $config['interfaces'][convert_real_interface_to_friendly_interface_name($parent_realif)] ?? []; if (isset($parent_cfg['enable']) && !empty($parent_cfg['mtu'])) { $parent_mtu = $parent_cfg['mtu']; + $force = true; } - /* configure parent MTU now to avoid silent fail for current device MTU change */ - interface_configure_mtu($parent_device, $parent_mtu, $ifconfig_details); + if ($force || $mtu > $ifconfig_details[$parent_device]['mtu']) { + /* configure parent MTU recursively to avoid a fail for current device MTU requirement */ + interface_configure_mtu($parent_device, $parent_mtu, $ifconfig_details); + } } if ($mtu != $ifconfig_details[$device]['mtu']) {