Refactor ipfw loading.

This commit is contained in:
Ermal Luçi 2008-11-11 22:43:01 +00:00
parent 7922db8a40
commit e4b6b97aa2
2 changed files with 24 additions and 20 deletions

View File

@ -64,20 +64,7 @@ function captiveportal_configure() {
$cprules = captiveportal_rules_generate();
/* make sure ipfw is loaded */
mwexec("/sbin/kldload ipfw");
/*
* make sure ipfw is the first hook to make CP work correctly on
* Multi-WAN.
* Disable the ipfw outer hook it has not value to us.
*/
mwexec("/sbin/sysctl net.inet.ip.pfil.inbound=\"ipfw,pf\"");
/*
* TODO: Check if disabling ipfw hook
* does not break accounting.
*/
mwexec("/sbin/sysctl net.inet.ip.pfil.outbound=\"ipfw,pf\"");
filter_load_ipfw();
/* stop accounting on all clients */
captiveportal_radius_stop_all();

View File

@ -52,6 +52,28 @@ $used_pftpx_ports = array();
/* Used to hold the interface list that will be used on ruleset creation. */
$FilterIflist = array();
function filter_load_ipfw()
{
$status = intval(`kldstat | grep ipfw | grep -v "grep" | wc -l | awk '{ print $1 }'`);
if ($status == "0") {
mute_kernel_msgs();
mwexec("/sbin/kldload ipfw");
unmute_kernel_msgs();
/*
* make sure ipfw is the first hook to make CP and schedules work
* correctly on Multi-WAN.
*/
mwexec("/sbin/sysctl net.inet.ip.pfil.inbound=\"ipfw,pf\"");
/*
* TODO: Check if disabling ipfw hook
* does not break accounting on CP.
* XXX Not sure if we really do outbound filtering with ipfw!
*/
mwexec("/sbin/sysctl net.inet.ip.pfil.outbound=\"ipfw,pf\"");
}
}
function filter_pflog_start() {
global $config, $g;
@ -2468,12 +2490,7 @@ EOD;
* and if so load ipfw for later usage.
*/
if ($load_ipfw_module == true) {
$status = intval(`kldstat | grep ipfw | wc -l | awk '{ print $1 }'`);
if($status == "0") {
mute_kernel_msgs();
mwexec("/sbin/kldload ipfw");
unmute_kernel_msgs();
}
filter_load_ipfw();
exec("/sbin/ipfw delete set 9");
exec("/sbin/ipfw delete 2");
exec("/sbin/ipfw delete 3");