summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-06-04 19:39:20 +0000
committerBill Marquette <billm@pfsense.org>2005-06-04 19:39:20 +0000
commit79a6c437be0199fdb63e927c7486921732c74f2a (patch)
treee7a51b6eeee10cc3238e1f7fa714a773ed0941d1
parent074d5eb4a747cb9837381b4b2d683f1ac2db87ac (diff)
downloadpfsense-79a6c437be0199fdb63e927c7486921732c74f2a.zip
pfsense-79a6c437be0199fdb63e927c7486921732c74f2a.tar.gz
More shaper work
-rw-r--r--etc/inc/filter.inc27
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard.xml240
2 files changed, 259 insertions, 8 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 3652d9c..0401d2d 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -184,6 +184,19 @@ function filter_get_rule_interface($associatedrulenumber) {
return $config['shaper']['rule'][$associatedrulenumber]['interface'];
}
+function find_default_queue() {
+ global $config;
+ $qconfig = $config;
+
+ if (is_array($qconfig['shaper']['queue'])) {
+ foreach ($qconfig['shaper']['queue'] as $rule) {
+ if(isset($rule['defaultqueue']) and $rule['defaultqueue'] <> "")
+ return $rule['name'];
+ }
+ }
+}
+
+
function filter_generate_altq_queues($altq_ints) {
global $config;
$altq_rules = "";
@@ -1683,13 +1696,13 @@ EOD;
* and setup for all netgraph interfaces
*/
$line = generate_user_filter_rule($rule, $xxx);
- $line .= " queue {$queue['name']} ";
+ $line .= " queue ({$queue['name']}, acks) ";
if($line <> "")
$ipfrules .= $line . "\n";
}
} else {
$line = generate_user_filter_rule($rule, 0);
- $line .= " queue {$queue['name']} ";
+ $line .= " queue ({$queue['name']}, acks) ";
// label
if($rule['descr'] <> "" and $line <> "")
$line .= " label \"USER_RULE: " . $rule['descr'] . "\" ";
@@ -1716,11 +1729,17 @@ EOD;
* and setup for all netgraph interfaces
*/
$line = generate_user_filter_rule($rule, $xxx);
- if($line <> "")
+ if($line <> "") {
+ if (isset($config['shaper']['enable']) && is_array($config['shaper']['queue']))
+ $line .= " queue (" . find_default_queue() . ", acks) ";
$ipfrules .= $line . "\n";
+ }
}
} else {
$line = generate_user_filter_rule($rule, 0);
+ if($line <> "")
+ if (isset($config['shaper']['enable']) && is_array($config['shaper']['queue']))
+ $line .= " queue (" . find_default_queue() . ", acks) ";
// label
if($rule['descr'] <> "" and $line <> "")
$line .= " label \"USER_RULE: " . $rule['descr'] . "\" ";
@@ -1909,4 +1928,4 @@ function process_carp_rules() {
return $lines;
}
-?> \ No newline at end of file
+?>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard.xml b/usr/local/www/wizards/traffic_shaper_wizard.xml
index cc8a1fd..94e9e31 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard.xml
@@ -78,7 +78,143 @@
</field>
</fields>
<stepsubmitphpaction>
-/* XXX create top level queues here */
+ /* Magic shaper uses HFSC */
+ $config['system']['schedulertype'] = "hfsc";
+
+ /* Create queues */
+ /* WAN queues */
+ $queue = array();
+ $queue['name'] = "qWANRoot";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 6;
+ $queue['parentqueue'] = "on";
+/*
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = (int)$_POST['upload'] * 0.7 . "Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = (int)$_POST['upload'] * 0.7 . "Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = (int)$_POST['upload'] * 0.8 . "Kb";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = (int)$_POST['upload'] * 0.8 . "Kb";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = (int)$_POST['upload'] * 0.8 . "Kb";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = (int)$_POST['upload'] * 0.8 . "Kb";
+*/
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
+ $queue = array();
+ $queue['name'] = "qWANdef";
+ $queue['attachtoqueue'] = "qWANRoot";
+ $queue['associatedrule'] = 0;
+ $queue['defaultqueue'] = 'true';
+ $queue['priority'] = 3;
+/*
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "10%";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "10%";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "1%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "1%";
+*/
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
+ /* LAN queue */
+ $queue = array();
+ $queue['name'] = "qLANRoot";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 6;
+ $queue['parentqueue'] = "on";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = (int) $_POST['download'] * 0.7 . "Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = (int) $_POST['download'] * 0.7 . "Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = (int) $_POST['download'] * 0.8 . "Kb";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = (int) $_POST['download'] * 0.8 . "Kb";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = (int)$_POST['upload'] * 0.8 . "Kb";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = (int)$_POST['upload'] * 0.8 . "Kb";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
+ $queue = array();
+ $queue['name'] = "qLANdef";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 3;
+ $queue['attachtoqueue'] = "qLANRoot";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "10%";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "10%";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "1%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "1%";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
+ $queue = array();
+ $queue['name'] = "qLANacks";
+ $queue['attachtoqueue'] = "qLANRoot";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 7;
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "10%";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "10%";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "1%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "1%";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
+ $queue = array();
+ $queue['name'] = "qWANacks";
+ $queue['attachtoqueue'] = "qWANRoot";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 7;
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "10%";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "10%";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "1%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "1%";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $config['shaper']['queue'][] = $queue;
+
/* XXX create default rules here */
</stepsubmitphpaction>
</step>
@@ -141,8 +277,74 @@
</field>
</fields>
<stepsubmitphpaction>
-/* XXX create VOIP queues here */
-/* XXX create VOIP rules here */
+ /* create qVOIPUp */
+ $queue = array();
+ $queue['name'] = "qVOIPUp";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 7;
+ $queue['red'] = "on";
+ $queue['ecn'] = "on";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = $_POST['bandwidth'] . "Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = $_POST['bandwidth'] . "Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = $_POST['bandwidth'] . "Kb";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = $_POST['bandwidth'] . "Kb";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = $_POST['bandwidth'] . "Kb";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = $_POST['bandwidth'] . "Kb";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $queue['attachtoqueue'] = "qLANRoot";
+ $config['shaper']['queue'][] = $queue;
+
+ /* create qVOIPDown */
+ $queue = array();
+ $queue['name'] = "qVOIPDown";
+ $queue['associatedrule'] = 0;
+ $queue['priority'] = 7;
+ $queue['red'] = "on";
+ $queue['ecn'] = "on";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = $_POST['bandwidth'] . "Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = $_POST['bandwidth'] . "Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = $_POST['bandwidth'] . "Kb";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = $_POST['bandwidth'] . "Kb";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = $_POST['bandwidth'] . "Kb";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = $_POST['bandwidth'] . "Kb";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $queue['attachtoqueue'] = "qLANRoot";
+ $config['shaper']['queue'][] = $queue;
+
+ /* create VOIP rules */
+ $rule = array();
+ $rule['descr'] = "DiffServ/Lowdelay/Upload";
+ $rule['inqueue'] = "qVOIPDown";
+ $rule['outqueue'] = "qVOIPUp";
+ $rule['interface'] = "wan";
+ $rule['source']['network'] = 'lan';
+ $rule['destination']['any'] = TRUE;
+ $rule['iptos'] = "lowdelay";
+ $config['shaper']['rule'][] = $rule;
+
+ $rule = array();
+ $rule['descr'] = "DiffServ/Lowdelay/Download";
+ $rule['inqueue'] = "qVOIPUp";
+ $rule['outqueue'] = "qVOIPDown";
+ $rule['interface'] = "lan";
+ $rule['source']['any'] = TRUE;
+ $rule['destination']['network'] = 'lan';
+ $rule['iptos'] = "lowdelay";
+ $config['shaper']['rule'][] = $rule;
</stepsubmitphpaction>
</step>
<step>
@@ -338,6 +540,21 @@
$queue['priority'] = 0;
$queue['red'] = "on";
$queue['ecn'] = "on";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "1Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "1Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "0%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "0%";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $queue['attachtoqueue'] = "qWANRoot";
$config['shaper']['queue'][] = $queue;
/* create qP2PDown */
@@ -347,6 +564,21 @@
$queue['priority'] = 1;
$queue['red'] = "on";
$queue['ecn'] = "on";
+ $queue['realtime'] = "on";
+ $queue['realtime1'] = "1Kb";
+ $queue['realtime2'] = "1";
+ $queue['realtime3'] = "1Kb";
+ $queue['upperlimit'] = "on";
+ $queue['upperlimit1'] = "90%";
+ $queue['upperlimit2'] = "1";
+ $queue['upperlimit3'] = "90%";
+ $queue['linkshare'] = "on";
+ $queue['linkshare1'] = "1%";
+ $queue['linkshare2'] = "1";
+ $queue['linkshare3'] = "1%";
+ $queue['bandwidth'] = "0";
+ $queue['bandwidthtype'] = "Kb";
+ $queue['attachtoqueue'] = "qLANRoot";
$config['shaper']['queue'][] = $queue;
</stepsubmitphpaction>
</step>
@@ -382,7 +614,7 @@
</field>
</fields>
<stepsubmitphpaction>
-/* XXX enable shaper */
+ $config['shaper']['enable'] = TRUE;
/* XXX reload filter rules */
</stepsubmitphpaction>
</step>
OpenPOWER on IntegriCloud