Some experimental changes to TC

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5883 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-04-10 00:12:27 +00:00
parent 1414963501
commit 64e17a716d
2 changed files with 19 additions and 12 deletions

View File

@ -249,23 +249,29 @@ my %tcdevices;
my @tcclasses;
my %tcclasses;
my $r2q = 10;
my $prefix = '1';
sub rate_to_kbit( $ ) {
my $rate = $_[0];
return $1 if $rate =~ /^(\d+)kbit$/i;
return $1 * 1024 if $rate =~ /^(\d+)mbit$/i;
return $1 * 8192 if $rate =~ /^(\d+)mbps$/i;
return $1 * 1000 if $rate =~ /^(\d+)mbit$/i;
return $1 * 8000 if $rate =~ /^(\d+)mbps$/i;
return $1 * 8 if $rate =~ /^(\d+)kbps$/i;
return $rate / 128 if $rate =~ /^\d+$/;
return $rate / 125 if $rate =~ /^\d+$/;
fatal_error "Invalid Rate ( $rate )";
}
sub calculate_quantum( $ ) {
sub calculate_r2q( $ ) {
my $rate = rate_to_kbit $_[0];
eval "int( ( $rate * 128 ) / $r2q )";
my $r2q= $rate / 200 ;
$r2q <= 5 ? 5 : $r2q;
}
sub calculate_quantum( $$ ) {
my ( $rate, $r2q ) = @_;
$rate = rate_to_kbit $rate;
eval "int( ( $rate * 125 ) / $r2q )";
}
sub validate_tc_device( $$$ ) {
@ -395,9 +401,9 @@ sub setup_traffic_shaping() {
for my $device ( @tcdevices ) {
my $dev = chain_base( $device );
my $devref = $tcdevices{$device};
my $defmark = $devref->{default};
my $defmark = $devref->{default} || 0;
fatal_error "Option default is not defined for any class in tcclasses for interface $device" unless $defmark;
$defmark = "${prefix}${defmark}" if $defmark;
emit "if interface_is_usable $device; then";
@ -406,7 +412,7 @@ sub setup_traffic_shaping() {
emitj( "${dev}_exists=Yes",
"qt tc qdisc del dev $device root",
"qt tc qdisc del dev $device ingress",
"run_tc qdisc add dev $device root handle $devnum: htb default ${prefix}${defmark}",
"run_tc qdisc add dev $device root handle $devnum: htb default $defmark",
"${dev}_mtu=\$(get_device_mtu $device)",
"run_tc class add dev $device parent $devnum: classid $devnum:1 htb rate $devref->{out_bandwidth} mtu \$${dev}_mtu"
);
@ -442,7 +448,8 @@ sub setup_traffic_shaping() {
my $devnum = $devref->{number};
my $classid = "$devnum:${prefix}${mark}";
my $rate = $tcref->{rate};
my $quantum = calculate_quantum $rate;
my $r2q = calculate_r2q $devref->{out_bandwidth};
my $quantum = calculate_quantum $rate, $r2q;
my $dev = chain_base $device;
if ( $lastdevice ne $device ) {

View File

@ -26,12 +26,12 @@ old (see below), migration to the new compiler must be voluntary.
c) By allowing Shorewall-perl to co-exist with the current Shorewall stable
release (3.4), I'm hoping that the new compiler will get more testing and
validation than it would if I were to package it with a new development
validation than it would if I were to package it only with a new development
version of Shorewall itself.
d) Along the same vein, I think that users will be more likely to experiment
with the new compiler if they can easily fall back to the old one if things
get sticky.
get sticky (I know that it has been handy for me ;-) )
----------------------------------------------------------------------------
T H E G O O D N E W S:
----------------------------------------------------------------------------