Commit 5525a08a authored by Ad Schellevis's avatar Ad Schellevis

interfaces.inc, fix mtu setup for vlans, for https://github.com/opnsense/core/issues/1709

parent 8236ddcc
...@@ -2517,37 +2517,6 @@ function interface_virtual_create($interface) ...@@ -2517,37 +2517,6 @@ function interface_virtual_create($interface)
} }
} }
function interface_vlan_adapt_mtu($vlanifs, $mtu)
{
global $config;
if (!is_array($vlanifs)) {
return;
}
/* All vlans need to use the same mtu value as their parent. */
foreach ($vlanifs as $vlan) {
$assignedport = convert_real_interface_to_friendly_interface_name($vlan['vlanif']);
if (!empty($assignedport)) {
if (!empty($config['interfaces'][$assignedport]['mtu'])) {
/*
* XXX: This is really never going to happen just keep the code for safety and readbility.
* It never happens since interface_vlan_mtu_configured finds the biggest mtu on vlans.
* Also if it has a lower mtu configured just respect user choice.
*/
if (intval($config['interfaces'][$assignedport]['mtu']) > $mtu) {
legacy_interface_mtu($vlan['vlanif'], $mtu);
}
} else {
if (legacy_interface_stats($vlan['vlanif'])['mtu'] != $mtu) {
legacy_interface_mtu($vlan['vlanif'], $mtu);
}
}
} elseif (legacy_interface_stats($vlan['vlanif'])['mtu'] != $mtu) {
legacy_interface_mtu($vlan['vlanif'], $mtu);
}
}
}
function interface_configure($interface = 'wan', $reloadall = false, $linkupevent = false, $verbose = false) function interface_configure($interface = 'wan', $reloadall = false, $linkupevent = false, $verbose = false)
{ {
...@@ -2701,34 +2670,27 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -2701,34 +2670,27 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
break; break;
} }
} }
$intf_stats = legacy_interface_stats();
if (!empty($wancfg['mtu'])) { if (!empty($wancfg['mtu'])) {
if (stristr($realif, "_vlan")) { if (stristr($realif, "_vlan")) {
$assignedparent = convert_real_interface_to_friendly_interface_name($realhwif); // max mtu to parent
if (!empty($assignedparent) && !empty($config['interfaces'][$assignedparent]['mtu'])) { $mtu = $wancfg['mtu'] < $intf_stats[$realhwif]['mtu'] ? $wancfg['mtu'] : $intf_stats[$realhwif]['mtu'];
$parentmtu = $config['interfaces'][$assignedparent]['mtu']; if ($mtu != $intf_stats[$realif]['mtu']) {
} else { legacy_interface_mtu($realif, $mtu);
$parentmtu = interface_vlan_mtu_configured($realhwif, $wancfg['mtu']);
} }
} elseif ($wancfg['mtu'] != $intf_stats['mtu']) {
legacy_interface_mtu($realhwif, $wancfg['mtu']);
}
}
if ($wancfg['mtu'] > $parentmtu) { // in case this interface has vlan's configured, make sure none of them has an mtu set higher than it's parent
if (legacy_interface_stats($realhwif)['mtu'] != $wancfg['mtu']) { if (!empty($config['vlans']['vlan'])) {
legacy_interface_mtu($realhwif, $wancfg['mtu']); $intf_stats = legacy_interface_stats();
} foreach ($config['vlans']['vlan'] as $vlan) {
if ($realhwif == $vlan['if'] && $intf_stats[$realhwif]['mtu'] < $intf_stats[$vlan['vlanif']]['mtu']) {
/* All vlans need to use the same mtu value as their parent. */ legacy_interface_mtu($vlan['vlanif'], $intf_stats[$realhwif]['mtu']);
interface_vlan_adapt_mtu(link_interface_to_vlans($realhwif), $wancfg['mtu']);
} else {
legacy_interface_mtu($realif, $wancfg['mtu']);
}
} else {
if ($wancfg['mtu'] != legacy_interface_stats($realhwif)['mtu']) {
legacy_interface_mtu($realhwif, $wancfg['mtu']);
} }
/* This case is needed when the parent of vlans is being configured */
interface_vlan_adapt_mtu(link_interface_to_vlans($realif), $wancfg['mtu']);
} }
/* XXX: What about gre/gif/lagg/.. ? */
} }
if (does_interface_exist($wancfg['if'])) { if (does_interface_exist($wancfg['if'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment