summaryrefslogtreecommitdiff
path: root/lib/Vyatta/Qos
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-06-14 08:43:33 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-06-14 08:43:33 -0700
commit6306f6edae447d824cf1d3beacb7b64f0f00d116 (patch)
tree9e88adbd7929e06597548df6f27e362957919356 /lib/Vyatta/Qos
parent03ff4147d09ce175354f7cce780bfef3e8003c0a (diff)
downloadvyatta-cfg-qos-6306f6edae447d824cf1d3beacb7b64f0f00d116.tar.gz
vyatta-cfg-qos-6306f6edae447d824cf1d3beacb7b64f0f00d116.zip
Add default for traffic limiter
This adds: set traffic-policy limiter TL default bandwidth 1mbit
Diffstat (limited to 'lib/Vyatta/Qos')
-rw-r--r--lib/Vyatta/Qos/TrafficLimiter.pm21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Vyatta/Qos/TrafficLimiter.pm b/lib/Vyatta/Qos/TrafficLimiter.pm
index c48e616..bec2b27 100644
--- a/lib/Vyatta/Qos/TrafficLimiter.pm
+++ b/lib/Vyatta/Qos/TrafficLimiter.pm
@@ -68,7 +68,12 @@ sub _define {
die "$level can not match on both ip and other types\n";
}
- foreach my $id ( $config->listNodes("class") ) {
+ if ($config->exists('default')) {
+ $config->setLevel("$level default");
+ push @classes, new Vyatta::Qos::LimiterClass( $config, 0 );
+ }
+
+ foreach my $id ( $config->listNodes('class') ) {
$config->setLevel("$level class $id");
push @classes, new Vyatta::Qos::LimiterClass( $config, $id );
}
@@ -88,15 +93,25 @@ sub commands {
printf "qdisc add dev %s handle %x: prio\n", $dev, $parent;
}
+ # find largest class id (to use for default)
+ my $maxid = 0;
+ foreach my $class (@$classes) {
+ my $id = $class->{id};
+ $maxid = $id if ($id > $maxid);
+ }
+
foreach my $class (@$classes) {
foreach my $match ( $class->matchRules() ) {
+ my $id = $class->{id};
+ $id = $maxid + 1 if ($id == 0);
+
my $police = " police rate " . $class->{rate}
. " action drop burst " . $class->{burst};
- $match->filter( $dev, $parent, $class->{id}, $class->{priority},
- undef, $police );
+ $match->filter( $dev, $parent, $id, $class->{priority}, undef, $police );
}
}
+
}
1;