diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-12-07 15:53:13 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-12-07 15:53:13 -0800 |
commit | b1a6023a196608f6ba8135852db97c31c2e524ad (patch) | |
tree | f7a57dba28749778694474800f644bc2a4833b51 | |
parent | c932d46780e4a22854191a66631c35cc5811de92 (diff) | |
download | vyatta-cfg-qos-b1a6023a196608f6ba8135852db97c31c2e524ad.tar.gz vyatta-cfg-qos-b1a6023a196608f6ba8135852db97c31c2e524ad.zip |
Revert "Add nested shaper classes"
This reverts commit bcb18b96605e194cf8c186467b0a4d853695f75e.
-rw-r--r-- | lib/Vyatta/Qos/RoundRobin.pm | 7 | ||||
-rw-r--r-- | lib/Vyatta/Qos/ShaperClass.pm | 101 | ||||
-rw-r--r-- | lib/Vyatta/Qos/TrafficShaper.pm | 11 | ||||
l--------- | templates/traffic-policy/shaper/node.tag/class/node.tag/class | 1 | ||||
-rw-r--r-- | templates/traffic-policy/shaper/node.tag/class/node.tag/queue-type/node.def | 1 |
5 files changed, 36 insertions, 85 deletions
diff --git a/lib/Vyatta/Qos/RoundRobin.pm b/lib/Vyatta/Qos/RoundRobin.pm index 54a1350..07aa8f7 100644 --- a/lib/Vyatta/Qos/RoundRobin.pm +++ b/lib/Vyatta/Qos/RoundRobin.pm @@ -85,7 +85,12 @@ sub commands { printf "qdisc add dev %s root handle %x: drr\n", $dev, $parent; foreach my $class (sort { $a->{id} <=> $b->{id} } @$classes) { - $class->commands( $dev, 'drr', $parent); + $class->gen_class( $dev, 'drr', $parent ); + $class->gen_leaf( $dev, $parent ); + + foreach my $match ( $class->matchRules() ) { + $match->filter( $dev, $parent, $class->{id}, $class->{id} ); + } } } diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index 0e8083c..cc42f44 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -46,31 +46,14 @@ sub new { $self->{_ceiling} = $config->returnValue("ceiling"); $self->{_burst} = $config->returnValue("burst"); $self->{_limit} = $config->returnValue("queue-limit"); + $self->{_qdisc} = $config->returnValue("queue-type"); $self->{_avgpkt} = $config->returnValue("packet-length"); $self->{_latency} = $config->returnValue("latency"); $self->{_quantum} = $config->returnValue("quantum"); $self->{dsmark} = getDsfield( $config->returnValue("set-dscp") ); - my @matches = _getMatch("$level match"); $self->{_match} = \@matches; - - my @subclasses = $config->listNodes("class"); - my $qtype = $config->returnValue("queue-type"); - - if (@subclasses) { - die "can not set queue-type with sub-classes\n" - if defined($qtype); - - my @classes; - foreach my $id (@subclasses) { - $config->setLevel("$level class $id"); - push @classes, $self->new($config, $id); - } - $self->{_class} = \@classes; - } else { - $self->{_qdisc} = defined($qtype) ? $qtype : 'fair-queue'; - } } return $self; @@ -88,9 +71,15 @@ sub _getMatch { return @matches; } +sub matchRules { + my ($self) = @_; + my $matches = $self->{_match}; + return @$matches; +} + sub _getPercentRate { my ( $rate, $speed ) = @_; - return unless defined($rate); + return unless defined $rate; # Rate might be a percentage of speed if ( $rate =~ /%$/ ) { @@ -182,7 +171,6 @@ sub redQdisc { printf " burst %d probability 0.1 bandwidth %s ecn\n", $burst, $rate; } -# Check if the parameters for RED will work sub redValidate { my ( $self, $level, $rate ) = @_; my $limit = $self->{_limit}; # packets @@ -220,8 +208,6 @@ my %qdiscValidate = ( 'random-detect' => \&redValidate, ); -# Check if the rate configured for the class is higher than the link -# speed, or if the rate exceeds the ceiling. sub rateCheck { my ( $self, $ifspeed, $level ) = @_; @@ -247,22 +233,11 @@ sub rateCheck { exit 1; } - my $subclass = $self->{_class}; - if ($subclass) { - my $rate = $self->{_rate}; + my $qtype = $self->{_qdisc}; + my $q = $qdiscValidate{$qtype}; + return unless $q; - foreach my $class (@$subclass) { - $class->rateCheck($rate, "$level class $class->{id}"); - } - } else { - my $qtype = $self->{_qdisc}; - return unless $qtype; - - my $q = $qdiscValidate{$qtype}; - return unless $q; - - $q->( $self, $level, $rate ); - } + $q->( $self, $level, $rate ); } sub get_rate { @@ -271,7 +246,6 @@ sub get_rate { return _getPercentRate( $self->{_rate}, $speed ); } -# Generate tc commands for class sub gen_class { my ( $self, $dev, $qdisc, $parent, $speed ) = @_; my $rate = _getPercentRate( $self->{_rate}, $speed ); @@ -288,52 +262,17 @@ sub gen_class { print "\n"; } -# Compute the maximum rate for the class -sub max_rate { - my ($self, $speed) = @_; - my $ceil = $self->{_ceiling}; - - if ($ceil) { - return _getPercentRate( $ceil, $speed ); - } else { - return _getPercentRate( $self->{_rate}, $speed ); - } -} - -# If this class has sub classes, generate those commands -# otherwise generate the qdisc parameters for the leaf sub gen_leaf { - my ( $self, $dev, $qdisc, $parent, $speed ) = @_; - my $rate = max_rate($speed); - - my $subclass = $self->{_class}; - if ($subclass) { - foreach my $class (@$subclass) { - $class->commands($dev, $qdisc, $self->{id}, $rate); - } - } else { - my $qtype = $self->{_qdisc}; - my $q = $qdiscOptions{$qtype}; - die "Unknown queue-type $qtype\n" - unless $q; - - printf "qdisc add dev %s parent %x:%x ", $dev, $parent, $self->{id}; - $q->( $self, $dev, $rate ); - } -} - -sub commands { - my ($self, $dev, $qdisc, $parent, $rate) = @_; + my ( $self, $dev, $parent, $rate ) = @_; + my $qtype = $self->{_qdisc}; + return unless $qtype; # default is okay - $self->gen_class( $dev, $qdisc, $parent, $rate ); - $self->gen_leaf( $dev, $qdisc, $parent, $rate ); + my $q = $qdiscOptions{$qtype}; + die "Unknown queue-type $qtype\n" + unless $q; - my $prio = 1; - my $matches = $self->{_match}; - foreach my $match ( @$matches ) { - $match->filter( $dev, $parent, $class->{id}, - $prio++, $class->{dsmark} ); - } + printf "qdisc add dev %s parent %x:%x ", $dev, $parent, $self->{id}; + $q->( $self, $dev, $rate ); } sub dsmarkClass { diff --git a/lib/Vyatta/Qos/TrafficShaper.pm b/lib/Vyatta/Qos/TrafficShaper.pm index a923981..4d43c4e 100644 --- a/lib/Vyatta/Qos/TrafficShaper.pm +++ b/lib/Vyatta/Qos/TrafficShaper.pm @@ -147,8 +147,15 @@ sub commands { printf "class add dev %s parent %x: classid %x:1 htb rate %s\n", $dev, $parent, $parent, $rate; - foreach my $class (sort { $a->{id} <=> $b->{id} } @$classes) { - $class->commands( $dev, 'htb', $parent, $rate); + foreach my $class (@$classes) { + $class->gen_class( $dev, 'htb', $parent, $rate ); + $class->gen_leaf( $dev, $parent, $rate ); + + my $prio = 1; + foreach my $match ( $class->matchRules() ) { + $match->filter( $dev, $parent, $class->{id}, $prio++, + $class->{dsmark} ); + } } } diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/class b/templates/traffic-policy/shaper/node.tag/class/node.tag/class deleted file mode 120000 index dd6cac9..0000000 --- a/templates/traffic-policy/shaper/node.tag/class/node.tag/class +++ /dev/null @@ -1 +0,0 @@ -../../class
\ No newline at end of file diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/queue-type/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/queue-type/node.def index 7ec149a..6b44648 100644 --- a/templates/traffic-policy/shaper/node.tag/class/node.tag/queue-type/node.def +++ b/templates/traffic-policy/shaper/node.tag/class/node.tag/queue-type/node.def @@ -1,4 +1,5 @@ type: txt +default: "fair-queue" syntax:expression: $VAR(@) in "fair-queue", "priority", "drop-tail", "random-detect";\ "Unknown queue-type" help: Queue type for this class |