]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
NET: Corrects a bug in ip_rt_acct_read()
authorEric Dumazet <dada1@cosmosbay.com>
Thu, 29 Nov 2007 12:07:57 +0000 (23:07 +1100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 14 Dec 2007 18:31:58 +0000 (10:31 -0800)
[NET]: Corrects a bug in ip_rt_acct_read()

[ Upstream commit: 483b23ffa3a5f44767038b0a676d757e0668437e ]

It seems that stats of cpu 0 are counted twice, since
for_each_possible_cpu() is looping on all possible cpus, including 0

Before percpu conversion of ip_rt_acct, we should also remove the
assumption that CPU 0 is online (or even possible)

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/ipv4/route.c

index 29ca63e81ced23877fe568573b8522e0ce16d8a1..4aa25518b60fa8e94ada8f02b680224e5d55b890 100644 (file)
@@ -3150,18 +3150,14 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
        offset /= sizeof(u32);
 
        if (length > 0) {
-               u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset;
                u32 *dst = (u32 *) buffer;
 
-               /* Copy first cpu. */
                *start = buffer;
-               memcpy(dst, src, length);
+               memset(dst, 0, length);
 
-               /* Add the other cpus in, one int at a time */
                for_each_possible_cpu(i) {
                        unsigned int j;
-
-                       src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
+                       u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
 
                        for (j = 0; j < length/4; j++)
                                dst[j] += src[j];