From c399d0dd03fb4df3456418bfbe15162edd16c7d1 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 29 Dec 2015 13:49:27 -0200 Subject: Restore default MTU when field is cleared. Fixes #3926 --- src/etc/inc/interfaces.inc | 76 ++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 8b6643b..7d937ba 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3177,52 +3177,56 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven interfaces_bring_up($wancfg['if']); } - if (!empty($wancfg['mtu'])) { - if (stristr($realif, "_vlan")) { - $assignedparent = convert_real_interface_to_friendly_interface_name($realhwif); - if (!empty($assignedparent) && !empty($config['interfaces'][$assignedparent]['mtu'])) { - $parentmtu = $config['interfaces'][$assignedparent]['mtu']; - if ($wancfg['mtu'] > $parentmtu) { - log_error("There is a conflict on MTU between parent {$realhwif} and VLAN({$realif})"); - } - } else { - $parentmtu = 0; + if (isset($wancfg['mtu']) && is_numericint($wancfg['mtu'])) { + $mtu = $wancfg['mtu']; + } else { + $mtu = 1500; /* Default */ + } + + if (stristr($realif, "_vlan")) { + $assignedparent = convert_real_interface_to_friendly_interface_name($realhwif); + if (!empty($assignedparent) && !empty($config['interfaces'][$assignedparent]['mtu'])) { + $parentmtu = $config['interfaces'][$assignedparent]['mtu']; + if ($mtu > $parentmtu) { + log_error("There is a conflict on MTU between parent {$realhwif} and VLAN({$realif})"); } + } else { + $parentmtu = 0; + } - $parentmtu = interface_vlan_mtu_configured($realhwif, $parentmtu); + $parentmtu = interface_vlan_mtu_configured($realhwif, $parentmtu); - if (get_interface_mtu($realhwif) != $parentmtu) { - pfSense_interface_mtu($realhwif, $parentmtu); - } + if (get_interface_mtu($realhwif) != $parentmtu) { + pfSense_interface_mtu($realhwif, $parentmtu); + } - /* All vlans need to use the same mtu value as their parent. */ - interface_vlan_adapt_mtu(link_interface_to_vlans($realhwif), $parentmtu); - } else if (substr($realif, 0, 4) == 'lagg') { - /* LAGG interface must be destroyed and re-created to change MTU */ - if ($wancfg['mtu'] != get_interface_mtu($realif)) { - if (isset($config['laggs']['lagg']) && is_array($config['laggs']['lagg'])) { - foreach ($config['laggs']['lagg'] as $lagg) { - if ($lagg['laggif'] == $realif) { - interface_lagg_configure($lagg); - break; - } + /* All vlans need to use the same mtu value as their parent. */ + interface_vlan_adapt_mtu(link_interface_to_vlans($realhwif), $parentmtu); + } else if (substr($realif, 0, 4) == 'lagg') { + /* LAGG interface must be destroyed and re-created to change MTU */ + if ($mtu != get_interface_mtu($realif)) { + if (isset($config['laggs']['lagg']) && is_array($config['laggs']['lagg'])) { + foreach ($config['laggs']['lagg'] as $lagg) { + if ($lagg['laggif'] == $realif) { + interface_lagg_configure($lagg); + break; } } } - } else { - if ($wancfg['mtu'] != get_interface_mtu($realif)) { - pfSense_interface_mtu($realif, $wancfg['mtu']); - } + } + } else { + if ($mtu != get_interface_mtu($realif)) { + pfSense_interface_mtu($realif, $mtu); + } - /* This case is needed when the parent of vlans is being configured */ - $vlans = link_interface_to_vlans($realif); - if (is_array($vlans)) { - interface_vlan_adapt_mtu($vlans, $wancfg['mtu']); - } - unset($vlans); + /* This case is needed when the parent of vlans is being configured */ + $vlans = link_interface_to_vlans($realif); + if (is_array($vlans)) { + interface_vlan_adapt_mtu($vlans, $mtu); } - /* XXX: What about gre/gif/.. ? */ + unset($vlans); } + /* XXX: What about gre/gif/.. ? */ switch ($wancfg['ipaddr']) { case 'dhcp': -- cgit v1.1