summaryrefslogtreecommitdiffstats
path: root/etc/inc/shaper.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-10-17 16:11:07 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-10-17 16:11:07 +0000
commitb7ff5e40d22b485d42be070d28937699a92d5983 (patch)
treeedfeca80bd7ca1a8fcaedd57e9ac2d5eafdcf572 /etc/inc/shaper.inc
parentc435798ff939fe2309e8abfa3c9c923becc5faf6 (diff)
downloadpfsense-b7ff5e40d22b485d42be070d28937699a92d5983.zip
pfsense-b7ff5e40d22b485d42be070d28937699a92d5983.tar.gz
MFC 6920
Allow for parent queues to work. Cleaned up code that does root queue detection and discovered some odd bugs that made me wonder how it worked correctly. Queues can be reordered (honestly, this is kinda pointless, but I put it in cause it was easier to punt to the user than doing queue trees correctly) This is obviously an XXX and needs to be fixed.
Diffstat (limited to 'etc/inc/shaper.inc')
-rw-r--r--etc/inc/shaper.inc68
1 files changed, 40 insertions, 28 deletions
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc
index 3fadcb2..21d931a 100644
--- a/etc/inc/shaper.inc
+++ b/etc/inc/shaper.inc
@@ -156,13 +156,17 @@ function is_subqueue_used_on_interface($queuename, $interface) {
if (!is_array($qconfig['shaper']['queue'])) return 0;
foreach ($qconfig['shaper']['queue'] as $queue) {
- if($queue['attachtoqueue'] == $queuename)
- $subqueue_interface = filter_is_queue_being_used_on_interface($queue['name'], $interface);
- /* Useful debugging code for when queues are messed up
- * echo "{$subqueue_interface}/{$interface}/{$queue['name']}/{$queuename}\n";
- */
- if ($subqueue_interface != ""){
- return 1;
+ if($queue['attachtoqueue'] == $queuename) {
+ /* recurse if we're a parent queue */
+ if ($queue['parentqueue'] == "on") {
+ return is_subqueue_used_on_interface($queue['name'], $interface);
+ }
+
+ /* If we're not a parent check to see if the queue is used on this interface */
+ $subqueue_interface = filter_is_queue_being_used_on_interface($queue['name'], $interface);
+ if ($subqueue_interface != ""){
+ return 1;
+ }
}
}
return 0;
@@ -199,28 +203,8 @@ function filter_setup_altq_interfaces() {
$queue_names = "";
$is_first = "";
- $workting_with_interface = $ifname;
-
- foreach ($config['shaper']['queue'] as $queue) {
- $rule_interface = "";
- $q = $queue;
- $rule_interface = filter_is_queue_being_used_on_interface($q['name'], $workting_with_interface);
- if ($rule_interface == $workting_with_interface) {
- if(!isset($q['attachtoqueue'])) {
- if($is_first) $queue_names .= ", ";
- $queue_names .= $q['name'];
- $is_first = "1";
- }
- } else {
- if(isset($q['parentqueue']) && ($q['parentqueue'] <> "")) {
- if(is_subqueue_used_on_interface($q['name'], $workting_with_interface)) {
- $queue_names .= " ";
- $queue_names .= $q['name'];
- }
- }
- }
+ $queue_names = find_root_queue($ifname);
- }
if($queue_names <> ""){
$altq_rules .= "altq on {$config['interfaces'][$ifname]['if']} ";
if($config['interfaces'][$ifname]['bandwidth'] <> "")
@@ -234,6 +218,34 @@ function filter_setup_altq_interfaces() {
return $altq_rules;
}
+/* Find the root queue for an interface */
+function find_root_queue($ifname) {
+ global $config;
+
+ $dbg = fopen("/tmp/debug", 'a');
+ foreach ($config['shaper']['queue'] as $queue) {
+ $rule_interface = "";
+ $q = $queue;
+ fwrite($dbg, "interface: {$ifname}\n");
+ fwrite($dbg, "queue: {$q['name']} parent: {$q['parentqueue']} attached: {$q['attachtoqueue']}\n");
+ /* if we're a parentqueue and aren't attached to another queue we're probably a root */
+ if ((isset($q['parentqueue']) && $q['parentqueue'] <> "") && (!isset($q['attachtoqueue']) || $q['attachtoqueue'] == "")) {
+ fwrite($dbg, "queue: {$q['name']} is a parent\n");
+ /* Confirm that this is a valid queue for this interface */
+ $rule_interface = is_subqueue_used_on_interface($q['name'], $ifname);
+ if ($rule_interface == 1) {
+ fwrite($dbg, "queue: {$q['name']} is a parent on {$ifname}\n");
+ $queue_names .= " ";
+ $queue_names .= $q['name'];
+ }
+ }
+ }
+ fclose($dbg);
+ return $queue_names;
+}
+
+
+
function is_queue_attached_children($name) {
global $config;
OpenPOWER on IntegriCloud