Bug 183598

Summary: [patch] netstat(1): wrong display of humanized packets counter
Product: Base System Reporter: olivier
Component: binAssignee: Gavin Atkinson <gavin>
Status: Closed FIXED    
Severity: Affects Only Me CC: hrs
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
netstat.patch.txt none

Description olivier 2013-11-02 18:30:00 UTC
1K packets = 1000 packets and not 1024 packets.

But netstat "-h" option convert 1024 packets to 1k packets.

In usr.bin/netstat/if.c, function show_stat() should call humanize_number() with the flag HN_DIVISOR_1000 for the packet counters.

How-To-Repeat: Here is the netstat output without and with the "h" option during receiving the same network load:

[root@bsdrp2]~# netstat -iw 1
            input        (Total)           output
   packets  errs idrops      bytes    packets  errs      bytes colls
    499963 244305     0   50996154          3     0        690     0
    500346 214356     0   51035256          1     0        214     0
    500937 257107     0   51095538          2     0        280     0
    500167 187844     0   51016890          4     0       2744     0
    499605 208954     0   50959638          3     0        546     0
    499915 203059     0   50991258          2     0       2188     0
    499355 183496     0   50934174          1     0        214     0
    499843 197301     0   50983950          1     0        214     0
    500193 211267     0   51020086          1     0        214     0
    500233 243838     0   51023730          1     0        214     0
    499386 238562     0   50937336          1     0        214     0
    499577 235335     0   50956818          1     0        214     0
[root@bsdrp2]~# netstat -ihw 1
            input        (Total)           output
   packets  errs idrops      bytes    packets  errs      bytes colls
      489k  185k     0        48M          1     0        262     0
      488k  196k     0        48M          1     0        214     0
      489k  200k     0        48M          1     0        214     0
      489k  193k     0        48M          1     0        214     0
      488k  200k     0        48M          1     0        214     0
      489k  196k     0        48M          1     0        214     0
      487k  189k     0        48M          1     0        214     0
      489k  195k     0        48M          1     0        214     0
      488k  191k     0        48M          1     0        214     0
      488k  192k     0        48M          5     0       2.8k     0
Comment 1 olivier 2014-10-13 21:50:22 UTC
The patch fix counters "input errs" and " output errs" too.
Comment 2 Hiroki Sato freebsd_committer freebsd_triage 2015-09-01 09:04:26 UTC
Gavin: are you still working on this PR?  If you do not mind, I want to fix this problem.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-09-02 18:43:30 UTC
A commit references this bug:

Author: hrs
Date: Wed Sep  2 18:42:36 UTC 2015
New revision: 287406
URL: https://svnweb.freebsd.org/changeset/base/287406

Log:
  Divide statistics in the number of packets with 1000 instead of 1024
  in human-readable form.

  PR:	183598

Changes:
  head/usr.bin/netstat/if.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-09-09 08:40:51 UTC
A commit references this bug:

Author: hrs
Date: Wed Sep  9 08:40:18 UTC 2015
New revision: 287593
URL: https://svnweb.freebsd.org/changeset/base/287593

Log:
  MFC r287406:

  Divide statistics in the number of packets with 1000 instead of 1024
  in human-readable form.

  PR:	183598

Changes:
_U  stable/10/
  stable/10/usr.bin/netstat/if.c
Comment 5 Hiroki Sato freebsd_committer freebsd_triage 2015-09-09 08:42:52 UTC
Committed to head and stable/10.  Thank you for your report!