summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-08 14:45:41 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-08 14:45:41 -0800
commit20b1f2af56a7b7c96eed434f0761b6e8bae53555 (patch)
tree88397bc71d30ae4efdd827b0179f8adb857e8965 /scripts
parent49decef8f62c517071c76b620f6f19ef90a8cbf8 (diff)
downloadvyatta-cfg-qos-20b1f2af56a7b7c96eed434f0761b6e8bae53555.tar.gz
vyatta-cfg-qos-20b1f2af56a7b7c96eed434f0761b6e8bae53555.zip
fix vlan and device matching
Use proper syntax for incoming interface and outgoing vlan match. Need to catch u32 vs basic match filter conflicts.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VyattaQosMatch.pm49
1 files changed, 31 insertions, 18 deletions
diff --git a/scripts/VyattaQosMatch.pm b/scripts/VyattaQosMatch.pm
index 7263afc..9904274 100644
--- a/scripts/VyattaQosMatch.pm
+++ b/scripts/VyattaQosMatch.pm
@@ -30,6 +30,10 @@ sub _define {
if ($config->exists("ip")) {
my %ip;
+ if (defined $self->{_dev} || defined $self->{_vif}) {
+ die "Match on both ip field and device not supported\n";
+ }
+
$ip{dsfield} = VyattaQosUtil::getDsfield( $config->returnValue("ip dscp"));
$ip{protocol} = VyattaQosUtil::getProtocol($config->returnValue("ip protocol"));
$ip{src} = $config->returnValue("ip source address");
@@ -42,27 +46,36 @@ sub _define {
sub filter {
my ( $self, $out, $dev, $id ) = @_;
+ my $ip = $self->{_ip};
+ my $indev = $self->{_dev};
+ my $vif = $self->{_vif};
- print {$out} "filter add dev $dev parent 1:0 prio 1";
-
- if (defined $self->{_ip}) {
- my $ip = $self->{_ip};
- print {$out} " protocol ip u32";
- print {$out} " match ip dsfield $$ip{dsfield} 0xff" if defined $$ip{dsfield};
- print {$out} " match ip protocol $$ip{protocol} 0xff" if defined $$ip{protocol};
- print {$out} " match ip src $$ip{src}" if defined $$ip{src};
- print {$out} " match ip sport $$ip{sport} 0xffff" if defined $$ip{sport};
- print {$out} " match ip dst $$ip{dst}" if defined $$ip{dst};
- print {$out} " match ip dport $$ip{dport} 0xffff" if defined $$ip{dport};
+ # Catch empty match
+ if (! (defined $ip || defined $indev || defined $vif)) {
+ return;
}
- if (defined $self->{_dev}) {
- print {$out} " basic match meta \(rt_iif eq $self->{_dev}\)";
- }
-
- if (defined $self->{_vif}) {
- print {$out} " basic match meta \(vlan mask 0xfff eq $self->{_vif}\)";
+ print {$out} "filter add dev $dev parent 1:0 prio 1";
+ if (defined $ip) {
+ print {$out} " protocol ip u32";
+ print {$out} " match ip dsfield $$ip{dsfield} 0xff"
+ if defined $$ip{dsfield};
+ print {$out} " match ip protocol $$ip{protocol} 0xff"
+ if defined $$ip{protocol};
+ print {$out} " match ip src $$ip{src}"
+ if defined $$ip{src};
+ print {$out} " match ip sport $$ip{sport} 0xffff"
+ if defined $$ip{sport};
+ print {$out} " match ip dst $$ip{dst}"
+ if defined $$ip{dst};
+ print {$out} " match ip dport $$ip{dport} 0xffff"
+ if defined $$ip{dport};
+ } else {
+ print {$out} " protocol all basic";
+ print {$out} " match meta\(rt_iif eq $indev\)"
+ if (defined $indev);
+ print {$out} " match meta\(vlan mask 0xfff eq $vif\)"
+ if (defined $vif);
}
-
print {$out} " classid 1:$id\n";
}