Project

General

Profile

« Previous | Next » 

Revision 4a735210

Added by Renato Botelho over 12 years ago

Make parent interface and all VLANs use the same MTU. Fixes #2786

View differences:

etc/inc/interfaces.inc
2888 2888
			break;
2889 2889
	}
2890 2890

  
2891
	if (!empty($wancfg['mtu'])) {
2892
		pfSense_interface_mtu($realif, $wancfg['mtu']);
2893
	} else {
2894
		$mtu = get_interface_default_mtu(remove_ifindex($realhwif));
2895
		if ($mtu != get_interface_mtu($realhwif))
2896
			pfSense_interface_mtu($realhwif, $mtu);
2891
	$mtu = get_interface_default_mtu(remove_ifindex($realhwif));
2892

  
2893
	if (preg_match('/_vlan[0-9]/', $wancfg['if'])) {
2894
		foreach ($config['interfaces'] as $ifdescr => $ifdata) {
2895
			if ($ifdata['if'] == $realhwif) {
2896
				if (!empty($ifdata['mtu']))
2897
					$mtu = $ifdata['mtu'];
2898
				break;
2899
			}
2900
		}
2901
	} else if (!empty($wancfg['mtu'])) {
2902
		$mtu = $wancfg['mtu'];
2897 2903
	}
2898 2904

  
2905
	if ($mtu != get_interface_mtu($realhwif))
2906
		pfSense_interface_mtu($realhwif, $mtu);
2907

  
2908
	/*
2909
	 * All vlans need to use the same mtu value as their parent.
2910
	 */
2911
	if (is_array($config['vlans']['vlan']))
2912
		foreach ($config['vlans']['vlan'] as $vlan)
2913
			if (($vlan['if'] == $realhwif) && (get_interface_mtu($vlan['vlanif']) != $mtu))
2914
				pfSense_interface_mtu($vlan['vlanif'], $mtu);
2915

  
2899 2916
	if(does_interface_exist($wancfg['if']))
2900 2917
		interfaces_bring_up($wancfg['if']);
2901 2918

  
usr/local/www/interfaces.php
92 92
else if ($if == "lan" && !$wancfg['descr'])
93 93
	$wancfg['descr'] = "LAN";
94 94

  
95
$parent_vlan_if = "";
96
if (preg_match('/_vlan[0-9]/', $wancfg['if'])) {
97
	$realhwif_array = get_parent_interface($wancfg['if']);
98
	// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
99
	$realhwif = $realhwif_array[0];
100
	$parent_vlan_if = convert_real_interface_to_friendly_interface_name($realhwif);
101
	$wancfg['mtu'] = '';
102
}
95 103

  
96 104
foreach ($a_ppps as $pppid => $ppp) {
97 105
	if ($wancfg['if'] == $ppp['if'])
......
1414 1422
						<tr>
1415 1423
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1416 1424
							<td class="vtable">
1417
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1425
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>"
1426
									<?php if(!empty($parent_vlan_if)) print "disabled"; ?>>
1418 1427
								<br>
1419
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1420
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1428
								<?php
1429
									if (empty($parent_vlan_if))
1430
										print gettext("If you leave this field blank, the adapter's default MTU will " .
1431
										"be used. This is typically 1500 bytes but can vary in some circumstances.");
1432
									else
1433
										print gettext("This interface is a VLAN and it needs to use same MTU set for " .
1434
										"its parent. You can change parent's MTU") . "<a href=\"interfaces.php?if={$parent_vlan_if}\"> " .
1435
										gettext("here") . ".</a>";
1436
								?>
1421 1437
							</td>
1422 1438
						</tr>
1423 1439
						<tr>

Also available in: Unified diff