diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-06-14 08:43:33 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-06-14 08:43:33 -0700 |
commit | 6306f6edae447d824cf1d3beacb7b64f0f00d116 (patch) | |
tree | 9e88adbd7929e06597548df6f27e362957919356 /lib/Vyatta/Qos | |
parent | 03ff4147d09ce175354f7cce780bfef3e8003c0a (diff) | |
download | vyatta-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.pm | 21 |
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; |