diff options
Diffstat (limited to 'lib/Vyatta/Qos')
-rw-r--r-- | lib/Vyatta/Qos/ShaperClass.pm | 32 | ||||
-rw-r--r-- | lib/Vyatta/Qos/TrafficShaper.pm | 3 |
2 files changed, 17 insertions, 18 deletions
diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index 631fc75..aa3a8ff 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -181,8 +181,7 @@ sub redQdisc { my $qmax = $qlimit / 8; my $qmin = $qmax / 3; - printf "red limit %d min %d max %d avpkt %d", - $qlimit, $qmin, $qmax, $avg; + printf "red limit %d min %d max %d avpkt %d", $qlimit, $qmin, $qmax, $avg; printf " burst %d probability 0.02 bandwidth %d ecn\n", ( 2 * $qmin + $qmax ) / ( 3 * $avg ), $rate / 1000; } @@ -194,29 +193,28 @@ my %qdiscOptions = ( 'drop-tail' => \&fifoQdisc, ); -sub htbClass { - my ( $self, $dev, $parent, $speed ) = @_; +sub gen_class { + my ( $self, $dev, $qdisc, $parent, $speed ) = @_; my $rate = _getPercentRate( $self->{_rate}, $speed ); my $ceil = _getPercentRate( $self->{_ceiling}, $speed ); - printf "class add dev %s parent %x:1 classid %x:%x htb rate %s", - $dev, $parent, $parent, $self->{id}, $rate; + printf "class add dev %s parent %x:1 classid %x:%x %s", + $dev, $parent, $parent, $self->{id}, $qdisc; + print " rate $rate" if ($rate); print " ceil $ceil" if ($ceil); - print " burst $self->{_burst}" if ( defined $self->{_burst} ); - print " prio $self->{_priority}" if ( defined $self->{_priority} ); + print " burst $self->{_burst}" if ( $self->{_burst} ); + print " prio $self->{_priority}" if ( $self->{_priority} ); print "\n"; +} - # create leaf qdisc +sub gen_leaf { + my ( $self, $dev, $parent, $rate ) = @_; my $q = $qdiscOptions{ $self->{_qdisc} }; - if ( defined $q ) { - printf "qdisc add dev %s parent %x:%x ", - $dev, $parent, $self->{id}; - $q->( $self, $dev, $rate ); - } - else { - die "Unknown queue type $self->{_qdisc}\n"; - } + 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 ); } sub dsmarkClass { diff --git a/lib/Vyatta/Qos/TrafficShaper.pm b/lib/Vyatta/Qos/TrafficShaper.pm index 8295764..2ea710b 100644 --- a/lib/Vyatta/Qos/TrafficShaper.pm +++ b/lib/Vyatta/Qos/TrafficShaper.pm @@ -191,7 +191,8 @@ sub commands { $dev, $parent, $parent, $rate; foreach my $class (@$classes) { - $class->htbClass( $dev, $parent, $rate ); + $class->gen_class( $dev, 'htb', $parent, $rate ); + $class->gen_leaf( $dev, $parent, $rate ); foreach my $match ( $class->matchRules() ) { $match->filter( $dev, $parent, 1, $class->{dsmark} ); |