From 8287f3e911b25ff83d7e0991da0006a14fd203f1 Mon Sep 17 00:00:00 2001 From: Nigel Kukard <nkukard@lbsd.net> Date: Fri, 17 Jan 2014 18:14:33 +0000 Subject: [PATCH] Fixed bug where tc id's were generated from count TC major/minor/filter ID's were being generated from hash table key count and not from a counter as they should of been. --- opentrafficshaper/plugins/tc/tc.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/opentrafficshaper/plugins/tc/tc.pm b/opentrafficshaper/plugins/tc/tc.pm index 0fcab66..dd42f57 100644 --- a/opentrafficshaper/plugins/tc/tc.pm +++ b/opentrafficshaper/plugins/tc/tc.pm @@ -257,6 +257,7 @@ sub _session_pool_add # Grab some things we need from the main pool my $txInterface = getPoolTxInterface($pool->{'ID'}); my $rxInterface = getPoolRxInterface($pool->{'ID'}); + # Grab effective config my $classID = $effectivePool->{'ClassID'}; my $trafficLimitTx = $effectivePool->{'TrafficLimitTx'}; @@ -804,6 +805,9 @@ sub _tc_iface_init 'root', ]); + # Initialize the major TC class + _reserveMajorTcClass($interface,"root"); + # Reserve our parent TC classes foreach my $classID (sort {$a <=> $b} keys %{$trafficClasses}) { # We don't really need the result, we just need the class created @@ -1522,6 +1526,8 @@ sub __reserveMinorTcClass # Setup defaults if we don't have anything defined if (!defined($tcClasses->{$interface}) || !defined($tcClasses->{$interface}->{$majorTcClass})) { $tcClasses->{$interface}->{$majorTcClass} = { + # Skip 0 and 1 + 'counter' => 2, 'free' => [ ], 'track' => { }, 'reverse' => { }, @@ -1533,8 +1539,7 @@ sub __reserveMinorTcClass # Generate new number if (!$minorTcClass) { - $minorTcClass = keys %{$tcClasses->{$interface}->{$majorTcClass}->{'track'}}; - $minorTcClass += 2; # Skip 0 and 1 + $minorTcClass = $tcClasses->{$interface}->{$majorTcClass}->{'counter'}++; # Hex it $minorTcClass = toHex($minorTcClass); } @@ -1555,6 +1560,8 @@ sub _reserveMajorTcClass # Setup defaults if we don't have anything defined if (!defined($tcClasses->{$interface})) { $tcClasses->{$interface} = { + # Skip 0 + 'counter' => 1, 'free' => [ ], 'track' => { }, 'reverse' => { }, @@ -1566,8 +1573,7 @@ sub _reserveMajorTcClass # Generate new number if (!$majorTcClass) { - $majorTcClass = keys %{$tcClasses->{$interface}->{'track'}}; - $majorTcClass += 2; # Skip 0 and 1 + $majorTcClass = $tcClasses->{$interface}->{'counter'}++; # Hex it $majorTcClass = toHex($majorTcClass); } @@ -1660,6 +1666,8 @@ sub _reserveTcFilter # Setup defaults if we don't have anything defined if (!defined($tcFilters->{$interface})) { $tcFilters->{$interface} = { + # Skip 0 and 1 + 'counter' => 2, 'free' => [ ], 'track' => { }, }; @@ -1670,11 +1678,9 @@ sub _reserveTcFilter # Generate new number if (!$filterID) { - $filterID = keys %{$tcFilters->{$interface}->{'track'}}; - # Bump ID - $filterID += 2; # Skip 0 and 1 + $filterID = $tcFilters->{$interface}->{'counter'}++; # We cannot use ID 800, its internal - $filterID = 801 if ($filterID == 800); + $filterID = $tcFilters->{$interface}->{'counter'}++ if ($filterID == 800); # Hex it $filterID = toHex($filterID); } -- GitLab