Radosław Łoboda
2013-Nov-14 23:10 UTC
Possible bug: TC with HFSC fails to load if umax is not provided
I stumbled upon a problem while upgrading Ubuntu 13.04, Shorewall version
from 4.4.26.1 to 4.5.16.1.
Everything was working fine before, after upgrading the script wouldn''t
start.
First some config files.
tcdevices:
#INTERFACE IN-BANDWIDTH OUT-BANDWIDTH OPTIONS REDIRECTED
eth1 - 6300kbit hfsc,classify
ifb0 - 6300kbit hfsc eth1
tcclasses:
#INTERFACE MARK RATE(:DMAX:UMAX) CEIL PRIORITY OPTIONS
ifb0:110 - full/4:50 full/2 1
tcp-ack,tos-minimize-delay
ifb0:130 - full/2 full*9/10 3 flow=nfct-dst
ifb0:140 - full/4 full*9/10 4 default,flow=nfct-dst
eth1:110 - full/4:50 full/2 1
tcp-ack,tos-minimize-delay
eth1:120 - full*3/4 full*9/10 2 default,flow=nfct-src
After upgrading I was getting this message in my log:
Nov 14 13:42:42 Setting up Traffic Control...
HFSC: Illegal "umax"
HFSC: Illegal "sc"
ERROR: Command "tc class add dev eth1 parent 1:1 classid 1:110 hfsc sc
umax b dmax 150ms rate 1575kbit ul rate 3150kbit" Failed
After some investigation of /var/lib/shorewall/firewall I found the above
line to be:
run_tc class add dev eth1 parent 1:1 classid 1:110 hfsc sc umax
${eth1_mtu}b dmax 150ms rate 1550kbit ul rate 3100kbit
But eth1_mtu was not defined anywhere! Hence it was getting the parmeter
"umax b" where it should apparently say "umax 1500b".
In the file generated by older version - /var/lib/shorewall/restore, just a
few lines above run_tc line was this one:
eth1_mtu=$(get_device_mtu eth1)
which was now missing in output from new version.
Going further:
/usr/share/shorewall/Shorewall/Tc.pm line 2167:
emit ( "${dev}_mtu=\$(get_device_mtu $device)",
"${dev}_mtu1=\$(get_device_mtu1 $device)"
) if $qdisc eq ''htb'';
/usr/share/shorewall/Shorewall/Tc.pm line 2242:
if ( $devref->{qdisc} eq ''htb'' ) {
$quantum = calculate_quantum $rate, calculate_r2q(
$devref->{out_bandwidth} );
emit ( "[ \$${dev}_mtu -gt $quantum ] && quantum=\$${dev}_mtu
||
quantum=$quantum" );
emit ( "run_tc class add dev $device parent $devicenumber:$parent
classid $classid htb rate $rate ceil $tcref->{ceiling}kbit prio
$tcref->{priority} \$${dev}_mtu1 quantum \$quantum" );
} else {
my $dmax = $tcref->{dmax};
my $rule = "run_tc class add dev $device parent $devicenumber:$parent
classid $classid hfsc";
if ( $dmax ) {
my $umax = $tcref->{umax} ? "$tcref->{umax}b" :
"\${${dev}_mtu}b";
$rule .= " sc umax $umax dmax ${dmax}ms";
$rule .= " rate $rate" if $rawrate;
} else {
$rule .= " sc rate $rate" if $rawrate;
}
$rule .= " ls rate ${lsceil}kbit" if $lsceil;
$rule .= " ul rate $tcref->{ceiling}kbit" if
$tcref->{ceiling};
emit $rule;
}
It appears that ${dev}_mtu line should be emitted for hfsc as well as for
htb. The above bug renders umax value in tcclasses MANDATORY when you
provide dmax value.
--
Radosław Łoboda
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
Tom Eastep
2013-Nov-16 16:09 UTC
Re: Possible bug: TC with HFSC fails to load if umax is not provided
On 11/14/2013 3:10 PM, Radosław Łoboda wrote:> > It appears that ${dev}_mtu line should be emitted for hfsc as well as for > htb. The above bug renders umax value in tcclasses MANDATORY when you > provide dmax value. >Tested patch attached. It applies with an offset to 4.5.16.1. Thanks! -Tom -- Tom Eastep \ When I die, I want to go like my Grandfather who Shoreline, \ died peacefully in his sleep. Not screaming like Washington, USA \ all of the passengers in his car http://shorewall.net \________________________________________________ ------------------------------------------------------------------------------ DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk