From 329655cc66d8ba9a060b6272bbb81a487b8a4e75 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 2 Mar 2011 07:34:55 -0800 Subject: [PATCH] Make burst in tcdevices IN-BANDWIDTH column work --- Shorewall/Perl/Shorewall/Tc.pm | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm index 3a8ea18c2..490ffee5b 100644 --- a/Shorewall/Perl/Shorewall/Tc.pm +++ b/Shorewall/Perl/Shorewall/Tc.pm @@ -652,7 +652,22 @@ sub validate_tc_device( ) { } } - $tcdevices{$device} = { in_bandwidth => rate_to_kbit( $inband ) . 'kbit', + my $in_burst = '10kb'; + + if ( $inband =~ /:/ ) { + my ( $in_band, $burst ) = split /:/, $inband, 2; + + if ( defined $burst && $burst ne '' ) { + fatal_error "Invalid IN-BANDWIDTH" if $burst =~ /:/; + fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(k|kb|m|mb|mbit|kbit|b)?$/; + $in_burst = $burst; + } + + $inband = $in_band; + } + + $tcdevices{$device} = { in_bandwidth => rate_to_kbit( $inband ), + in_burst => $in_burst, out_bandwidth => rate_to_kbit( $outband ) . 'kbit', number => $devnumber, classify => $classify, @@ -1378,26 +1393,9 @@ sub setup_traffic_shaping() { qq(fi) ); } - my $in_burst = '10kb'; - my $inband; - - if ( $devref->{in_bandwidth} =~ /:/ ) { - my ( $in_band, $burst ) = split /:/, $devref->{in_bandwidth}, 2; - - if ( defined $burst && $burst ne '' ) { - fatal_error "Invalid IN-BANDWIDTH" if $burst =~ /:/; - fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(k|kb|m|mb|mbit|kbit|b)?$/; - $in_burst = $burst; - } - - $inband = rate_to_kbit( $in_band ); - } else { - $inband = rate_to_kbit $devref->{in_bandwidth}; - } - - if ( $inband ) { + if ( $devref->{in_bandwidth} ) { emit ( "run_tc qdisc add dev $device handle ffff: ingress", - "run_tc filter add dev $device parent ffff: protocol all prio 10 u32 match ip src 0.0.0.0/0 police rate ${inband}kbit burst $in_burst drop flowid :1" + "run_tc filter add dev $device parent ffff: protocol all prio 10 u32 match ip src 0.0.0.0/0 police rate $devref->{in_bandwidth}kbit burst $devref->{in_burst} drop flowid :1" ); }