summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-04-02 01:35:51 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-04-02 01:35:51 +0000
commit2defff77511852b3fc506715a357014012b1441c (patch)
treeee57480acd7ae20b622cc15b8de9a44173660cf3
parentf19dba118fda9c6640f6032297e4f2eaee9fc386 (diff)
downloadpfsense-2defff77511852b3fc506715a357014012b1441c.zip
pfsense-2defff77511852b3fc506715a357014012b1441c.tar.gz
* Add new filter loading status page used after traffic shaper load screen
* Fix p2p queues
-rw-r--r--etc/inc/filter.inc15
-rw-r--r--etc/inc/pfsense-utils.inc9
-rw-r--r--usr/local/www/status_filter_reload.php145
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard.xml63
4 files changed, 219 insertions, 13 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 640e55f..b75823c 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -70,6 +70,7 @@ function filter_configure() {
/* reload filter sync */
function filter_configure_sync() {
global $config, $g, $after_filter_configure_run;
+ update_filter_reload_status("Initializing");
if(isset($config['system']['developerspew'])) {
$mt = microtime();
echo "filter_configure_sync() being called $mt\n";
@@ -81,20 +82,25 @@ function filter_configure_sync() {
/* generate aliases */
if($g['booting'] == true) echo " aliases ";
+ update_filter_reload_status("Creating aliases");
$aliases = filter_generate_aliases();
/* generate nat rules */
if($g['booting'] == true) echo " rules ";
+ update_filter_reload_status("Generating NAT rules");
$natrules = filter_nat_rules_generate();
/* generate pfctl rules */
if($g['booting'] == true) echo " filtering ";
+ update_filter_reload_status("Generating filter rules");
$pfrules = filter_rules_generate();
if(isset($config['shaper']['enable'])) {
/* generate altq interface setup parms */
if($g['booting'] == true) echo " altq-interfaces ";
+ update_filter_reload_status("Generating ALTQ interfaces");
$altq_ints = filter_setup_altq_interfaces();
/* generate altq queues */
if($g['booting'] == true) echo " altq-queues ";
+ update_filter_reload_status("Generating ALTQ queues");
$altq_queues = filter_generate_altq_queues($altq_ints);
/* generate altq rules */
if($g['booting'] == true) echo " altq-rules ";
@@ -103,9 +109,12 @@ function filter_configure_sync() {
* this allows the shaper to be first match
*/
$pf_altq_rules = "block in all tag unshaped label \"SHAPER: first match rule\"\n";
+ update_filter_reload_status("Generating ALTQ rules");
$pf_altq_rules .= filter_generate_pf_altq_rules();
}
+ update_filter_reload_status("Loading filter rules");
+
/* enable pf if we need to, otherwise disable */
if( !isset( $config['system']['disablefilter'] ) ) {
mwexec("/sbin/pfctl -e");
@@ -185,6 +194,7 @@ function filter_configure_sync() {
$line_error = "The line in question reads [{$line_number}]: {$line_split[$line_number-1]}";
file_notice("filter_load", "There were error(s) loading the rules: {$rules_error} {$line_error}", "Filter Reload", "");
log_error("There were error(s) loading the rules: {$rules_error} - {$line_error}");
+ update_filter_reload_status("There were error(s) loading the rules: {$rules_error} - {$line_error}");
return;
}
@@ -213,6 +223,8 @@ function filter_configure_sync() {
}
}
+ update_filter_reload_status("Syncing CARP data");
+
/* sync carp entries to other firewalls */
carp_sync_client();
@@ -229,6 +241,8 @@ function filter_configure_sync() {
foreach($after_filter_configure_run as $afcr) {
mwexec($afcr);
}
+
+ update_filter_reload_status("Done");
return 0;
}
@@ -2361,4 +2375,5 @@ function return_vpn_subnet($adr) {
return " # error - {$adr['network']} ";
}
+
?> \ No newline at end of file
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 658f570..5faa905 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -2033,4 +2033,13 @@ function kill_traffic_collector() {
mwexec("ps awwwux | grep '/[u]pdaterrd.sh' | awk '{print $2}' | xargs kill");
}
+function update_filter_reload_status($text) {
+ global $g;
+ config_lock();
+ $fd = fopen("{$g['varrun_path']}/filter_reload_status", "w");
+ fwrite($fd, $text);
+ fclose($fd);
+ config_unlock();
+}
+
?> \ No newline at end of file
diff --git a/usr/local/www/status_filter_reload.php b/usr/local/www/status_filter_reload.php
new file mode 100644
index 0000000..53a2cf9
--- /dev/null
+++ b/usr/local/www/status_filter_reload.php
@@ -0,0 +1,145 @@
+<?php
+/* $Id$ */
+/*
+ status_filter_reload.php
+ Copyright (C) 2006 Scott Ullrich
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once("guiconfig.inc");
+require_once("functions.inc");
+
+$pgtitle = "Diagnostics: Filter Reload Status";
+
+include("head.inc");
+
+if(file_exists("{$g['varrun_path']}/filter_reload_status"))
+ $status = file_get_contents("{$g['varrun_path']}/filter_reload_status");
+
+if($_GET['getstatus']) {
+ echo "|{$status}|";
+ exit;
+}
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
+<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+
+<?php include("fbegin.inc"); ?>
+
+<p><span class="pgtitle"><?=$pgtitle;?></span></p>
+
+<div id="loadingicon" name="loadingicon">
+ <img src="/themes/metallic/images/misc/loader.gif">
+ <p/>
+</div>
+
+<div id="status" name="status" style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000;">
+ <?php echo $status; ?>
+</div>
+
+<div id="doneurl" name="doneurl">
+</div>
+
+<?php include("fend.inc"); ?>
+
+<script language="javascript">
+/* init update "thread */
+$('loadingicon').style.visibility="visible";
+function update_status_thread() {
+ $('loadingicon').style.visibility="visible";
+ getURL('status_filter_reload.php?getstatus=true', update_data);
+}
+function update_data(obj) {
+ var result_text = obj.content;
+ var result_text_split = result_text.split("|");
+ result_text = result_text_split[1];
+ result_text = result_text.replace("\n","");
+ result_text = result_text.replace("\r","");
+ if (result_text) {
+ $('status').innerHTML = result_text + '...';
+ } else {
+ $('status').innerHTML = 'Obtaining filter status...';
+ }
+ if(result_text == "Done") {
+ $('status').innerHTML = 'Done.';
+ $('loadingicon').style.visibility="hidden";
+ $('doneurl').style.visibility="visible";
+ $('doneurl').innerHTML = "<p/><a href='status_queues.php'>Queue Status</a>";
+ }
+ window.setTimeout('update_status_thread()', 2500);
+}
+</script>
+
+<script language="javascript">
+/**
+ * getURL is a proprietary Adobe function, but it's simplicity has made it very
+ * popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest.
+ */
+if (typeof getURL == 'undefined') {
+ getURL = function(url, callback) {
+ if (!url)
+ throw 'No URL for getURL';
+
+ try {
+ if (typeof callback.operationComplete == 'function')
+ callback = callback.operationComplete;
+ } catch (e) {}
+ if (typeof callback != 'function')
+ throw 'No callback function for getURL';
+
+ var http_request = null;
+ if (typeof XMLHttpRequest != 'undefined') {
+ http_request = new XMLHttpRequest();
+ }
+ else if (typeof ActiveXObject != 'undefined') {
+ try {
+ http_request = new ActiveXObject('Msxml2.XMLHTTP');
+ } catch (e) {
+ try {
+ http_request = new ActiveXObject('Microsoft.XMLHTTP');
+ } catch (e) {}
+ }
+ }
+ if (!http_request)
+ throw 'Both getURL and XMLHttpRequest are undefined';
+
+ http_request.onreadystatechange = function() {
+ if (http_request.readyState == 4) {
+ callback( { success : true,
+ content : http_request.responseText,
+ contentType : http_request.getResponseHeader("Content-Type") } );
+ }
+ }
+ http_request.open('GET', url, true);
+ http_request.send(null);
+ }
+}
+window.setTimeout('update_status_thread()', 2500);
+</script>
+
+</body>
+</html>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard.xml b/usr/local/www/wizards/traffic_shaper_wizard.xml
index f7355f6..97b4b07 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard.xml
@@ -1982,15 +1982,6 @@
/* XXX: add some more protocols here! */
-
- /* install default p2p catch all rule if user has enabled option (MUST BE LAST!) */
- if($config['ezshaper']['step4']['p2pcatchall'] == "on") {
- $othersplist[] = array('p2pCatchAll', 'tcp', '', '', 'both', 'p2p');
- $othersplist[] = array('p2pCatchAll2','tcp', '', '', 'both', 'p2p');
- $othersplist[] = array('p2pCatchAll', 'udp', '', '', 'both', 'p2p');
- $othersplist[] = array('p2pCatchAll2','udp', '', '', 'both', 'p2p');
- }
-
/* Set up/down protocols as higher weight */
/* loop through othersplist[] */
@@ -2027,9 +2018,53 @@
$config['shaper']['rule'][] = $rule;
}
}
- }
+ /* install default p2p catch all rule if user has enabled option (MUST BE LAST!) */
+ if($config['ezshaper']['step4']['p2pcatchall'] == "on") {
+ $othersplist = array();
+ $othersplist[] = array('p2pCatchAll', 'tcp', '', '', 'both', 'L');
+ $othersplist[] = array('p2pCatchAll2', 'udp', '', '', 'both', 'L');
+ } else {
+ $othersplist = array();
+ }
+
+ /* Set up/down protocols as p2p weight */
+ /* loop through othersplist[] */
+ foreach ($othersplist as $otherclient) {
+ foreach (array('source', 'destination') as $srcdest) {
+ $rule = array();
+ $config['shaper']['itemsshaped']++;
+ if ($srcdest == 'source') {
+ $destsrc = 'destination';
+ $rule['inqueue'] = 'qP2PDown' . $otherclient[5]; /* posted value H or L */
+ $rule['outqueue'] = 'qP2PUp' . $otherclient[5]; /* posted value H or L */
+ $rule['in-interface'] = $downint;
+ $rule['out-interface'] = $upint;
+ $rule['source']['network'] = $downint;
+ $rule['destination']['any'] = TRUE;
+ $rule['descr'] = "p2pCatchAll outbound";
+ } else {
+ $destsrc = 'source';
+ $rule['inqueue'] = 'qP2PUp' . $otherclient[5]; /* posted value H or L */
+ $rule['outqueue'] = 'qP2PDown' . $otherclient[5]; /* posted value H or L */
+ $rule['in-interface'] = $upint;
+ $rule['out-interface'] = $downint;
+ $rule['source']['any'] = TRUE;
+ $rule['destination']['network'] = $downint;
+ $rule['descr'] = "p2pCatchAll inbound";
+ }
+
+ if($otherclient[2] or $otherclient[3]) {
+ $rule['destination']['port'] = $otherclient[2]."-".$otherclient[3];
+ if($otherclient[1] != '')
+ $rule['protocol'] = $otherclient[1];
+ }
+
+ $config['shaper']['rule'][] = $rule;
+ }
+ }
+ }
</stepsubmitphpaction>
</step>
<step>
@@ -2077,13 +2112,15 @@
unset($config['shaper']['itemsshaped']);
/* Create new rules */
- filter_configure_sync();
+ filter_configure();
/* And we're no longer dirty! */
unlink_if_exists($d_shaperconfdirty_path);
+ update_filter_reload_status("Initializing");
+
/* Head over and check out the groovy queue stats */
- header("Location: /status_queues.php");
+ header("Location: status_filter_reload.php");
</stepsubmitphpaction>
</step>
<step>
@@ -2096,7 +2133,7 @@
</field>
</fields>
<stepsubmitphpaction>
- header("Location: /");
+ header("Location: status_filter_reload.php");
</stepsubmitphpaction>
</step>
</pfsensewizard>
OpenPOWER on IntegriCloud