mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-18 10:35:27 +00:00
interfaces.inc, fix mtu setup for vlans, for https://github.com/opnsense/core/issues/1709
This commit is contained in:
parent
8236ddcc5f
commit
5525a08adb
@ -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)
|
||||
{
|
||||
@ -2701,34 +2670,27 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
|
||||
break;
|
||||
}
|
||||
}
|
||||
$intf_stats = legacy_interface_stats();
|
||||
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'];
|
||||
} else {
|
||||
$parentmtu = interface_vlan_mtu_configured($realhwif, $wancfg['mtu']);
|
||||
// max mtu to parent
|
||||
$mtu = $wancfg['mtu'] < $intf_stats[$realhwif]['mtu'] ? $wancfg['mtu'] : $intf_stats[$realhwif]['mtu'];
|
||||
if ($mtu != $intf_stats[$realif]['mtu']) {
|
||||
legacy_interface_mtu($realif, $mtu);
|
||||
}
|
||||
} elseif ($wancfg['mtu'] != $intf_stats['mtu']) {
|
||||
legacy_interface_mtu($realhwif, $wancfg['mtu']);
|
||||
}
|
||||
}
|
||||
|
||||
// in case this interface has vlan's configured, make sure none of them has an mtu set higher than it's parent
|
||||
if (!empty($config['vlans']['vlan'])) {
|
||||
$intf_stats = legacy_interface_stats();
|
||||
foreach ($config['vlans']['vlan'] as $vlan) {
|
||||
if ($realhwif == $vlan['if'] && $intf_stats[$realhwif]['mtu'] < $intf_stats[$vlan['vlanif']]['mtu']) {
|
||||
legacy_interface_mtu($vlan['vlanif'], $intf_stats[$realhwif]['mtu']);
|
||||
}
|
||||
|
||||
if ($wancfg['mtu'] > $parentmtu) {
|
||||
if (legacy_interface_stats($realhwif)['mtu'] != $wancfg['mtu']) {
|
||||
legacy_interface_mtu($realhwif, $wancfg['mtu']);
|
||||
}
|
||||
|
||||
/* All vlans need to use the same mtu value as their parent. */
|
||||
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'])) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user