diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 16:54:48 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 16:54:48 -0800 |
commit | 0b8d73903c3a1245c95d3ed92756fe3df649bbed (patch) | |
tree | 67e0342479bc718d35c04e657357b3036419e9cb /scripts | |
parent | 24b46144a00f1346b0c983884e3f11b91b0c4379 (diff) | |
download | vyatta-cfg-qos-0b8d73903c3a1245c95d3ed92756fe3df649bbed.tar.gz vyatta-cfg-qos-0b8d73903c3a1245c95d3ed92756fe3df649bbed.zip |
add support for match based on incoming device and vlan
This is preliminary (still needs testing) but get the syntax and basic structure
in place.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/VyattaQosMatch.pm | 14 | ||||
-rw-r--r-- | scripts/VyattaQosTrafficShaper.pm | 3 | ||||
-rw-r--r-- | scripts/VyattaQosUtil.pm | 15 |
3 files changed, 24 insertions, 8 deletions
diff --git a/scripts/VyattaQosMatch.pm b/scripts/VyattaQosMatch.pm index fc0958a..31ddf36 100644 --- a/scripts/VyattaQosMatch.pm +++ b/scripts/VyattaQosMatch.pm @@ -5,7 +5,7 @@ use strict; my %fields = ( _dev => undef, - _vlan => undef, + _vif => undef, _ip => { src => undef, dst => undef, @@ -31,7 +31,7 @@ sub _define { my ( $self, $config ) = @_; my $level = $config->setLevel(); - $self->{_vlan} = $config->returnValue("vif"); + $self->{_vif} = VyattaQosUtil::getIfIndex($config->returnValue("vif")); $self->{_dev} = $config->returnValue("interface"); if ($config->exists("ip")) { my %ip; @@ -51,8 +51,6 @@ sub filter { print {$out} "filter add dev $dev parent 1:0 prio 1"; - # TODO match on vlan, device, ... - if (defined $self->{_ip}) { my $ip = $self->{_ip}; print {$out} " protocol ip u32"; @@ -64,5 +62,13 @@ sub filter { print {$out} " match ip dport $$ip{dport} 0xffff" if defined $$ip{dport}; } + if (defined $self->{_dev}) { + print {$out} " basic meta match meta \(rt_iif eq $self->{_dev}\)"; + } + + if (defined $self->{_vif}) { + print {$out} " basic meta match meta \(vlan mask 0xfff eq $self->{_vif}\)"; + } + print {$out} " classid 1:$id\n"; } diff --git a/scripts/VyattaQosTrafficShaper.pm b/scripts/VyattaQosTrafficShaper.pm index 2b95a05..16c1fef 100644 --- a/scripts/VyattaQosTrafficShaper.pm +++ b/scripts/VyattaQosTrafficShaper.pm @@ -34,10 +34,11 @@ my $level = $config->setLevel(); my @matches = (); + $self->{_rate} = $config->returnValue("rate"); + defined $self->{_rate} or die "Rate not defined for class $id\n"; $self->{_id} = sprintf "%04x", $id; $self->{_priority} = $config->returnValue("priority"); - $self->{_rate} = $config->returnValue("rate"); $self->{_ceiling} = $config->returnValue("ceiling"); $self->{_burst} = $config->returnValue("burst"); diff --git a/scripts/VyattaQosUtil.pm b/scripts/VyattaQosUtil.pm index 3a115db..0c9ab83 100644 --- a/scripts/VyattaQosUtil.pm +++ b/scripts/VyattaQosUtil.pm @@ -1,7 +1,7 @@ package VyattaQosUtil; use POSIX; require Exporter; -@EXPORT = qw/getRate getSize getProtocol getDsfield interfaceRate/; +@EXPORT = qw/getRate getSize getProtocol getDsfield getIfIndex interfaceRate/; use strict; sub get_num { @@ -119,12 +119,21 @@ sub getDsfield { last; } } - close($ds); + close($ds) or die "read $dsFileName error\n"; return $match; } -# Utility routines +sub getIfIndex { + my ($str) = @_; + + defined $str or return; + open my $sysfs, "<", "/sys/class/net/$str/ifindex" || die "Unknown interface $str\n"; + my $ifindex = <$sysfs>; + close($sysfs) or die "read sysfs error\n"; + return $ifindex; +} + ## interfaceRate("eth0") # return result in bits per second |