diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 10:51:07 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 10:51:07 -0800 |
commit | 2e846fde9ce03b52e43ee6a1d81755429c027971 (patch) | |
tree | 61a2dc6f947ac2b21c631903630966ae286c0acf | |
parent | 50127014a2b863fb4b5e31f5f61230b22f371e63 (diff) | |
download | vyatta-cfg-qos-2e846fde9ce03b52e43ee6a1d81755429c027971.tar.gz vyatta-cfg-qos-2e846fde9ce03b52e43ee6a1d81755429c027971.zip |
get match rules to work.
fixes http://bugzilla.vyatta.com/show_bug.cgi?id=2738
-rw-r--r-- | scripts/VyattaQosMatch.pm | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/scripts/VyattaQosMatch.pm b/scripts/VyattaQosMatch.pm index 59e0477..fc0958a 100644 --- a/scripts/VyattaQosMatch.pm +++ b/scripts/VyattaQosMatch.pm @@ -7,12 +7,12 @@ my %fields = ( _dev => undef, _vlan => undef, _ip => { - _src => undef, - _dst => undef, - _dsfield => undef, - _protocol => undef, - _sport => undef, - _dport => undef, + src => undef, + dst => undef, + dsfield => undef, + protocol => undef, + sport => undef, + dport => undef, } ); @@ -27,57 +27,42 @@ sub new { return $self; } -sub _dsfield { - my $dsfield = shift; - my $ret = undef; - - if ( defined $dsfield ) { - $ret = VyattaQosUtil::getDsfield($dsfield); - if ( !defined $ret ) { - $dsfield = hex($dsfield); - } - } - return $ret; -} - sub _define { my ( $self, $config ) = @_; - - my $level=$config->setLevel(); + my $level = $config->setLevel(); $self->{_vlan} = $config->returnValue("vif"); $self->{_dev} = $config->returnValue("interface"); + if ($config->exists("ip")) { + my %ip; - $self->{_ip}->{_dsfield} = _dsfield( $config->returnValue("ip dsfield") ); - $self->{_ip}->{_protocol} = $config->returnValue("ip protocol"); - $self->{_ip}->{_src} = $config->returnValue("ip source address"); - $self->{_ip}->{_dst} = $config->returnValue("ip destination address"); - - $self->{_ip}->{_sport} = $config->returnValue("ip source port"); - $self->{_ip}->{_dport} = $config->returnValue("ip destination port"); + $ip{dsfield} = VyattaQosUtil::getDsfield( $config->returnValue("ip dsfield")); + $ip{protocol} = VyattaQosUtil::getProtocol($config->returnValue("ip protocol")); + $ip{src} = $config->returnValue("ip source address"); + $ip{dst} = $config->returnValue("ip destination address"); + $ip{sport} = $config->returnValue("ip source port"); + $ip{dport} = $config->returnValue("ip destination port"); + $self->{_ip} = \%ip; + } } sub filter { my ( $self, $out, $dev, $id ) = @_; - print {$out} "filter add dev $dev parent 1:0 prio 10"; + print {$out} "filter add dev $dev parent 1:0 prio 1"; # TODO match on vlan, device, ... + if (defined $self->{_ip}) { - print {$out} " u32"; - print {$out} " match ip dsfield $self->{_ip}->{_dsfield} 0xff" - if defined $self->{_ip}->{_dsfield}; - print {$out} " match ip protocol $self->{_ip}->{_protocol} 0xff" - if defined $self->{_ip}->{_protocol}; - print {$out} " match ip src $self->{_ip}->{_src}" - if defined $self->{_ip}->{_src}; - print {$out} " match ip sport $self->{_ip}->{_sport}" - if defined $self->{_ip}->{_sport}; - print {$out} " match ip dst $self->{_ip}->{_dst}" - if defined $self->{_ip}->{_dst}; - print {$out} " match ip dport $self->{_ip}->{_dport}" - if defined $self->{_ip}->{_dport}; + 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}; } - print {$out} " classid $id\n"; + print {$out} " classid 1:$id\n"; } |