From b0d2fde832dcef9fb1018ce66eed7533c32be43a Mon Sep 17 00:00:00 2001 From: Carl Byington Date: Sat, 8 Nov 2014 16:04:56 -0800 Subject: add fair queue codel queueing (#446) Signed-off-by: kouak --- lib/Vyatta/Qos/FairQueueCodel.pm | 62 +++++++++++++++++++++ lib/Vyatta/Qos/Match.pm | 113 +++++++++++++++++++++++++++++++++------ lib/Vyatta/Qos/ShaperClass.pm | 27 ++++++---- lib/Vyatta/Qos/Shared.pm | 13 ++--- 4 files changed, 184 insertions(+), 31 deletions(-) create mode 100644 lib/Vyatta/Qos/FairQueueCodel.pm (limited to 'lib') diff --git a/lib/Vyatta/Qos/FairQueueCodel.pm b/lib/Vyatta/Qos/FairQueueCodel.pm new file mode 100644 index 0000000..980cbeb --- /dev/null +++ b/lib/Vyatta/Qos/FairQueueCodel.pm @@ -0,0 +1,62 @@ +# This is a wrapper around fq_codel queue discipline +# +# +# **** License **** +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# This code was originally developed by Vyatta, Inc. +# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. +# All Rights Reserved. +# **** End License **** + +package Vyatta::Qos::FairQueueCodel; + +use strict; +use warnings; + +require Vyatta::Config; + +# Fair Queue Codel +# Uses fq_codel + +my %fields = ( + _limit => undef, + _flows => undef, + _target => undef, + _interval => undef, + _quantum => undef, +); + +sub new { + my ( $that, $config ) = @_; + my $class = ref($that) || $that; + my $self = {%fields}; + + $self->{_limit} = $config->returnValue('queue-limit'); + $self->{_flows} = $config->returnValue('flows'); + $self->{_target} = $config->returnValue('target'); + $self->{_interval} = $config->returnValue('interval'); + $self->{_quantum} = $config->returnValue('quantum'); + return bless $self, $class; +} + +sub commands { + my ( $self, $dev ) = @_; + + print "qdisc add dev $dev root fq_codel"; + print " limit $self->{_limit}" if ( $self->{_limit} ); + print " flows $self->{_flows}" if ( $self->{_flows} ); + print " target $self->{_target}" if ( $self->{_target} ); + print " interval $self->{_interval}" if ( $self->{_interval} ); + print " quantum $self->{_quantum}" if ( $self->{_quantum} ); + print " noecn\n"; +} + +1; diff --git a/lib/Vyatta/Qos/Match.pm b/lib/Vyatta/Qos/Match.pm index c8078b6..2b22c30 100644 --- a/lib/Vyatta/Qos/Match.pm +++ b/lib/Vyatta/Qos/Match.pm @@ -26,7 +26,7 @@ sub getPort { if ( $str =~ /^([0-9]+)|(0x[0-9a-fA-F]+)$/ ) { die "$str is not a valid port number\n" - if ( $str <= 0 || $str > 65535 ); + if ( $str <= 0 || $str > 65535 ); return $str; } @@ -47,8 +47,8 @@ sub new { # special case for match all unless ($config) { - $self->{'ether'} = { protocol => 'all' }; - return $self; + $self->{'ether'} = { protocol => 'all' }; + return $self; } foreach my $af (qw(ip ipv6 ether)) { @@ -88,7 +88,7 @@ sub new { } } - # if the hash is empty then we didn't generate a match rule + # if the hash is empty then we didn't generate a match rule # this usually means user left an uncompleted match in the config my @keys = keys(%fields); if ($#keys < 0) { @@ -120,6 +120,82 @@ sub new { return $self; } +sub small_ip_filter { + my ( $dev, $parent, $prio, $classid ) = @_; + my $protoip = "ip"; + my $synack = 2; # hash table id, arbitrary number + $parent = sprintf("%x", $parent); + $classid = sprintf("%x", $classid); + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32\n"; + # make a linked hash table + print "filter add dev $dev parent $parent: prior $prio protocol $protoip handle $synack: u32 divisor 1\n"; + # tcp syn bit + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32 ht $synack:"; + print " match u8 0x02 0x02 at 13"; + print " flowid $parent:$classid\n"; + # tcp ack bit + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32 ht $synack:"; + print " match u8 0x10 0x10 at 13"; + print " flowid $parent:$classid\n"; + # ipv4/icmp + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; + print " match ip protocol 1 0xff"; + print " flowid $parent:$classid\n"; + # ipv4/tcp, total len<256, tos=0x10 == minimum delay + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; + print " match ip protocol 6 0xff"; + print " match u16 0x0000 0xff00 at 2"; + print " match ip tos 0x10 0xff"; + print " flowid $parent:$classid\n"; + # ipv4/tcp, total len<128, not fragmented + print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; + print " match ip protocol 6 0xff"; + print " match u16 0x0000 0xff80 at 2"; + print " match ip nofrag"; + print " offset at 0 mask 0x0f00 shift 6 eat"; + print " link $synack:\n"; +} + +sub small_ip6_filter { + my ( $dev, $parent, $prio, $classid ) = @_; + my $protoip6 = "ipv6"; + my $synack6 = 3; # hash table id, arbitrary number + $parent = sprintf("%x", $parent); + $classid = sprintf("%x", $classid); + # setup base filter + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32\n"; + # make a linked hash table + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 handle $synack6: u32 divisor 1\n"; + # tcp syn bit + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32 ht $synack6: "; + print " match u8 0x02 0x02 at 13"; + print " flowid $parent:$classid\n"; + # tcp ack bit + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32 ht $synack6:"; + print " match u8 0x10 0x10 at 13"; + print " flowid $parent:$classid\n"; + # ipv6/icmpv6 + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; + print " match ip6 protocol 58 0xff"; + print " flowid $parent:$classid\n"; + # ipv6/tcp, payload len<128, priority=0x10 == minimum delay + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; + print " match ip6 protocol 6 0xff"; + print " match u16 0x0000 0xff80 at 4"; + print " match ip6 priority 0x10 0xff"; + print " flowid $parent:$classid\n"; + # ipv6/tcp, payload len<64, not fragmented since the next header is a tcp header + # this does not handle packets with other ipv6 extension headers that might be + # present between the ipv6 header and the tcp header + print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; + print " match ip6 protocol 6 0xff"; + print " match u16 0x0000 0xffc0 at 4"; + print " offset plus 40 eat"; + print " link $synack6:\n"; +} + + + sub filter { my ( $self, $dev, $parent, $classid, $prio, $dsmark, $police ) = @_; @@ -134,9 +210,9 @@ sub filter { next unless $ip && $$ip{dsfield}; printf "filter add dev %s parent %x: protocol %s prio %d", - $dev, $parent, $ipver, $prio; + $dev, $parent, $ipver, $prio; printf " handle %s tcindex classid %x:%x\n", - $$ip{dsfield}, $parent, $classid; + $$ip{dsfield}, $parent, $classid; $prio += 1; } @@ -148,12 +224,18 @@ sub filter { my $p = $self->{$proto}; next unless $p; + if (defined($$p{small})) { + small_ip_filter($dev, $parent, $prio, $classid) if ($proto eq 'ip'); + small_ip6_filter($dev, $parent, $prio, $classid) if ($proto eq 'ipv6'); + next; + } + printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; if ( $proto eq 'ether' ) { my $type = $$p{protocol}; $type = 'all' unless $type; - print " protocol $type u32"; + print " protocol $type u32"; if ( defined( $$p{src} ) || defined( $$p{dst} ) ) { print " match ether src $$p{src}" if $$p{src}; print " match ether dst $$p{dst}" if $$p{dst}; @@ -211,8 +293,8 @@ sub filter { } } - print " match mark $fwmark 0xff" if $fwmark; - print " $police" if $police; + print " match mark $fwmark 0xff" if $fwmark; + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; return; } @@ -221,18 +303,17 @@ sub filter { my $vif = $self->{_vif}; if ( defined($vif) || defined($indev) ) { printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; - print " protocol all basic"; - print " match meta\(rt_iif eq $indev\)" if $indev; - print " match meta\(vlan mask 0xfff eq $vif\)" if $vif; - print " match meta\(fwmark eq $fwmark\)" if $fwmark; - - print " $police" if $police; + print " protocol all basic"; + print " match meta\(rt_iif eq $indev\)" if $indev; + print " match meta\(vlan mask 0xfff eq $vif\)" if $vif; + print " match meta\(fwmark eq $fwmark\)" if $fwmark; + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; } elsif ($fwmark) { printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; printf " protocol all handle %d fw", $fwmark; - print " $police" if $police; + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; } } diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index 4d3cf33..a7d9b22 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -51,7 +51,7 @@ sub new { $self->{_qdisc} = $config->returnValue("queue-type"); $self->{_avgpkt} = $config->returnValue("packet-length"); $self->{_latency} = $config->returnValue("latency"); - $self->{_quantum} = $config->returnValue("quantum"); + $self->{_quantum} = $config->returnValue("quantum"); $self->{dsmark} = getDsfield( $config->returnValue("set-dscp") ); my @matches = _getMatch("$level match"); @@ -94,7 +94,7 @@ sub _getPercentRate { } return ( $percent * $speed ) / 100.; - } + } return getRate($rate); } @@ -122,6 +122,14 @@ sub sfqQdisc { print "\n"; } +sub codelQdisc { + my ( $self, $dev, $rate ) = @_; + + print "fq_codel"; + print " limit $self->{_limit}" if ( $self->{_limit} ); + print " noecn\n"; +} + sub sfqValidate { my ( $self, $level ) = @_; my $limit = $self->{_limit}; @@ -178,15 +186,15 @@ sub redQdisc { sub redValidate { my ( $self, $level, $rate ) = @_; - my $limit = $self->{_limit}; # packets - my $thresh = redQsize($rate); # bytes + my $limit = $self->{_limit}; # packets + my $thresh = redQsize($rate); # bytes my $qmax = POSIX::ceil($thresh / AVGPKT); # packets if ( defined($limit) && $limit < $qmax ) { print STDERR "Configuration error in: $level\n"; printf STDERR "The queue limit (%d) is too small, must be %d or more when using random-detect\n", - $limit, $qmax; + $limit, $qmax; exit 1; } @@ -194,16 +202,17 @@ sub redValidate { my $minbw = ( 3 * AVGPKT * 8 ) / LATENCY; print STDERR "Configuration error in: $level\n"; - printf STDERR + printf STDERR "Random-detect queue type requires effective bandwidth of %d Kbit/sec or greater\n", $minbw; - exit 1; + exit 1; } } my %qdiscOptions = ( 'priority' => \&prioQdisc, 'fair-queue' => \&sfqQdisc, + 'fq-codel' => \&codelQdisc, 'random-detect' => \&redQdisc, 'drop-tail' => \&fifoQdisc, ); @@ -264,7 +273,7 @@ sub gen_class { # Hack to avoid kernel HTB message if quantum is small. # Only occurs if link speed is high and offered bandwidth is small. if ( defined($r2q) && !defined($quantum) && ($rate / 8) / $r2q < MINQUANTUM ) { - $quantum = MINQUANTUM; + $quantum = MINQUANTUM; } printf "class add dev %s parent %x:1 classid %x:%x %s", @@ -272,7 +281,7 @@ sub gen_class { print " rate $rate" if ($rate); print " ceil $ceil" if ($ceil); - print " quantum $quantum" if ($quantum); + print " quantum $quantum" if ($quantum); print " burst $self->{_burst}" if ( $self->{_burst} ); print " prio $self->{_priority}" if ( $self->{_priority} ); diff --git a/lib/Vyatta/Qos/Shared.pm b/lib/Vyatta/Qos/Shared.pm index 2a0fc3d..2b13b04 100644 --- a/lib/Vyatta/Qos/Shared.pm +++ b/lib/Vyatta/Qos/Shared.pm @@ -28,21 +28,22 @@ our @EXPORT = qw(find_policy interfaces_using get_policy_names list_policy %policies); use base qw(Exporter); -our %policies = ( +our %policies = ( 'out' => { 'shaper-hfsc' => 'HFSCShaper', 'shaper' => 'TrafficShaper', 'fair-queue' => 'FairQueue', + 'fq-codel' => 'FairQueueCodel', 'rate-control' => 'RateLimiter', 'drop-tail' => 'DropTail', 'network-emulator' => 'NetworkEmulator', 'round-robin' => 'RoundRobin', 'priority-queue' => 'Priority', 'random-detect' => 'RandomDetect', - }, + }, 'in' => { 'limiter' => 'TrafficLimiter', - } + } ); # find policy for name - also check for duplicates @@ -106,12 +107,12 @@ sub get_policy_names { $config->setLevel('traffic-policy'); - foreach my $direction ( @args ) { + foreach my $direction ( @args ) { my @qos = grep { $policies{$direction}{$_} } $config->$listNodes(); foreach my $type (@qos) { my @n = $config->$listNodes($type); - push @names, @n; - } + push @names, @n; + } } return @names; } -- cgit v1.2.3 From 1a9399fe3e2dc25fadff10dd8c72485337dedb51 Mon Sep 17 00:00:00 2001 From: Carl Byington Date: Thu, 18 Dec 2014 09:07:32 -0800 Subject: add fq-codel parameters (#446) Signed-off-by: kouak --- lib/Vyatta/Qos/FairQueueCodel.pm | 4 ++-- lib/Vyatta/Qos/ShaperClass.pm | 13 ++++++++++++- .../traffic-policy/fq-codel/node.tag/codel-quantum/node.def | 2 ++ templates/traffic-policy/fq-codel/node.tag/flows/node.def | 2 +- .../traffic-policy/fq-codel/node.tag/interval/node.def | 2 +- templates/traffic-policy/fq-codel/node.tag/quantum/node.def | 2 -- templates/traffic-policy/fq-codel/node.tag/target/node.def | 2 +- .../node.tag/class/node.tag/codel-quantum/node.def | 2 ++ .../priority-queue/node.tag/class/node.tag/flows/node.def | 2 ++ .../node.tag/class/node.tag/interval/node.def | 2 ++ .../priority-queue/node.tag/class/node.tag/target/node.def | 3 +++ .../priority-queue/node.tag/default/codel-quantum/node.def | 2 ++ .../priority-queue/node.tag/default/flows/node.def | 2 ++ .../priority-queue/node.tag/default/interval/node.def | 2 ++ .../priority-queue/node.tag/default/target/node.def | 3 +++ .../node.tag/class/node.tag/codel-quantum/node.def | 2 ++ .../round-robin/node.tag/class/node.tag/flows/node.def | 2 ++ .../round-robin/node.tag/class/node.tag/interval/node.def | 2 ++ .../round-robin/node.tag/class/node.tag/target/node.def | 3 +++ .../round-robin/node.tag/default/codel-quantum/node.def | 2 ++ .../round-robin/node.tag/default/flows/node.def | 2 ++ .../round-robin/node.tag/default/interval/node.def | 2 ++ .../round-robin/node.tag/default/target/node.def | 3 +++ .../shaper/node.tag/class/node.tag/codel-quantum/node.def | 2 ++ .../shaper/node.tag/class/node.tag/flows/node.def | 2 ++ .../shaper/node.tag/class/node.tag/interval/node.def | 2 ++ .../shaper/node.tag/class/node.tag/target/node.def | 3 +++ .../shaper/node.tag/default/codel-quantum/node.def | 2 ++ .../traffic-policy/shaper/node.tag/default/flows/node.def | 2 ++ .../shaper/node.tag/default/interval/node.def | 2 ++ .../traffic-policy/shaper/node.tag/default/target/node.def | 3 +++ 31 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 templates/traffic-policy/fq-codel/node.tag/codel-quantum/node.def delete mode 100644 templates/traffic-policy/fq-codel/node.tag/quantum/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/class/node.tag/codel-quantum/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/class/node.tag/flows/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/class/node.tag/interval/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/class/node.tag/target/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/default/codel-quantum/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/default/flows/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/default/interval/node.def create mode 100644 templates/traffic-policy/priority-queue/node.tag/default/target/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/class/node.tag/codel-quantum/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/class/node.tag/flows/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/class/node.tag/interval/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/class/node.tag/target/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/default/codel-quantum/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/default/flows/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/default/interval/node.def create mode 100644 templates/traffic-policy/round-robin/node.tag/default/target/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/codel-quantum/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/flows/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/interval/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/target/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/default/codel-quantum/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/default/flows/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/default/interval/node.def create mode 100644 templates/traffic-policy/shaper/node.tag/default/target/node.def (limited to 'lib') diff --git a/lib/Vyatta/Qos/FairQueueCodel.pm b/lib/Vyatta/Qos/FairQueueCodel.pm index 980cbeb..79c1f79 100644 --- a/lib/Vyatta/Qos/FairQueueCodel.pm +++ b/lib/Vyatta/Qos/FairQueueCodel.pm @@ -43,7 +43,7 @@ sub new { $self->{_flows} = $config->returnValue('flows'); $self->{_target} = $config->returnValue('target'); $self->{_interval} = $config->returnValue('interval'); - $self->{_quantum} = $config->returnValue('quantum'); + $self->{_cquantum} = $config->returnValue('codel-quantum'); return bless $self, $class; } @@ -55,7 +55,7 @@ sub commands { print " flows $self->{_flows}" if ( $self->{_flows} ); print " target $self->{_target}" if ( $self->{_target} ); print " interval $self->{_interval}" if ( $self->{_interval} ); - print " quantum $self->{_quantum}" if ( $self->{_quantum} ); + print " quantum $self->{_cquantum}" if ( $self->{_cquantum} ); print " noecn\n"; } diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index a7d9b22..b4689b4 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -52,6 +52,13 @@ sub new { $self->{_avgpkt} = $config->returnValue("packet-length"); $self->{_latency} = $config->returnValue("latency"); $self->{_quantum} = $config->returnValue("quantum"); + $self->{_flows} = $config->returnValue('flows'); + $self->{_target} = $config->returnValue('target'); + $self->{_interval} = $config->returnValue('interval'); + $self->{_cquantum} = $config->returnValue('codel-quantum'); + + if ( $self->{_target} ) { $self->{_target} *= 1000; } + if ( $self->{_interval} ) { $self->{_interval} *= 1000; } $self->{dsmark} = getDsfield( $config->returnValue("set-dscp") ); my @matches = _getMatch("$level match"); @@ -126,7 +133,11 @@ sub codelQdisc { my ( $self, $dev, $rate ) = @_; print "fq_codel"; - print " limit $self->{_limit}" if ( $self->{_limit} ); + print " limit $self->{_limit}" if ( $self->{_limit} ); + print " flows $self->{_flows}" if ( $self->{_flows} ); + print " target $self->{_target}" if ( $self->{_target} ); + print " interval $self->{_interval}" if ( $self->{_interval} ); + print " quantum $self->{_cquantum}" if ( $self->{_cquantum} ); print " noecn\n"; } diff --git a/templates/traffic-policy/fq-codel/node.tag/codel-quantum/node.def b/templates/traffic-policy/fq-codel/node.tag/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/fq-codel/node.tag/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/fq-codel/node.tag/flows/node.def b/templates/traffic-policy/fq-codel/node.tag/flows/node.def index 3d0e485..aff7f29 100644 --- a/templates/traffic-policy/fq-codel/node.tag/flows/node.def +++ b/templates/traffic-policy/fq-codel/node.tag/flows/node.def @@ -1,2 +1,2 @@ type: u32 -help: Number of flows (default 1024) +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/fq-codel/node.tag/interval/node.def b/templates/traffic-policy/fq-codel/node.tag/interval/node.def index 857bd62..a7d28b1 100644 --- a/templates/traffic-policy/fq-codel/node.tag/interval/node.def +++ b/templates/traffic-policy/fq-codel/node.tag/interval/node.def @@ -1,2 +1,2 @@ type: u32 -help: Interval (milliseconds) used to measure the delay (default 100) +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/fq-codel/node.tag/quantum/node.def b/templates/traffic-policy/fq-codel/node.tag/quantum/node.def deleted file mode 100644 index 49edde3..0000000 --- a/templates/traffic-policy/fq-codel/node.tag/quantum/node.def +++ /dev/null @@ -1,2 +0,0 @@ -type: u32 -help: Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/fq-codel/node.tag/target/node.def b/templates/traffic-policy/fq-codel/node.tag/target/node.def index d678f11..d9b4196 100644 --- a/templates/traffic-policy/fq-codel/node.tag/target/node.def +++ b/templates/traffic-policy/fq-codel/node.tag/target/node.def @@ -1,3 +1,3 @@ type: u32 -help: Acceptable minimum queue delay (milliseconds) +help: fq-codel - Acceptable minimum queue delay (milliseconds) diff --git a/templates/traffic-policy/priority-queue/node.tag/class/node.tag/codel-quantum/node.def b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/priority-queue/node.tag/class/node.tag/flows/node.def b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/priority-queue/node.tag/class/node.tag/interval/node.def b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/priority-queue/node.tag/class/node.tag/target/node.def b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/class/node.tag/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + diff --git a/templates/traffic-policy/priority-queue/node.tag/default/codel-quantum/node.def b/templates/traffic-policy/priority-queue/node.tag/default/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/default/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/priority-queue/node.tag/default/flows/node.def b/templates/traffic-policy/priority-queue/node.tag/default/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/default/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/priority-queue/node.tag/default/interval/node.def b/templates/traffic-policy/priority-queue/node.tag/default/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/default/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/priority-queue/node.tag/default/target/node.def b/templates/traffic-policy/priority-queue/node.tag/default/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/priority-queue/node.tag/default/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + diff --git a/templates/traffic-policy/round-robin/node.tag/class/node.tag/codel-quantum/node.def b/templates/traffic-policy/round-robin/node.tag/class/node.tag/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/class/node.tag/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/round-robin/node.tag/class/node.tag/flows/node.def b/templates/traffic-policy/round-robin/node.tag/class/node.tag/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/class/node.tag/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/round-robin/node.tag/class/node.tag/interval/node.def b/templates/traffic-policy/round-robin/node.tag/class/node.tag/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/class/node.tag/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/round-robin/node.tag/class/node.tag/target/node.def b/templates/traffic-policy/round-robin/node.tag/class/node.tag/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/class/node.tag/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + diff --git a/templates/traffic-policy/round-robin/node.tag/default/codel-quantum/node.def b/templates/traffic-policy/round-robin/node.tag/default/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/default/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/round-robin/node.tag/default/flows/node.def b/templates/traffic-policy/round-robin/node.tag/default/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/default/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/round-robin/node.tag/default/interval/node.def b/templates/traffic-policy/round-robin/node.tag/default/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/default/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/round-robin/node.tag/default/target/node.def b/templates/traffic-policy/round-robin/node.tag/default/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/round-robin/node.tag/default/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/codel-quantum/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/class/node.tag/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/flows/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/class/node.tag/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/interval/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/class/node.tag/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/target/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/class/node.tag/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + diff --git a/templates/traffic-policy/shaper/node.tag/default/codel-quantum/node.def b/templates/traffic-policy/shaper/node.tag/default/codel-quantum/node.def new file mode 100644 index 0000000..cb1efe3 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/default/codel-quantum/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of bytes used as 'deficit' (default 1514) diff --git a/templates/traffic-policy/shaper/node.tag/default/flows/node.def b/templates/traffic-policy/shaper/node.tag/default/flows/node.def new file mode 100644 index 0000000..aff7f29 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/default/flows/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Number of flows (default 1024) diff --git a/templates/traffic-policy/shaper/node.tag/default/interval/node.def b/templates/traffic-policy/shaper/node.tag/default/interval/node.def new file mode 100644 index 0000000..a7d28b1 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/default/interval/node.def @@ -0,0 +1,2 @@ +type: u32 +help: fq-codel - Interval (milliseconds) used to measure the delay (default 100) diff --git a/templates/traffic-policy/shaper/node.tag/default/target/node.def b/templates/traffic-policy/shaper/node.tag/default/target/node.def new file mode 100644 index 0000000..d9b4196 --- /dev/null +++ b/templates/traffic-policy/shaper/node.tag/default/target/node.def @@ -0,0 +1,3 @@ +type: u32 +help: fq-codel - Acceptable minimum queue delay (milliseconds) + -- cgit v1.2.3 From b9cfbe091e636b2bcdd35f2461a4f68c80e43e5e Mon Sep 17 00:00:00 2001 From: Carl Byington Date: Thu, 18 Dec 2014 09:24:47 -0800 Subject: fq-codel target and interval in milliseconds (#446) Signed-off-by: kouak --- lib/Vyatta/Qos/FairQueueCodel.pm | 4 ++++ lib/Vyatta/Qos/ShaperClass.pm | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Vyatta/Qos/FairQueueCodel.pm b/lib/Vyatta/Qos/FairQueueCodel.pm index 79c1f79..a6f4220 100644 --- a/lib/Vyatta/Qos/FairQueueCodel.pm +++ b/lib/Vyatta/Qos/FairQueueCodel.pm @@ -44,6 +44,10 @@ sub new { $self->{_target} = $config->returnValue('target'); $self->{_interval} = $config->returnValue('interval'); $self->{_cquantum} = $config->returnValue('codel-quantum'); + + if ( $self->{_target} ) { $self->{_target} *= 1000; } + if ( $self->{_interval} ) { $self->{_interval} *= 1000; } + return bless $self, $class; } diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index b4689b4..b0d6343 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -133,7 +133,7 @@ sub codelQdisc { my ( $self, $dev, $rate ) = @_; print "fq_codel"; - print " limit $self->{_limit}" if ( $self->{_limit} ); + print " limit $self->{_limit}" if ( $self->{_limit} ); print " flows $self->{_flows}" if ( $self->{_flows} ); print " target $self->{_target}" if ( $self->{_target} ); print " interval $self->{_interval}" if ( $self->{_interval} ); -- cgit v1.2.3 From 439206f1b4e4d9fb0feecaa43c6c9dc99c794e25 Mon Sep 17 00:00:00 2001 From: kouak Date: Thu, 26 Mar 2015 00:52:42 +0100 Subject: Remove small packets matching from fq-codel import (already fixed in #513) (#446) --- lib/Vyatta/Qos/Match.pm | 113 +++------------------ .../node.tag/match/node.tag/ip/small/node.def | 1 - .../node.tag/match/node.tag/ipv6/small/node.def | 1 - 3 files changed, 16 insertions(+), 99 deletions(-) delete mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ip/small/node.def delete mode 100644 templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ipv6/small/node.def (limited to 'lib') diff --git a/lib/Vyatta/Qos/Match.pm b/lib/Vyatta/Qos/Match.pm index 2b22c30..c8078b6 100644 --- a/lib/Vyatta/Qos/Match.pm +++ b/lib/Vyatta/Qos/Match.pm @@ -26,7 +26,7 @@ sub getPort { if ( $str =~ /^([0-9]+)|(0x[0-9a-fA-F]+)$/ ) { die "$str is not a valid port number\n" - if ( $str <= 0 || $str > 65535 ); + if ( $str <= 0 || $str > 65535 ); return $str; } @@ -47,8 +47,8 @@ sub new { # special case for match all unless ($config) { - $self->{'ether'} = { protocol => 'all' }; - return $self; + $self->{'ether'} = { protocol => 'all' }; + return $self; } foreach my $af (qw(ip ipv6 ether)) { @@ -88,7 +88,7 @@ sub new { } } - # if the hash is empty then we didn't generate a match rule + # if the hash is empty then we didn't generate a match rule # this usually means user left an uncompleted match in the config my @keys = keys(%fields); if ($#keys < 0) { @@ -120,82 +120,6 @@ sub new { return $self; } -sub small_ip_filter { - my ( $dev, $parent, $prio, $classid ) = @_; - my $protoip = "ip"; - my $synack = 2; # hash table id, arbitrary number - $parent = sprintf("%x", $parent); - $classid = sprintf("%x", $classid); - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32\n"; - # make a linked hash table - print "filter add dev $dev parent $parent: prior $prio protocol $protoip handle $synack: u32 divisor 1\n"; - # tcp syn bit - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32 ht $synack:"; - print " match u8 0x02 0x02 at 13"; - print " flowid $parent:$classid\n"; - # tcp ack bit - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32 ht $synack:"; - print " match u8 0x10 0x10 at 13"; - print " flowid $parent:$classid\n"; - # ipv4/icmp - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; - print " match ip protocol 1 0xff"; - print " flowid $parent:$classid\n"; - # ipv4/tcp, total len<256, tos=0x10 == minimum delay - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; - print " match ip protocol 6 0xff"; - print " match u16 0x0000 0xff00 at 2"; - print " match ip tos 0x10 0xff"; - print " flowid $parent:$classid\n"; - # ipv4/tcp, total len<128, not fragmented - print "filter add dev $dev parent $parent: prior $prio protocol $protoip u32"; - print " match ip protocol 6 0xff"; - print " match u16 0x0000 0xff80 at 2"; - print " match ip nofrag"; - print " offset at 0 mask 0x0f00 shift 6 eat"; - print " link $synack:\n"; -} - -sub small_ip6_filter { - my ( $dev, $parent, $prio, $classid ) = @_; - my $protoip6 = "ipv6"; - my $synack6 = 3; # hash table id, arbitrary number - $parent = sprintf("%x", $parent); - $classid = sprintf("%x", $classid); - # setup base filter - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32\n"; - # make a linked hash table - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 handle $synack6: u32 divisor 1\n"; - # tcp syn bit - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32 ht $synack6: "; - print " match u8 0x02 0x02 at 13"; - print " flowid $parent:$classid\n"; - # tcp ack bit - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32 ht $synack6:"; - print " match u8 0x10 0x10 at 13"; - print " flowid $parent:$classid\n"; - # ipv6/icmpv6 - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; - print " match ip6 protocol 58 0xff"; - print " flowid $parent:$classid\n"; - # ipv6/tcp, payload len<128, priority=0x10 == minimum delay - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; - print " match ip6 protocol 6 0xff"; - print " match u16 0x0000 0xff80 at 4"; - print " match ip6 priority 0x10 0xff"; - print " flowid $parent:$classid\n"; - # ipv6/tcp, payload len<64, not fragmented since the next header is a tcp header - # this does not handle packets with other ipv6 extension headers that might be - # present between the ipv6 header and the tcp header - print "filter add dev $dev parent $parent: prior $prio protocol $protoip6 u32"; - print " match ip6 protocol 6 0xff"; - print " match u16 0x0000 0xffc0 at 4"; - print " offset plus 40 eat"; - print " link $synack6:\n"; -} - - - sub filter { my ( $self, $dev, $parent, $classid, $prio, $dsmark, $police ) = @_; @@ -210,9 +134,9 @@ sub filter { next unless $ip && $$ip{dsfield}; printf "filter add dev %s parent %x: protocol %s prio %d", - $dev, $parent, $ipver, $prio; + $dev, $parent, $ipver, $prio; printf " handle %s tcindex classid %x:%x\n", - $$ip{dsfield}, $parent, $classid; + $$ip{dsfield}, $parent, $classid; $prio += 1; } @@ -224,18 +148,12 @@ sub filter { my $p = $self->{$proto}; next unless $p; - if (defined($$p{small})) { - small_ip_filter($dev, $parent, $prio, $classid) if ($proto eq 'ip'); - small_ip6_filter($dev, $parent, $prio, $classid) if ($proto eq 'ipv6'); - next; - } - printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; if ( $proto eq 'ether' ) { my $type = $$p{protocol}; $type = 'all' unless $type; - print " protocol $type u32"; + print " protocol $type u32"; if ( defined( $$p{src} ) || defined( $$p{dst} ) ) { print " match ether src $$p{src}" if $$p{src}; print " match ether dst $$p{dst}" if $$p{dst}; @@ -293,8 +211,8 @@ sub filter { } } - print " match mark $fwmark 0xff" if $fwmark; - print " $police" if $police; + print " match mark $fwmark 0xff" if $fwmark; + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; return; } @@ -303,17 +221,18 @@ sub filter { my $vif = $self->{_vif}; if ( defined($vif) || defined($indev) ) { printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; - print " protocol all basic"; - print " match meta\(rt_iif eq $indev\)" if $indev; - print " match meta\(vlan mask 0xfff eq $vif\)" if $vif; - print " match meta\(fwmark eq $fwmark\)" if $fwmark; - print " $police" if $police; + print " protocol all basic"; + print " match meta\(rt_iif eq $indev\)" if $indev; + print " match meta\(vlan mask 0xfff eq $vif\)" if $vif; + print " match meta\(fwmark eq $fwmark\)" if $fwmark; + + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; } elsif ($fwmark) { printf "filter add dev %s parent %x: prio %d", $dev, $parent, $prio; printf " protocol all handle %d fw", $fwmark; - print " $police" if $police; + print " $police" if $police; printf " flowid %x:%x\n", $parent, $classid; } } diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ip/small/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ip/small/node.def deleted file mode 100644 index 4321d9d..0000000 --- a/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ip/small/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Match on small ip packets diff --git a/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ipv6/small/node.def b/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ipv6/small/node.def deleted file mode 100644 index 8afbb67..0000000 --- a/templates/traffic-policy/shaper/node.tag/class/node.tag/match/node.tag/ipv6/small/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Match on small ipv6 packets -- cgit v1.2.3