summaryrefslogtreecommitdiff
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
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
-rw-r--r--lib/Vyatta/Qos/TrafficLimiter.pm21
-rw-r--r--templates/traffic-policy/limiter/node.tag/default/bandwidth/node.def8
-rw-r--r--templates/traffic-policy/limiter/node.tag/default/burst/node.def7
-rw-r--r--templates/traffic-policy/limiter/node.tag/default/description/node.def2
-rw-r--r--templates/traffic-policy/limiter/node.tag/default/priority/node.def8
5 files changed, 43 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;
diff --git a/templates/traffic-policy/limiter/node.tag/default/bandwidth/node.def b/templates/traffic-policy/limiter/node.tag/default/bandwidth/node.def
new file mode 100644
index 0000000..13c70ee
--- /dev/null
+++ b/templates/traffic-policy/limiter/node.tag/default/bandwidth/node.def
@@ -0,0 +1,8 @@
+type: txt
+help: Set the traffic-limit used for this class [REQUIRED]
+syntax:expression: exec "/opt/vyatta/sbin/vyatta-qos-util.pl --rate $VAR(@)"
+comp_help: Allowed values:
+ <number> Bandwidth in Kbps
+ <number><suffix> Value with scaling suffix
+ bits per sec (kbit, mbit, gbit)
+ bytes per sec (kbps, mbps, gbps)
diff --git a/templates/traffic-policy/limiter/node.tag/default/burst/node.def b/templates/traffic-policy/limiter/node.tag/default/burst/node.def
new file mode 100644
index 0000000..e22453c
--- /dev/null
+++ b/templates/traffic-policy/limiter/node.tag/default/burst/node.def
@@ -0,0 +1,7 @@
+type: txt
+help: Set the burst size for this class (default: 15kb)
+default: "15k"
+syntax:expression: exec "/opt/vyatta/sbin/vyatta-qos-util.pl --burst $VAR(@)"
+comp_help: Allowed values:
+ <number> Burst size in bytes
+ <number><suffix> Size with scaling suffix (kb, mb, gb)
diff --git a/templates/traffic-policy/limiter/node.tag/default/description/node.def b/templates/traffic-policy/limiter/node.tag/default/description/node.def
new file mode 100644
index 0000000..d4241e7
--- /dev/null
+++ b/templates/traffic-policy/limiter/node.tag/default/description/node.def
@@ -0,0 +1,2 @@
+type: txt
+help: Set description for this traffic class
diff --git a/templates/traffic-policy/limiter/node.tag/default/priority/node.def b/templates/traffic-policy/limiter/node.tag/default/priority/node.def
new file mode 100644
index 0000000..a99400d
--- /dev/null
+++ b/templates/traffic-policy/limiter/node.tag/default/priority/node.def
@@ -0,0 +1,8 @@
+type: u32
+help: Set priority for rule evaluation
+default: 20
+syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 20 ; \
+ "priority must be between 0 and 20"
+help: Priority value
+comp_help: Priority for traffic limiting evaluation
+ <0-20> (default 20)