diff options
author | Ermal <eri@pfsense.org> | 2013-03-07 13:59:16 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2013-03-07 13:59:16 +0000 |
commit | 4ffa46bf9c79a4b60fa2601477d6d3563219a8ef (patch) | |
tree | 41dea2522638da2779692057b55dd22e9e045104 /etc | |
parent | 0d0d4a273dd6ab6ad49aa7920b576d6145de0d9f (diff) | |
download | pfsense-4ffa46bf9c79a4b60fa2601477d6d3563219a8ef.zip pfsense-4ffa46bf9c79a4b60fa2601477d6d3563219a8ef.tar.gz |
Correctly handle mtu changing between vlans
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index df602a5..fc32587 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -2700,6 +2700,25 @@ function find_dhcp6c_process($interface) { return intval($pid); } +function interface_vlan_mtu_configured($realhwif, $mtu) { + global $config; + + if (is_array($config['vlans']['vlan'])) { + foreach ($config['vlans']['vlan'] as $vlan) { + if ($vlan['if'] != $realhwif) + continue; + $assginedport = convert_real_interface_to_friendly_interface_name($vlan['vlanif']); + if (!empty($assginedport)) { + $portmtu = $config['interfaces'][$assginedport]['mtu']; + if (!empty($portmtu) && $portmtu > $mtu) + $mtu = $portmtu; + } + } + } + + return $mtu; +} + function interface_configure($interface = "wan", $reloadall = false, $linkupevent = false) { global $config, $g; global $interface_sn_arr_cache, $interface_ip_arr_cache; @@ -2917,18 +2936,50 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven $portmtu = $config['interfaces'][$assginedport]['mtu']; if (empty($portmtu)) pfSense_interface_mtu($vlan['vlanif'], $wancfg['mtu']); - } else if (get_interface_mtu($vlan['vlanif']) != $wancfg['mtu']) + } else if (get_interface_mtu($vlan['vlanif']) < $wancfg['mtu']) pfSense_interface_mtu($vlan['vlanif'], $wancfg['mtu']); } } } - } else if ($wancfg['mtu'] > get_interface_mtu($realhwif)) - pfSense_interface_mtu($realhwif, $wancfg['mtu']); + } else { + $bigmtu = interface_vlan_mtu_configured($realhwif, $wancfg['mtu']); + file_put_contents("/tmp/testing", $bigmtu); + if ($wancfg['mtu'] >= $bigmtu) { + /* All vlans need to use the same mtu value as their parent. */ + if (is_array($config['vlans']['vlan'])) { + foreach ($config['vlans']['vlan'] as $vlan) { + if ($vlan['if'] != $realhwif) + continue; + if ($vlan['vlanif'] == $realif) + continue; + pfSense_interface_mtu($vlan['vlanif'], $wancfg['mtu']); + } + } + pfSense_interface_mtu($realhwif, $wancfg['mtu']); + } + } } if ($wancfg['mtu'] != get_interface_mtu($realif)) pfSense_interface_mtu($realif, $wancfg['mtu']); - } else if ($mtu != get_interface_mtu($realhwif)) + } else if (stristr($realif, "vlan")) { /* XXX: This is really dangerous for example with vlans changing their parent mtu! */ + $bigmtu = interface_vlan_mtu_configured($realhwif, $mtu); + if ($mtu < $bigmtu) + $mtu = $bigmtu; + pfSense_interface_mtu($realhwif, $mtu); + + /* All vlans need to use the same mtu value as their parent. */ + if (is_array($config['vlans']['vlan'])) { + foreach ($config['vlans']['vlan'] as $vlan) { + if ($vlan['if'] != $realhwif) + continue; + if ($vlan['vlanif'] == $realif) + continue; + pfSense_interface_mtu($vlan['vlanif'], $mtu); + } + } + pfSense_interface_mtu($realif, $mtu); + } else if ($mtu != get_interface_mtu($realhwif)) pfSense_interface_mtu($realhwif, $mtu); if(does_interface_exist($wancfg['if'])) |