Bug 213439

Summary: ifOutOctets are always zero for Xen xn interfaces
Product: Base System Reporter: Trond Endrestøl <Trond.Endrestol>
Component: kernAssignee: freebsd-xen (Nobody) <xen>
Status: Closed FIXED    
Severity: Affects Only Me CC: ae, royger
Priority: --- Keywords: patch
Version: 11.0-STABLE   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
Proposed patch (untested)
none
Proposed patch (untested) none

Description Trond Endrestøl 2016-10-13 09:16:16 UTC
Virtualization platform is XenServer 7.0.0.

The XenServer guest is:
root@[WITHHELD]:~ # uname -a
FreeBSD [WITHHELD].fig.ol.no 11.0-PRERELEASE FreeBSD 11.0-PRERELEASE #1 r306639: Mon Oct  3 17:36:35 CEST 2016     root@[WITHHELD]:/usr/obj/usr/src/sys/XENGUEST  amd64

The kernel configuration file is available at http://ximalas.info/~trond/create-zfs/canmount/XENGUEST-amd64-stable-11

Just for comparison, here's lo0:
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.1
IF-MIB::ifDescr.1 = STRING: lo0
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.1
IF-MIB::ifInOctets.1 = Counter32: 190342
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.1
IF-MIB::ifOutOctets.1 = Counter32: 190491

This is for xn0:
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.2
IF-MIB::ifDescr.2 = STRING: xn0
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.2
IF-MIB::ifInOctets.2 = Counter32: 1799356094
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.2
IF-MIB::ifOutOctets.2 = Counter32: 0

This is for xn1:
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.3
IF-MIB::ifDescr.3 = STRING: xn1
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.3
IF-MIB::ifInOctets.3 = Counter32: 2647317261
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.3
IF-MIB::ifOutOctets.3 = Counter32: 0

In the latter two cases ifOutOctets are always zero, but not for the lo0 case.

Is this a bug in the xn driver?
Comment 1 Andrey V. Elsukov freebsd_committer freebsd_triage 2016-10-13 10:41:01 UTC
Created attachment 175694 [details]
Proposed patch (untested)

Hi,

can you test this patch?
Comment 2 Andrey V. Elsukov freebsd_committer freebsd_triage 2016-10-13 11:09:38 UTC
Created attachment 175696 [details]
Proposed patch (untested)

I think this version is more correct, because after xn_txeof() mbuf should be freed. Also removed duplicate OPACKETS accounting.
Comment 3 Roger Pau Monné freebsd_committer freebsd_triage 2016-10-13 11:31:49 UTC
Could you please upload the patch to reviews.freebsd.org and add me (royger) and liuw_liuw.name as reviewers?

Thanks.
Comment 4 Trond Endrestøl 2016-10-13 14:59:32 UTC
(In reply to Andrey V. Elsukov from comment #2)

I tried the second proposed patch on an identical and least busy system:

root@[WITHHELD]:~ # uname -a
FreeBSD [WITHHELD] 11.0-STABLE FreeBSD 11.0-STABLE #2 r307213M: Thu Oct 13 16:28:54 CEST 2016     root@[WITHHELD]:/usr/obj/usr/src/sys/XENGUEST  amd64

root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.2
IF-MIB::ifDescr.2 = STRING: xn0
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.2
IF-MIB::ifInOctets.2 = Counter32: 29079
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.2
IF-MIB::ifOutOctets.2 = Counter32: 24659

root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.3
IF-MIB::ifDescr.3 = STRING: xn1
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.3
IF-MIB::ifInOctets.3 = Counter32: 10450
root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.3
IF-MIB::ifOutOctets.3 = Counter32: 696

After running for a while, I got this:


root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.2 ; snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.2 ; snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.2
IF-MIB::ifDescr.2 = STRING: xn0
IF-MIB::ifInOctets.2 = Counter32: 115769
IF-MIB::ifOutOctets.2 = Counter32: 117953

root@[WITHHELD]:~ # snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.2.3 ; snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.10.3 ; snmpget -v 2c -c public localhost 1.3.6.1.2.1.2.2.1.16.3
IF-MIB::ifDescr.3 = STRING: xn1
IF-MIB::ifInOctets.3 = Counter32: 67898
IF-MIB::ifOutOctets.3 = Counter32: 696

The low count on ifOutOctets.3 is due to pf filtering and low activity on the xn1 interface.

This patch looks promising. I guess this patch can be committed after some more testing.
Comment 5 Trond Endrestøl 2016-10-20 17:00:57 UTC
(In reply to Trond.Endrestol from comment #4)

I managed to squeeze in a small maintenance window and updated the remaining virtual machines. All worries are gone. The patch allows MRTG to plot outgoing octets and not only incoming octets.

xenbot go, to paraphrase the zettabot on the openzfs developer list.
Comment 6 Roger Pau Monné freebsd_committer freebsd_triage 2016-10-24 17:06:12 UTC
Patch look fine to me, do you want me to commit it Andrey?
Comment 7 Andrey V. Elsukov freebsd_committer freebsd_triage 2016-10-25 18:24:17 UTC
(In reply to Roger Pau Monné from comment #6)
> Patch look fine to me, do you want me to commit it Andrey?

Yes, please, do it if you think it is good enough, I'm busy with other task now.
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-10-31 11:31:51 UTC
A commit references this bug:

Author: royger
Date: Mon Oct 31 11:31:11 UTC 2016
New revision: 308126
URL: https://svnweb.freebsd.org/changeset/base/308126

Log:
  xen/netfront: fix statistics

  Fix the statistics used by netfront.

  Reported by:    Trond.Endrestol@ximalas.info
  Submitted by:   ae
  Reviewed by:    royger, Wei Liu <wei.liu2@citrix.com>
  MFC after:	4 weeks
  PR:		213439

Changes:
  head/sys/dev/xen/netfront/netfront.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-03-16 09:41:58 UTC
A commit references this bug:

Author: royger
Date: Thu Mar 16 09:40:54 UTC 2017
New revision: 315403
URL: https://svnweb.freebsd.org/changeset/base/315403

Log:
  MFC r308126:

  xen/netfront: fix statistics

  PR:	213439

Changes:
_U  stable/11/
  stable/11/sys/dev/xen/netfront/netfront.c
Comment 10 Eitan Adler freebsd_committer freebsd_triage 2018-05-23 10:27:13 UTC
batch change of PRs untouched in 2018 marked "in progress" back to open.
Comment 11 Trond Endrestøl 2018-05-23 10:33:18 UTC
(In reply to Eitan Adler from comment #10)
The patch was committed a long time ago, and everything's fine as far as I can tell.