From 844f6c63e49178d576088b898976271aff6457a3 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 11 Jun 2012 15:45:47 -0700 Subject: [PATCH] Add support for TC size tables. Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Tc.pm | 46 ++++++++++++++++++-- Shorewall/manpages/shorewall-tcdevices.xml | 38 +++++++++++++++- Shorewall6/manpages/shorewall6-tcdevices.xml | 38 +++++++++++++++- 3 files changed, 116 insertions(+), 6 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm index 832793961..994a111a9 100644 --- a/Shorewall/Perl/Shorewall/Tc.pm +++ b/Shorewall/Perl/Shorewall/Tc.pm @@ -853,6 +853,8 @@ sub process_simple_device() { progress_message " Simple tcdevice \"$currentline\" $done."; } +my %validlinklayer = ( ethernet => 1, atm => 1, adsl => 1 ); + sub validate_tc_device( ) { my ( $device, $inband, $outband , $options , $redirected ) = split_line 'tcdevices', { interface => 0, in_bandwidth => 1, out_bandwidth => 2, options => 3, redirect => 4 }; @@ -887,7 +889,8 @@ sub validate_tc_device( ) { fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device}; fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/; - my ( $classify, $pfifo, $flow, $qdisc ) = (0, 0, '', 'htb' ); + my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize ) = + (0, 0, '', 'htb', '', 0, 0, 0, 0); if ( $options ne '-' ) { for my $option ( split_list1 $options, 'option' ) { @@ -903,6 +906,25 @@ sub validate_tc_device( ) { $qdisc = 'hfsc'; } elsif ( $option eq 'htb' ) { $qdisc = 'htb'; + } elsif ( $option =~ /^linklayer=([a-z]+)$/ ) { + $linklayer = $1; + fatal_error "Invalid linklayer ($linklayer)" unless $validlinklayer{ $linklayer }; + } elsif ( $option =~ /^overhead=(.+)$/ ) { + $overhead = numeric_value( $1 ); + fatal_error "Invalid overhead ($1)" unless defined $overhead; + fatal_error q('overhead' requires 'linklayer') unless $linklayer; + } elsif ( $option =~ /^mtu=(.+)$/ ) { + $mtu = numeric_value( $1 ); + fatal_error "Invalid mtu ($1)" unless defined $mtu; + fatal_error q('mtu' requires 'linklayer') unless $linklayer; + } elsif ( $option =~ /^mpu=(.+)$/ ) { + $mpu = numeric_value( $1 ); + fatal_error "Invalid mpu ($1)" unless defined $mpu; + fatal_error q('mpu' requires 'linklayer') unless $linklayer; + } elsif ( $option =~ /^tsize=(.+)$/ ) { + $tsize = numeric_value( $1 ); + fatal_error "Invalid tsize ($1)" unless defined $tsize; + fatal_error q('tsize' requires 'linklayer') unless $linklayer; } else { fatal_error "Unknown device option ($option)"; } @@ -941,7 +963,12 @@ sub validate_tc_device( ) { guarantee => 0, name => $device, physical => physical_name $device, - filters => [] + filters => [], + linklayer => $linklayer, + overhead => $overhead, + mtu => $mtu, + mpu => $mpu, + tsize => $tsize, } , push @tcdevices, $device; @@ -1711,11 +1738,22 @@ sub process_traffic_shaping() { "${dev}_mtu1=\$(get_device_mtu1 $device)" ); + my $stab; + + if ( $linklayer ) { + $stab = "stab linklayer $devref->{linklayer} overhead $devref->{overhead} "; + $stab .= "mtu $devref->{mtu} " if $devref->{mtu}; + $stab .= "mpu $devref->{mpu} " if $devref->{mpu}; + $stab .= "mpu $devref->{tsize} " if $devref->{tsize}; + } else { + $stab = ''; + } + if ( $devref->{qdisc} eq 'htb' ) { - emit ( "run_tc qdisc add dev $device root handle $devnum: htb default $defmark r2q $r2q" , + emit ( "run_tc qdisc add dev $device ${stab}root handle $devnum: htb default $defmark r2q $r2q" , "run_tc class add dev $device parent $devnum: classid $devnum:1 htb rate $devref->{out_bandwidth} \$${dev}_mtu1" ); } else { - emit ( "run_tc qdisc add dev $device root handle $devnum: hfsc default $defmark" , + emit ( "run_tc qdisc add dev $device ${stab}root handle $devnum: hfsc default $defmark" , "run_tc class add dev $device parent $devnum: classid $devnum:1 hfsc sc rate $devref->{out_bandwidth} ul rate $devref->{out_bandwidth}" ); } diff --git a/Shorewall/manpages/shorewall-tcdevices.xml b/Shorewall/manpages/shorewall-tcdevices.xml index 421205637..d78912703 100644 --- a/Shorewall/manpages/shorewall-tcdevices.xml +++ b/Shorewall/manpages/shorewall-tcdevices.xml @@ -179,7 +179,17 @@ OPTIONS - {-|{classify|hfsc} ,...} + role="bold">{classify|hfsc|linklayer={ethernet|atm|adsl}|tsize=tsize|mtu=mtu|mpu=mpu|overhead=overhead} + ,...} ― When specified, Shorewall will not @@ -191,6 +201,32 @@ Hierarchical Token Bucket queuing discipline. When is specified, the Hierarchical Fair Service Curves discipline is used instead. + + linklayer - Added in + Shorewall 4.5.6. Type of link (ethernet, atm, adsl). When specified, + causes scheduler packet size manipulation as described in tc-stab + (8). When this option is given, the following options may also be + given after it: + +
+ mtu=mtu - The + device MTU; default 2048 (will be routed up to a power of + two) + + mpu=mpubytes - + Minimum packet size used in calculations. Smaller packets will be + routed up to this size + + tsize=tablesize + - Size table entries; default is 512 + + overhead=overheadbytes + - Number of overhead bytes per packet. +
diff --git a/Shorewall6/manpages/shorewall6-tcdevices.xml b/Shorewall6/manpages/shorewall6-tcdevices.xml index b67ae57f4..1e89bca67 100644 --- a/Shorewall6/manpages/shorewall6-tcdevices.xml +++ b/Shorewall6/manpages/shorewall6-tcdevices.xml @@ -180,7 +180,17 @@ OPTIONS - {-|{classify|hfsc} ,...} + role="bold">{classify|hfsc|linklayer={ethernet|atm|adsl}|tsize=tsize|mtu=mtu|mpu=mpu|overhead=overhead} + ,...} ― When specified, Shorewall will not @@ -192,6 +202,32 @@ Hierarchical Token Bucket queuing discipline. When is specified, the Hierarchical Fair Service Curves discipline is used instead. + + linklayer - Added in + Shorewall 4.5.6. Type of link (ethernet, atm, adsl). When specified, + causes scheduler packet size manipulation as described in tc-stab + (8). When this option is given, the following options may also be + given after it: + +
+ mtu=mtu - The + device MTU; default 2048 (will be routed up to a power of + two) + + mpu=mpubytes - + Minimum packet size used in calculations. Smaller packets will be + routed up to this size + + tsize=tablesize + - Size table entries; default is 512 + + overhead=overheadbytes + - Number of overhead bytes per packet. +