Skip to content

Commit

Permalink
net: fix length computation in rt_check_expire()
Browse files Browse the repository at this point in the history
rt_check_expire() computes average and standard deviation of chain lengths,
but not correclty reset length to 0 at beginning of each chain.
This probably gives overflows for sum2 (and sum) on loaded machines instead
of meaningful results.

Signed-off-by: Eric Dumazet <[email protected]>
Acked-by: Neil Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed May 21, 2009
1 parent bc8a539 commit cf8da76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static void rt_check_expire(void)
static unsigned int rover;
unsigned int i = rover, goal;
struct rtable *rth, **rthp;
unsigned long length = 0, samples = 0;
unsigned long samples = 0;
unsigned long sum = 0, sum2 = 0;
u64 mult;

Expand All @@ -795,9 +795,9 @@ static void rt_check_expire(void)
goal = (unsigned int)mult;
if (goal > rt_hash_mask)
goal = rt_hash_mask + 1;
length = 0;
for (; goal > 0; goal--) {
unsigned long tmo = ip_rt_gc_timeout;
unsigned long length;

i = (i + 1) & rt_hash_mask;
rthp = &rt_hash_table[i].chain;
Expand All @@ -809,6 +809,7 @@ static void rt_check_expire(void)

if (*rthp == NULL)
continue;
length = 0;
spin_lock_bh(rt_hash_lock_addr(i));
while ((rth = *rthp) != NULL) {
if (rt_is_expired(rth)) {
Expand Down

0 comments on commit cf8da76

Please sign in to comment.