Bug 184626

Summary: [wlan] wlan0 missing some ifmib(4) data, specifically ifi_obytes/output bytes
Product: Base System Reporter: Marcus Reid <marcus>
Component: wirelessAssignee: Andrey V. Elsukov <ae>
Status: Closed FIXED    
Severity: Affects Many People CC: ae, bhughes, cmb, grembo, mjl, woodsb02
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Marcus Reid 2013-12-09 10:20:01 UTC
Some ifmib(4) data, secifically ifi_obytes from the if_data structure (see ifnet(9)) appears to be missing from wlan0. For example, 'netstat -I wlan0 1' reports that 0 bytes are received per second.  It does report the packets per second though.  The situation seems to be reversed for iwn0 (the parent interface of wlan0) except that both (incoming) pps and bps are missing.

Aside from netstat, there are other consumers of this info, like gui network monitors, etc.

How-To-Repeat: netstat -I wlan0 1
netstat -I iwn0 1
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-12-10 02:04:28 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-wireless

Over to maintainer(s).
Comment 2 Ben Woods freebsd_committer freebsd_triage 2014-10-13 15:03:08 UTC
I am also experiencing this issue on FreeBSD 10.1-BETA3.

In case it matters, here is the output of pciconf -lv:
iwn0@pci0:4:0:0:        class=0x028000 card=0x50058086 chip=0x08968086 rev=0x34 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Centrino Wireless-N 130'
    class      = network

This is causing my netstat and vnstat to show zero transmitted data. Here is my vnstat output:

Database updated: Mon Oct 13 22:58:27 2014

   wlan0 since 09/23/14

          rx:  3.02 GiB      tx:  0 KiB      total:  3.02 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Sep '14    625.97 MiB |       0 KiB |  625.97 MiB |    1.98 kbit/s
       Oct '14      2.41 GiB |       0 KiB |    2.41 GiB |   18.03 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated        --     |      --     |      --     |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     yesterday     67.82 MiB |       0 KiB |   67.82 MiB |    6.43 kbit/s
         today    106.92 MiB |       0 KiB |  106.92 MiB |   10.59 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated        --     |      --     |      --     |
Comment 3 Ben Woods freebsd_committer freebsd_triage 2014-10-14 23:48:04 UTC
I was having this issue when testing the FreeBSD 10.1RC1 uefi memstick installer, and could never get the kernel load messages to appear on my screen (although I believe it was booted in the background as I could hear disk activity and a ctrl+alt+delete successfully rebooted the laptop. Haven't tested with 10.1RC2 yet, but the announcement didn't mention it was fixed.

I have a MacBook Pro mid-2010 edition (nvidia graphics).

How can I help troubleshoot further? Is there a chance we could get this resolved for 10.1 release?
Comment 4 Ben Woods freebsd_committer freebsd_triage 2014-10-14 23:52:28 UTC
Please ignore the above comment at 2014-10-14 23:48:04 UTC as I was posting on the wrong bug! My previous comment showing vnstat issues with iwn0 is still valid (Experienced on my NON-macbook home theater PC hardware).
Comment 5 Marcus Reid 2014-10-15 18:14:08 UTC
This bug still exists in -CURRENT, and affects my new wireless interface in the same way (I've got an rsu now). This would suggest it's not a hardware quirk or specific to the iwn driver.
Comment 6 Bradley T. Hughes freebsd_committer freebsd_triage 2014-11-16 22:09:57 UTC
I am also seeing this, using the ath(4) driver instead of iwn(4):

$ netstat -bi
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
...
ath0   2290 <Link#2>      24:0a:64:1b:52:7c 17671612 809581     0          0 18787865     1          0     0
...
wlan0  1500 <Link#5>      24:0a:64:1b:52:7c 17614982     5     0 14663416432 18806620    51          0     0
...

Odd that Ibytes are reported, but not Obytes?
Comment 7 Bradley T. Hughes freebsd_committer freebsd_triage 2014-11-16 22:10:38 UTC
(In reply to Bradley T. Hughes from comment #6)
> I am also seeing this, using the ath(4) driver instead of iwn(4):

Forgot to mention, this is on a 10.1-RELEASE amd64 host.
Comment 8 cmb 2014-11-22 21:10:03 UTC
Confirmed issue, also seeing this myself on multiple systems, and others have reported same. 

We have a bug ticket on this as well: https://redmine.pfsense.org/issues/4028
Where the version that's referring to is the same as stock FreeBSD 10.1 in this regard. It looks to be a regression in all FreeBSD 10.x versions. 

I've only tested with ath(4) cards because that's all I have handy, but appears generic to all wifi judging by others' reports here.
Comment 9 Michael Gmelin freebsd_committer freebsd_triage 2015-01-24 22:04:27 UTC
*** Bug 197057 has been marked as a duplicate of this bug. ***
Comment 10 Michael Gmelin freebsd_committer freebsd_triage 2015-01-24 22:09:46 UTC
Changed subject to make it easier to find and set to "affects many people".
Comment 11 commit-hook freebsd_committer freebsd_triage 2015-05-23 09:49:45 UTC
A commit references this bug:

Author: ae
Date: Sat May 23 09:49:41 UTC 2015
New revision: 283313
URL: https://svnweb.freebsd.org/changeset/base/283313

Log:
  Properly update TX statistics for wlan(4).
  ieee80211_pwrsave() can fail due to queue overflow, check its return code
  and increment oerrors counter when it fails. Also handle more error cases
  and update oerrors counter when we don't send mbuf due to some errors.
  Return ENETDOWN when parent interface isn't ready. Update obytes and omcasts
  counters in corresponding places.

  PR:		184626
  Differential Revision:	https://reviews.freebsd.org/D2621
  Reviewed by:	adrian
  MFC after:	1 week

Changes:
  head/sys/net80211/ieee80211_output.c
  head/sys/net80211/ieee80211_wds.c
Comment 12 Ben Woods freebsd_committer freebsd_triage 2015-05-23 09:54:36 UTC
Thank you very much for taking the time to investigate and fix this Andrey - I really appreciate it!
Comment 13 Marcus Reid 2015-05-25 19:49:10 UTC
Thank you! The more annoying part of this bug is now fixed. "ifconfig -I wlan0 -i 1" now has plausible looking counters. However, the parent interface still has zeroes on the input side. "ifconfig -I iwn0 -i 1" to reproduce that one.
Comment 14 Andrey V. Elsukov freebsd_committer freebsd_triage 2015-05-26 12:37:18 UTC
(In reply to Marcus Reid from comment #13)
> Thank you! The more annoying part of this bug is now fixed. "ifconfig -I
> wlan0 -i 1" now has plausible looking counters. However, the parent
> interface still has zeroes on the input side. "ifconfig -I iwn0 -i 1" to
> reproduce that one.

It looks like each driver should be fixed to do proper accounting. But in 11.0-CURRENT there is work in progress, that will lead to removing ifnet statistics from parent interfaces. And fixing this now will conflicts with these changes.
Comment 15 commit-hook freebsd_committer freebsd_triage 2015-05-31 23:29:45 UTC
A commit references this bug:

Author: ae
Date: Sun May 31 23:29:05 UTC 2015
New revision: 283855
URL: https://svnweb.freebsd.org/changeset/base/283855

Log:
  MFC r283313:
    Properly update TX statistics for wlan(4).
    ieee80211_pwrsave() can fail due to queue overflow, check its return code
    and increment oerrors counter when it fails. Also handle more error cases
    and update oerrors counter when we don't send mbuf due to some errors.
    Return ENETDOWN when parent interface isn't ready. Update obytes and omcasts
    counters in corresponding places.

  PR:		184626
  Differential Revision:	https://reviews.freebsd.org/D2621

Changes:
_U  stable/10/
  stable/10/sys/net80211/ieee80211_output.c
  stable/10/sys/net80211/ieee80211_wds.c
Comment 16 Andrey V. Elsukov freebsd_committer freebsd_triage 2015-06-02 01:54:21 UTC
Fixed in head/ and stable/10.