[NET]: Corrects a bug in ip_rt_acct_read()
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b242e891c2
commit
483b23ffa3
@@ -2888,18 +2888,14 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
|
|||||||
offset /= sizeof(u32);
|
offset /= sizeof(u32);
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset;
|
|
||||||
u32 *dst = (u32 *) buffer;
|
u32 *dst = (u32 *) buffer;
|
||||||
|
|
||||||
/* Copy first cpu. */
|
|
||||||
*start = buffer;
|
*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) {
|
for_each_possible_cpu(i) {
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
|
||||||
src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
|
|
||||||
|
|
||||||
for (j = 0; j < length/4; j++)
|
for (j = 0; j < length/4; j++)
|
||||||
dst[j] += src[j];
|
dst[j] += src[j];
|
||||||
|
Reference in New Issue
Block a user