Project

General

Profile

« Previous | Next » 

Revision 3f183d4e

Added by Angelo Turetta over 16 years ago

Fix VLAN creation. Previous patch simply removed some code, now the code is derived from what is in RELENG_1, omitting the list of supported drivers that apparently is no more needed.

View differences:

etc/inc/interfaces.inc
46 46
}
47 47

  
48 48
function interfaces_vlan_configure() {
49
	global $config, $g;
49
	global $config;
50 50

  
51
	$i = 0;
51 52
	if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
52

  
53
		/* devices with native VLAN support */
54
		$vlan_native_supp = $g['vlan_native_supp'];
55

  
56
		/* devices with long frame support */
57
		$vlan_long_frame = $g['vlan_long_frame'];
58

  
59
		/* sweep through and axe old interfaces */
60
		$vlan_count = get_number_of_vlan_interfaces();
61
		for($x=0; $x<$vlan_count; $x++)
62
			exec("/sbin/ifconfig vlan{$x} down delete");
63

  
64
		$i = 0;
65

  
66 53
		foreach ($config['vlans']['vlan'] as $vlan) {
67

  
68
			$cmd = "/sbin/ifconfig vlan{$i} create vlan " .
69
				escapeshellarg($vlan['tag']) . " vlandev " .
70
				escapeshellarg($vlan['if']);
71

  
72
			/* get driver name */
73
			for ($j = 0; $j < strlen($vlan['if']); $j++) {
74
				if ($vlan['if'][$j] >= '0' && $vlan['if'][$j] <= '9')
75
					break;
54
			if(empty($vlan['vlanif'])) {
55
				$vlan['vlanif'] = "vlan{$i}";
76 56
			}
77
			$drvname = substr($vlan['if'], 0, $j);
78

  
79
			/* Apparently, FreeBSD7 DoesTheRightThing without much help
80
			   'link0' is no more mentioned in vlan section of 'man ifconfig',
81
			   (it returns error on sis(4)) and 'mtu' also seems redundant
82
			   XXXX: this code may be removed once my findings are validated
83
			if (in_array($drvname, $vlan_native_supp))
84
				$cmd .= " link0";
85
			else if (in_array($drvname, $vlan_long_frame))
86
				$cmd .= " mtu 1500";
87
			*/
57
			/* XXX: Maybe we should report any errors?! */
58
			interface_vlan_configure($vlan['if'], $vlan['tag'], $vlan['vlanif']);
59
			$i++;
60
		}
61
		//Leaving it here as it was in original 1.2 code, I don't know if it's needed. aturetta.
62
		/* CARP interfaces can be attached to VLAN's, too. */
63
		interfaces_carp_bring_up_final();
64
	}
65
}
88 66

  
89
			mwexec($cmd);
67
function interface_vlan_configure($if, $tag, $vlanif = "") {
68
	global $config, $g;
90 69

  
91
			/* invalidate interface cache */
92
			get_interface_arr(true);
70
	/* make sure the parent interface is up and enable hw vlan support if available*/
71
	mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up vlanhwtag vlanmtu");
93 72

  
94
			/*   all vlans need to spoof their parent mac address, too.  see
95
			 *   ticket #1514: http://cvstrac.pfsense.com/tktview?tn=1514,33 
96
			 */
97
			foreach($config['interfaces'] as $interfaces) {
98
				if($interfaces['if'] == $vlan['if']) {
99
					if($interfaces['spoofmac']) {
100
						mwexec("/sbin/ifconfig " . escapeshellarg($interfaces['if']) .
101
							" link " . escapeshellarg($interfaces['spoofmac']));
102
					}
103
				}
104
			}
73
	if ($g['booting'] || !(empty($vlanif))) {
74
		mwexec("/sbin/ifconfig {$vlanif} destroy");
75
		mwexec("/sbin/ifconfig {$vlanif} create");
76
	} else 
77
		$vlanif = exec("/sbin/ifconfig vlan create");
78
	
79
	mwexec("/sbin/ifconfig {$vlanif} vlan " .
80
		escapeshellarg($tag) . " vlandev " .
81
		escapeshellarg($if));
105 82

  
106
			/* make sure the parent interface is up */
107
			mwexec("/sbin/ifconfig " . escapeshellarg($vlan['if']) . " up");
83
	mwexec("/sbin/ifconfig {$vlanif} up");
108 84

  
109
			$i++;
85
	/* invalidate interface cache */
86
	get_interface_arr(true);
87

  
88
	/*   all vlans need to spoof their parent mac address, too.  see
89
	 *   ticket #1514: http://cvstrac.pfsense.com/tktview?tn=1514,33
90
	 */
91
	foreach($config['interfaces'] as $interfaces) {
92
		if($interfaces['if'] == $if && $interfaces['spoofmac']) {
93
			mwexec("/sbin/ifconfig " . escapeshellarg($if) .
94
				" link " . escapeshellarg($interfaces['spoofmac']));
110 95
		}
111 96
	}
112 97

  
113
	/* CARP interfaces can be attached to VLAN's, too. */
114
	interfaces_carp_bring_up_final();
115

  
116
	return 0;
98
	return $vlanif;
117 99
}
118 100

  
119 101
function interfaces_lan_configure() {

Also available in: Unified diff