From 20b1f2af56a7b7c96eed434f0761b6e8bae53555 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 8 Feb 2008 14:45:41 -0800 Subject: fix vlan and device matching Use proper syntax for incoming interface and outgoing vlan match. Need to catch u32 vs basic match filter conflicts. --- scripts/VyattaQosMatch.pm | 49 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'scripts') 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"; } -- cgit v1.2.3