Red Hat Bugzilla – Bug 12852
ifconfig reports wrong packet statistics when they're greater than LONG_MAX
Last modified: 2008-05-01 11:37:56 EDT
When an interface statistic counter is greater than 2147483647 ifconfig
always reports the value of 2147483647 (LONG_MAX on i386). The reason of
this behavior is that the internal representation device statistic counter
in Linux device structure is an unsigned long and the ifconfig utility
reads the interface statistic counters from /proc/net/dev file system as a
string and then converts the textual representation into a long. The
conversion is done in function if_getstats()(ifconfig.c) by a call to
sscanf() function but with wrong conversion specification. The sscanf()
function is told to treat the string as a signed long (%ld) and it returns
the 2147483647 value for all strings that represent numbers exceeding the
range of long.
This has been fixed in upstream net-tools-1.58.