summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-14 14:01:21 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-14 14:01:21 -0800
commit529f2f91a74aca030ad07af120322ec515d6d377 (patch)
tree0b4b886aea4ef4b1c9cbd2637b2acab4d1495826
parentc2b36d99a7715e13df75d83cc63ce92cac0981dc (diff)
downloadvyatta-cfg-qos-529f2f91a74aca030ad07af120322ec515d6d377.tar.gz
vyatta-cfg-qos-529f2f91a74aca030ad07af120322ec515d6d377.zip
get dsmark working
This makes dsmark work. Need to round up to power of 2 and also pass parent down to handle nested case properly.
-rw-r--r--scripts/VyattaQosMatch.pm6
-rw-r--r--scripts/VyattaQosTrafficShaper.pm22
2 files changed, 18 insertions, 10 deletions
diff --git a/scripts/VyattaQosMatch.pm b/scripts/VyattaQosMatch.pm
index 334b7c1..437dd50 100644
--- a/scripts/VyattaQosMatch.pm
+++ b/scripts/VyattaQosMatch.pm
@@ -41,7 +41,7 @@ sub _define {
}
sub filter {
- my ( $self, $out, $dev, $id ) = @_;
+ my ( $self, $out, $dev, $parent, $id ) = @_;
my $ip = $self->{_ip};
my $indev = $self->{_dev};
my $vif = $self->{_vif};
@@ -51,7 +51,7 @@ sub filter {
return;
}
- print {$out} "filter add dev $dev parent 1:0 prio 1";
+ print {$out} "filter add dev $dev parent $parent:0 prio 1";
if (defined $ip) {
print {$out} " protocol ip u32";
print {$out} " match ip dsfield $$ip{dsfield} 0xff"
@@ -73,5 +73,5 @@ sub filter {
print {$out} " match meta\(vlan mask 0xfff eq $vif\)"
if (defined $vif);
}
- print {$out} " classid 1:$id\n";
+ print {$out} " classid $parent:$id\n";
}
diff --git a/scripts/VyattaQosTrafficShaper.pm b/scripts/VyattaQosTrafficShaper.pm
index 854ee41..1fe92aa 100644
--- a/scripts/VyattaQosTrafficShaper.pm
+++ b/scripts/VyattaQosTrafficShaper.pm
@@ -93,7 +93,8 @@
my $rate = _getPercentRate($self->{_rate}, $speed);
my $ceil = _getPercentRate($self->{_ceiling}, $speed);
my $id = sprintf "%04x", $self->{id};
- print ${out} "class add dev $dev parent $parent:1 classid 1:$id htb rate $rate";
+ print ${out} "class add dev $dev parent $parent:1 classid $parent:$id"
+ . " htb rate $rate";
print ${out} " burst $self->{_burst}" if ( defined $self->{_burst} );
print ${out} " prio $self->{_priority}" if ( defined $self->{_priority} );
@@ -104,7 +105,7 @@
my $matches = $self->{_match};
foreach my $match (@$matches) {
- $match->filter( $out, $dev, $id );
+ $match->filter( $out, $dev, $parent, $id );
}
}
@@ -226,11 +227,10 @@ sub commands {
$default->{id} = ++$maxid;
unshift @$classes, $default;
- # if any dscp marking, then set up hash
+ # Check if we need dsmrk
my $usedsmark;
foreach my $class (@$classes) {
if (defined $class->{dsmark}) {
- print "Class $class->{id} uses dsmark\n";
$usedsmark = 1;
last;
}
@@ -238,9 +238,17 @@ sub commands {
my $parent = "1";
my $root = "root";
+
if ($usedsmark) {
- print {$out} "qdisc add dev $dev root handle 1: dsmark "
- . " indicies $maxid+1 default_index $default->{id}\n";
+ # dsmark max index must be power of 2
+ my $indices = $maxid + 1;
+ while (($indices & ($indices - 1)) != 0) {
+ ++$indices;
+ }
+
+ print {$out} "qdisc add dev $dev handle 1:0 root dsmark"
+ . " indices $indices default_index $default->{id}\n";
+
foreach my $class (@$classes) {
$class->dsmarkClass($out, "1", $dev);
}
@@ -250,7 +258,7 @@ sub commands {
print {$out} "qdisc add dev $dev $root handle $parent: htb";
printf {$out} " default %x\n", $default->{id};
- print {$out} "class add dev $dev parent 1: classid $parent:1 htb rate $rate\n";
+ print {$out} "class add dev $dev parent $parent: classid $parent:1 htb rate $rate\n";
foreach my $class (@$classes) {
$class->htbClass($out, $parent, $dev, $rate);