Commit 6d35bbea authored by David S. Miller's avatar David S. Miller

[IPV4]: Fix ip_rt_acct reading.

parent 8b1309d9
...@@ -2605,17 +2605,28 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset, ...@@ -2605,17 +2605,28 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
*eof = 1; *eof = 1;
} }
offset /= sizeof(u32);
if (length > 0) {
u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset;
u32 *dst = (u32 *) buffer;
/* Copy first cpu. */ /* Copy first cpu. */
*start = buffer; *start = buffer;
memcpy(buffer, IP_RT_ACCT_CPU(0), length); memcpy(dst, src, length);
/* Add the other cpus in, one int at a time */ /* Add the other cpus in, one int at a time */
for (i = 1; i < NR_CPUS; i++) { for (i = 1; i < NR_CPUS; i++) {
unsigned int j; unsigned int j;
if (!cpu_online(i)) if (!cpu_online(i))
continue; continue;
src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
for (j = 0; j < length/4; j++) for (j = 0; j < length/4; j++)
((u32*)buffer)[j] += ((u32*)IP_RT_ACCT_CPU(i))[j]; dst[j] += src[j];
}
} }
return length; return length;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment