2002-09-29 19:51:01

by Erik Schoenfelder

[permalink] [raw]
Subject: [2.4.19] small bug plus fix for /proc/net/snmp (Imcp: field count)

Hi,

i received a bug report plus fix from Gonzalo A. Arana Tagle
<[email protected]> about a extra dummy value printed for the
``Icmp:'' values in /proc/net/snmp:

# awk '/Icmp/ { print NF; }' /proc/net/snmp
27
28

the code in snmp_get_info() from net/ipv4/proc.c prints a dummy value
present at the end of struct icmp_mib, which should not be included.

from include/net/snmp.h:

> struct icmp_mib
> {
> unsigned long IcmpInMsgs;
> [...]
> unsigned long IcmpOutAddrMaskReps;
> unsigned long dummy;
> unsigned long __pad[0];
> } ____cacheline_aligned;


instead of printing all values before the __pad field, printing the
values before the dummy field gives the right number of values:


--- linux-2.4.19/net/ipv4/proc.c-dist Wed May 16 19:21:45 2001
+++ linux-2.4.19/net/ipv4/proc.c Sat Sep 28 22:03:05 2002
@@ -128,7 +128,7 @@
len += sprintf (buffer + len,
"\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps\n"
"Icmp:");
- for (i=0; i<offsetof(struct icmp_mib, __pad)/sizeof(unsigned long); i++)
+ for (i=0; i<offsetof(struct icmp_mib, dummy)/sizeof(unsigned long); i++)
len += sprintf(buffer+len, " %lu", fold_field((unsigned long*)icmp_statistics, sizeof(struct icmp_mib), i));

len += sprintf (buffer + len,


please fix this. thank's in advance,
Erik