Bug#640480: net-tools: netstat -s truncates 64bit counters, producing bogus output

Bjørn Mork bjorn at mork.no
Mon Sep 5 08:18:01 UTC 2011


Package: net-tools
Version: 1.60-24.1
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


netstat -s will mess up any number > 2^31.  


Example, input is:

bjorn at canardo:~$ tail -2 /proc/net/netstat 
IpExt: InNoRoutes InTruncatedPkts InMcastPkts OutMcastPkts InBcastPkts OutBcastPkts InOctets OutOctets InMcastOctets OutMcastOctets InBcastOctets OutBcastOctets
IpExt: 2 0 152463 40 2363641 84544 89530720060 449078447969 4692500 3059 717279980 6612480


Output becomes (not synchronized so counters are changed, but the pattern
should still be obvious):

bjorn at canardo:~$ netstat -s |sed -ne '/^IpExt/,$p'
IpExt:
    InNoRoutes: 2
    InMcastPkts: 152464
    OutMcastPkts: 40
    InBcastPkts: 2363664
    OutBcastPkts: 84545
    InOctets: -662600012
    OutOctets: -1810944975
    InMcastOctets: 4692532
    OutMcastOctets: 3059
    InBcastOctets: 717286964
    OutBcastOctets: 6612556


The attached patch fixes this for me, but may need some polishing to be
useful cross-platform...  The patch is based on top of the current Debian
package (1.60-24.1) with all other patches applied.



Bjørn



- -- System Information:
Debian Release: 6.0.2
  APT prefers stable
  APT policy: (700, 'stable'), (600, 'unstable'), (500, 'stable-updates'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages net-tools depends on:
ii  libc6                         2.11.2-10  Embedded GNU C Library: Shared lib

net-tools recommends no packages.

net-tools suggests no packages.

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk5khbcACgkQ10rqkowbIsllxQCfT+/JFd0oRnNDCpnT068uGM9i
YjYAnRKBmRIJPdQm0bXLi/pjKadEZtDG
=viuW
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: statistics.c-64bit.patch
Type: text/x-c
Size: 29832 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-net-tools-maintainers/attachments/20110905/5820b9e3/attachment-0001.bin>


More information about the Pkg-net-tools-maintainers mailing list