Revision 669e1adb
Added by Bill Marquette about 20 years ago
etc/inc/interfaces.inc | ||
---|---|---|
35 | 35 |
require_once("functions.inc"); |
36 | 36 |
|
37 | 37 |
function interfaces_loopback_configure() { |
38 |
global $config, $g; |
|
39 |
|
|
40 | 38 |
mwexec("/sbin/ifconfig lo0 127.0.0.1"); |
41 | 39 |
|
42 | 40 |
return 0; |
43 | 41 |
} |
44 | 42 |
|
45 | 43 |
function interfaces_vlan_configure() { |
46 |
global $config, $g;
|
|
44 |
global $config; |
|
47 | 45 |
|
48 | 46 |
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { |
49 | 47 |
|
... | ... | |
211 | 209 |
|
212 | 210 |
/* OpenVPN configuration? */ |
213 | 211 |
if (isset($optcfg['ovpn'])) { |
214 |
if (strstr($if, "tap"))
|
|
212 |
if (strstr($optcfg['if'], "tap"))
|
|
215 | 213 |
ovpn_link_tap(); |
216 | 214 |
} |
217 | 215 |
|
... | ... | |
246 | 244 |
if ($g['booting']) { |
247 | 245 |
echo "Configuring CARP interfaces..."; |
248 | 246 |
mute_kernel_msgs(); |
249 |
}
|
|
247 |
} |
|
250 | 248 |
unlink_if_exists("/usr/local/etc/rc.d/carp.sh"); |
251 | 249 |
unlink_if_exists("/usr/local/pkg/pf/carp.sh"); |
252 | 250 |
unlink_if_exists("/usr/local/pkg/pf/carp_rules.sh"); |
... | ... | |
255 | 253 |
if($config['installedpackages']['carpsettings']['config'] != "") { |
256 | 254 |
foreach($config['installedpackages']['carpsettings']['config'] as $carp) |
257 | 255 |
if($carp['pfsyncenabled'] != "") { |
258 |
$pfsync = 1; |
|
259 |
if($carp['premption'] != "") |
|
260 |
mwexec("/sbin/sysctl net.inet.carp.preempt=1"); |
|
261 |
if($carp['balancing'] != "") |
|
262 |
mwexec("/sbin/sysctl net.inet.arpbalance=1"); |
|
263 |
$carp_sync_int = convert_friendly_interface_to_real_interface_name($carp['pfsyncinterface']); |
|
264 |
mwexec("/sbin/ifconfig pfsync0 create"); |
|
265 |
mwexec("/sbin/ifconfig pfsync0 syncdev " . $carp_sync_int); |
|
266 |
mwexec("/sbin/ifconfig pfsync0 syncif " . $carp_sync_int); |
|
267 |
mwexec("/sbin/ifconfig {$carp_sync_int} up"); |
|
268 |
mwexec("/sbin/ifconfig pfsync0 up"); |
|
269 |
if($g['booting']) { |
|
270 |
/* install rules to alllow pfsync to sync up during boot |
|
271 |
* carp interfaces will remain down until the bootup sequence finishes |
|
272 |
*/ |
|
273 |
exec("echo pass quick proto carp all keep state > /tmp/rules.boot"); |
|
274 |
exec("echo pass quick proto pfsync all >> /tmp/rules.boot"); |
|
275 |
exec("echo pass out proto { tcp, udp } from any to any port 53 keep state >> /tmp/rules.boot"); |
|
276 |
exec("/sbin/pfctl -f /tmp/rules.boot"); |
|
277 |
} |
|
278 |
$pfsync_instances_counter++; |
|
256 |
if($carp['premption'] != "") |
|
257 |
mwexec("/sbin/sysctl net.inet.carp.preempt=1"); |
|
258 |
if($carp['balancing'] != "") |
|
259 |
mwexec("/sbin/sysctl net.inet.arpbalance=1"); |
|
260 |
$carp_sync_int = convert_friendly_interface_to_real_interface_name($carp['pfsyncinterface']); |
|
261 |
mwexec("/sbin/ifconfig pfsync0 create"); |
|
262 |
mwexec("/sbin/ifconfig pfsync0 syncdev " . $carp_sync_int); |
|
263 |
mwexec("/sbin/ifconfig pfsync0 syncif " . $carp_sync_int); |
|
264 |
mwexec("/sbin/ifconfig {$carp_sync_int} up"); |
|
265 |
mwexec("/sbin/ifconfig pfsync0 up"); |
|
266 |
if($g['booting']) { |
|
267 |
/* install rules to alllow pfsync to sync up during boot |
|
268 |
* carp interfaces will remain down until the bootup sequence finishes |
|
269 |
*/ |
|
270 |
exec("echo pass quick proto carp all keep state > /tmp/rules.boot"); |
|
271 |
exec("echo pass quick proto pfsync all >> /tmp/rules.boot"); |
|
272 |
exec("echo pass out proto { tcp, udp } from any to any port 53 keep state >> /tmp/rules.boot"); |
|
273 |
exec("/sbin/pfctl -f /tmp/rules.boot"); |
|
274 |
} |
|
275 |
$pfsync_instances_counter++; |
|
279 | 276 |
} |
280 |
}
|
|
277 |
} |
|
281 | 278 |
if($config['installedpackages']['carp']['config'] != "") { |
282 | 279 |
foreach($config['installedpackages']['carp']['config'] as $carp) { |
283 |
/*
|
|
284 |
* create the carp interface
|
|
285 |
*/
|
|
286 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " create");
|
|
287 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " down");
|
|
288 |
$broadcast_address = gen_subnet_max($carp['ipaddress'], $carp['netmask']);
|
|
289 |
if($carp['password'] != "") {
|
|
290 |
$password = " pass " . $carp['password'];
|
|
291 |
}
|
|
292 |
$carpdev = "";
|
|
293 |
if($carp['interface'] <> "AUTO" and $carp['interface'] <> "") {
|
|
294 |
$ci = filter_opt_interface_to_real($carp['interface']); |
|
295 |
$carpdev = " carpdev {$ci} "; |
|
296 |
}
|
|
297 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " " . $carp['ipaddress'] . "/" . $carp['netmask'] . " broadcast " . $broadcast_address . " vhid " . $carp['vhid'] . "{$carpdev} advskew " . $carp['advskew'] . $password);
|
|
298 |
$carp_instances_counter++;
|
|
280 |
/*
|
|
281 |
* create the carp interface
|
|
282 |
*/
|
|
283 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " create");
|
|
284 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " down");
|
|
285 |
$broadcast_address = gen_subnet_max($carp['ipaddress'], $carp['netmask']);
|
|
286 |
if($carp['password'] != "") {
|
|
287 |
$password = " pass " . $carp['password'];
|
|
288 |
}
|
|
289 |
$carpdev = "";
|
|
290 |
if($carp['interface'] <> "AUTO" and $carp['interface'] <> "") {
|
|
291 |
$ci = filter_opt_interface_to_real($carp['interface']);
|
|
292 |
$carpdev = " carpdev {$ci} ";
|
|
293 |
}
|
|
294 |
mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " " . $carp['ipaddress'] . "/" . $carp['netmask'] . " broadcast " . $broadcast_address . " vhid " . $carp['vhid'] . "{$carpdev} advskew " . $carp['advskew'] . $password);
|
|
295 |
$carp_instances_counter++;
|
|
299 | 296 |
} |
300 | 297 |
} |
301 | 298 |
unmute_kernel_msgs(); |
302 | 299 |
if ($g['booting']) { |
303 | 300 |
unmute_kernel_msgs(); |
304 | 301 |
echo "done.\n"; |
305 |
}
|
|
302 |
} |
|
306 | 303 |
} |
307 | 304 |
|
308 | 305 |
function interfaces_carp_bringup() { |
309 |
global $g, $config;
|
|
306 |
global $g; |
|
310 | 307 |
/* lets bring the carp interfaces up now */ |
311 | 308 |
if ($g['booting']) |
312 | 309 |
sleep(5); |
313 | 310 |
$carp_ints = find_number_of_created_carp_interfaces(); |
314 | 311 |
for($x=0; $x<$carp_ints; $x++) |
315 |
mwexec("/sbin/ifconfig carp{$carp_instances_counter} up");
|
|
312 |
mwexec("/sbin/ifconfig carp{$x} up");
|
|
316 | 313 |
} |
317 | 314 |
|
318 | 315 |
function interfaces_wireless_configure($if, $wlcfg) { |
Also available in: Unified diff
Various code cleanups and a few actual bugfixes courtesy of Zend