summaryrefslogtreecommitdiff
path: root/lib/Vyatta/Qos/ShaperClass.pm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-13 16:49:02 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-13 16:49:02 -0700
commitd222de9c4110494f2621fe9251254a724fa20dc5 (patch)
tree571b9b967df0a2c492aaa8060e5bcd2ad93f191f /lib/Vyatta/Qos/ShaperClass.pm
parent1c240e8ba32f96b002ecaf0b7a1e87e1e15d1605 (diff)
downloadvyatta-cfg-qos-d222de9c4110494f2621fe9251254a724fa20dc5.tar.gz
vyatta-cfg-qos-d222de9c4110494f2621fe9251254a724fa20dc5.zip
Fix RoundRobin scheduler
Need to change assumptions in ShaperClass about bandwidth and this goes over to TrafficShaper and RR.
Diffstat (limited to 'lib/Vyatta/Qos/ShaperClass.pm')
-rw-r--r--lib/Vyatta/Qos/ShaperClass.pm63
1 files changed, 28 insertions, 35 deletions
diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm
index 9a0ba00..1dbfd98 100644
--- a/lib/Vyatta/Qos/ShaperClass.pm
+++ b/lib/Vyatta/Qos/ShaperClass.pm
@@ -23,52 +23,45 @@ require Vyatta::Config;
use Vyatta::Qos::Match;
use Vyatta::Qos::Util qw/getDsfield getRate/;
-my %fields = (
- id => undef,
- dsmark => undef,
- _priority => undef,
- _rate => undef,
- _ceiling => undef,
- _burst => undef,
- _match => undef,
- _limit => undef,
- _qdisc => undef,
-);
sub new {
my ( $that, $config, $id ) = @_;
- my $class = ref($that) || $that;
- my $self = {%fields};
+ my $class = ref($that) || $that;
+ my $self = { };
$self->{id} = $id;
bless $self, $class;
- $self->_define($config) if ($config);
+
+ if ($config) {
+ my $level = $config->setLevel();
+
+ $self->{level} = $level;
+ $self->{_rate} = $config->returnValue("bandwidth");
+ $self->{_priority} = $config->returnValue("priority");
+ $self->{_ceiling} = $config->returnValue("ceiling");
+ $self->{_burst} = $config->returnValue("burst");
+ $self->{_limit} = $config->returnValue("queue-limit");
+ $self->{_qdisc} = $config->returnValue("queue-type");
+
+ $self->{dsmark} = getDsfield( $config->returnValue("set-dscp") );
+ my @matches = _getMatch("$level match");
+ $self->{_match} = \@matches;
+ }
return $self;
}
-sub _define {
- my ( $self, $config ) = @_;
- my $level = $config->setLevel();
- my @matches = ();
-
- $self->{_rate} = $config->returnValue("bandwidth");
- defined $self->{_rate} or die "$level bandwidth not defined\n";
-
- $self->{_priority} = $config->returnValue("priority");
- $self->{_ceiling} = $config->returnValue("ceiling");
- $self->{_burst} = $config->returnValue("burst");
- $self->{_limit} = $config->returnValue("queue-limit");
- $self->{_qdisc} = $config->returnValue("queue-type");
+sub _getMatch {
+ my $level = shift;
+ my @matches;
+ my $config = new Vyatta::Config;
- $self->{dsmark} = getDsfield( $config->returnValue("set-dscp") );
-
- foreach my $match ( $config->listNodes("match") ) {
- $config->setLevel("$level match $match");
+ foreach my $match ( $config->listNodes($level) ) {
+ $config->setLevel("$level $match");
push @matches, new Vyatta::Qos::Match($config);
}
- $self->{_match} = \@matches;
+ return @matches;
}
sub matchRules {
@@ -210,11 +203,11 @@ sub gen_class {
sub gen_leaf {
my ( $self, $dev, $parent, $rate ) = @_;
- my $q = $qdiscOptions{ $self->{_qdisc} };
- die "Unknown queue type $self->{_qdisc}\n" unless $q;
printf "qdisc add dev %s parent %x:%x ", $dev, $parent, $self->{id};
- $q->( $self, $dev, $rate );
+
+ my $q = $qdiscOptions{ $self->{_qdisc} };
+ $q->( $self, $dev, $rate ) if ($q);
}
sub dsmarkClass {