From 562fca6d5692fc1f4343b2f2a8326b72a35065cb Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 7 Nov 2005 03:27:23 +0000 Subject: Do not require a reboot to setup polling. --- etc/inc/pfsense-utils.inc | 73 ++++++++++++++++++++++++++++++--------- etc/rc.bootup | 3 ++ usr/local/www/system_advanced.php | 7 ++-- 3 files changed, 64 insertions(+), 19 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index ffdc3bf..dbbeedf 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -127,25 +127,12 @@ function enable_hardware_offloading($interface) { /* translate wan, lan, opt -> real interface if needed */ $int = filter_translate_type_to_real_interface($interface); if($int <> "") $interface = $int; - if(isset($config['system']['polling'])) { - /* activate polling for interface if it supports it - * man polling on a freebsd box for the following list - */ - $supported_ints = array('dc', 'em', 'fwe', 'fwip', 'fxp', 'ixgb', 'ste', - 'nge', 're', 'rl', 'sf', 'sis', 'ste', 'vge', 'vr', 'xl', 'fxp'); - foreach($supported_ints as $int) { - if(stristr($interface,$int) != false) { - mwexec("/sbin/ifconfig {$interface} polling"); - } - } - } + $int_family = preg_split("/[0-9]+/", $int); $options = strtolower(`/sbin/ifconfig {$interface} | grep options`); $supported_ints = array('fxp'); - foreach($supported_ints as $int) { - if(stristr($interface,$int) != false) { - mwexec("/sbin/ifconfig {$interface} link0"); - } - } + if (in_array($int_family, $supported_ints)) + mwexec("/sbin/ifconfig {$interface} link0"); + if(stristr($options, "txcsum") == true) mwexec("/sbin/ifconfig {$interface} txcsum 2>/dev/null"); if(stristr($options, "rxcsum") == true) @@ -156,6 +143,58 @@ function enable_hardware_offloading($interface) { return; } +/****f* pfsense-utils/setup_polling_defaults + * NAME + * sets up sysctls for pollingS + * INPUTS + * + * RESULT + * null + * NOTES + * + ******/ +function setup_polling_defaults() { + global $g, $config; + if($config['system']['polling_each_burst']) + mwexec("sysctl kern.polling.each_burst={$config['system']['polling_each_burst']}"); + if($config['system']['polling_burst_max']) + mwexec("sysctl kern.polling.burst_max={$config['system']['polling_burst_max']}"); + if($config['system']['polling_user_frac']) + mwexec("sysctl kern.polling.user_frac={$config['system']['polling_user_frac']}"); +} + +/****f* pfsense-utils/setup_polling + * NAME + * sets up polling + * INPUTS + * + * RESULT + * null + * NOTES + * + ******/ +function setup_polling() { + setup_polling_defaults(); + global $g, $config; + /* build an array of interfaces to work with */ + $iflist = array("lan" => "LAN", "wan" => "WAN"); + for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) + $iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr']; + /* activate polling for interface if it supports it + * man polling on a freebsd box for the following list + */ + /* loop through all interfaces and handle pftpx redirections */ + foreach ($iflist as $ifent => $ifname) { + $supported_ints = array('dc', 'em', 'fwe', 'fwip', 'fxp', 'ixgb', 'ste', + 'nge', 're', 'rl', 'sf', 'sis', 'ste', 'vge', 'vr', 'xl'); + if (in_array($int_family, $supported_ints) and isset($config['system']['polling'])) { + mwexec("/sbin/ifconfig {$interface} polling"); + } else { + mwexec("/sbin/ifconfig {$interface} -polling"); + } + } +} + /****f* pfsense-utils/setup_microcode * NAME * enumerates all interfaces and calls enable_hardware_offloading which diff --git a/etc/rc.bootup b/etc/rc.bootup index b71c6f9..13934e1 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -229,6 +229,9 @@ /* run any shell commands specified in config.xml */ system_do_shell_commands(); + /* setup polling */ + setup_polling(); + /* start ftp proxy helpers if they are enabled */ echo "Starting FTP helpers... "; system_start_ftp_helpers(); diff --git a/usr/local/www/system_advanced.php b/usr/local/www/system_advanced.php index 03a1ade..86b3826 100755 --- a/usr/local/www/system_advanced.php +++ b/usr/local/www/system_advanced.php @@ -116,10 +116,13 @@ if ($_POST) { $oldsshport = $config['system']['ssh']['port']; $config['system']['ssh']['port'] = $_POST['sshport']; - if($_POST['polling_enable'] == "yes") + if($_POST['polling_enable'] == "yes") { $config['system']['polling'] = true; - else + setup_polling(); + } else { unset($config['system']['polling']); + setup_polling(); + } if($_POST['sharednet'] == "yes") { $config['system']['sharednet'] = true; -- cgit v1.1