Project

General

Profile

Bug #2786 ยป fix_vlan_mtu.diff

Renato Botelho, 02/15/2013 07:52 AM

View differences:

etc/inc/interfaces.inc
2884 2884
			break;
2885 2885
	}
2886 2886

  
2887
	if (!empty($wancfg['mtu'])) {
2888
		pfSense_interface_mtu($realif, $wancfg['mtu']);
2889
	} else {
2890
		$mtu = get_interface_default_mtu(remove_numbers($realhwif));
2891
		if ($mtu != get_interface_mtu($realhwif))
2892
			pfSense_interface_mtu($realhwif, $mtu);
2887
	$mtu = get_interface_default_mtu(remove_numbers($realhwif));
2888

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

  
2901
	if ($mtu != get_interface_mtu($realhwif))
2902
		pfSense_interface_mtu($realhwif, $mtu);
2903

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

  
2895 2912
	if(does_interface_exist($wancfg['if']))
2896 2913
		interfaces_bring_up($wancfg['if']);
2897 2914

  
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'])
......
1384 1392
						<tr>
1385 1393
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1386 1394
							<td class="vtable">
1387
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1395
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>"
1396
									<?php if(!empty($parent_vlan_if)) print "disabled"; ?>>
1388 1397
								<br>
1389
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1390
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1398
								<?php
1399
									if (empty($parent_vlan_if))
1400
										print gettext("If you leave this field blank, the adapter's default MTU will " .
1401
										"be used. This is typically 1500 bytes but can vary in some circumstances.");
1402
									else
1403
										print gettext("This interface is a VLAN and it needs to use same MTU set for " .
1404
										"its parent. You can change parent's MTU") . "<a href=\"interfaces.php?if={$parent_vlan_if}\"> " .
1405
										gettext("here") . ".</a>";
1406
								?>
1391 1407
							</td>
1392 1408
						</tr>
1393 1409
						<tr>
    (1-1/1)