snmp: 64bit ipstats_mib for all arches
/proc/net/snmp and /proc/net/netstat expose SNMP counters. Width of these counters is either 32 or 64 bits, depending on the size of "unsigned long" in kernel. This means user program parsing these files must already be prepared to deal with 64bit values, regardless of user program being 32 or 64 bit. This patch introduces 64bit snmp values for IPSTAT mib, where some counters can wrap pretty fast if they are 32bit wide. # netstat -s|egrep "InOctets|OutOctets" InOctets: 244068329096 OutOctets: 244069348848 Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
f3eb62d2cc
commit
4ce3c183fc
@@ -343,10 +343,12 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
|
||||
IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2,
|
||||
sysctl_ip_default_ttl);
|
||||
|
||||
BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0);
|
||||
for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
|
||||
seq_printf(seq, " %lu",
|
||||
snmp_fold_field((void __percpu **)net->mib.ip_statistics,
|
||||
snmp4_ipstats_list[i].entry));
|
||||
seq_printf(seq, " %llu",
|
||||
snmp_fold_field64((void __percpu **)net->mib.ip_statistics,
|
||||
snmp4_ipstats_list[i].entry,
|
||||
offsetof(struct ipstats_mib, syncp)));
|
||||
|
||||
icmp_put(seq); /* RFC 2011 compatibility */
|
||||
icmpmsg_put(seq);
|
||||
@@ -432,9 +434,10 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
|
||||
|
||||
seq_puts(seq, "\nIpExt:");
|
||||
for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++)
|
||||
seq_printf(seq, " %lu",
|
||||
snmp_fold_field((void __percpu **)net->mib.ip_statistics,
|
||||
snmp4_ipextstats_list[i].entry));
|
||||
seq_printf(seq, " %llu",
|
||||
snmp_fold_field64((void __percpu **)net->mib.ip_statistics,
|
||||
snmp4_ipextstats_list[i].entry,
|
||||
offsetof(struct ipstats_mib, syncp)));
|
||||
|
||||
seq_putc(seq, '\n');
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user