Bug 157015 - bsnmpd(8) does not create 64bit counters for interfaces without link
Summary: bsnmpd(8) does not create 64bit counters for interfaces without link
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Andrey V. Elsukov
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-05-13 21:00 UTC by Kurt Lidl
Modified: 2019-05-02 17:44 UTC (History)
2 users (show)

See Also:


Attachments
Proposed patch (2.01 KB, patch)
2018-12-21 10:54 UTC, Andrey V. Elsukov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Lidl 2011-05-13 21:00:19 UTC
On a machine with 4 ethernet interfaces (two on-board, two on a single
dual-port PCI card), I noticed the following.

Interfaces fxp0, fxp1 are on the PCI card.
Interfaces fxp2, fxp3 are on the motherboard.

Interfaces fxp0, fxp2, fxp3 are plugged into ethernet switches.
Interface fxp1 is not plugged into anything, but configured "UP".

Using snmpwalk, I see the following:

# snmpwalk -v2c -c XXX gatewayname 1.3.6.1.2.1.31.1.1.1

IF-MIB::ifName.1 = STRING: fxp0
IF-MIB::ifName.2 = STRING: fxp1
IF-MIB::ifName.3 = STRING: fxp2
IF-MIB::ifName.4 = STRING: fxp3
IF-MIB::ifName.5 = STRING: lo0
IF-MIB::ifInMulticastPkts.1 = Counter32: 2294
IF-MIB::ifInMulticastPkts.2 = Counter32: 0
IF-MIB::ifInMulticastPkts.3 = Counter32: 1486
IF-MIB::ifInMulticastPkts.4 = Counter32: 43
IF-MIB::ifInMulticastPkts.5 = Counter32: 0
IF-MIB::ifInBroadcastPkts.1 = Counter32: 0
IF-MIB::ifInBroadcastPkts.2 = Counter32: 0
IF-MIB::ifInBroadcastPkts.3 = Counter32: 0
IF-MIB::ifInBroadcastPkts.4 = Counter32: 0
IF-MIB::ifInBroadcastPkts.5 = Counter32: 0
IF-MIB::ifOutMulticastPkts.1 = Counter32: 0
IF-MIB::ifOutMulticastPkts.2 = Counter32: 0
IF-MIB::ifOutMulticastPkts.3 = Counter32: 9
IF-MIB::ifOutMulticastPkts.4 = Counter32: 0
IF-MIB::ifOutMulticastPkts.5 = Counter32: 0
IF-MIB::ifOutBroadcastPkts.1 = Counter32: 0
IF-MIB::ifOutBroadcastPkts.2 = Counter32: 0
IF-MIB::ifOutBroadcastPkts.3 = Counter32: 0
IF-MIB::ifOutBroadcastPkts.4 = Counter32: 0
IF-MIB::ifOutBroadcastPkts.5 = Counter32: 0
IF-MIB::ifHCInOctets.1 = Counter64: 766678
IF-MIB::ifHCInOctets.3 = Counter64: 22034061
IF-MIB::ifHCInOctets.4 = Counter64: 57896044
IF-MIB::ifHCInUcastPkts.1 = Counter64: 18446744073709551613
IF-MIB::ifHCInUcastPkts.3 = Counter64: 62323
IF-MIB::ifHCInUcastPkts.4 = Counter64: 65222
IF-MIB::ifHCInMulticastPkts.1 = Counter64: 2294
IF-MIB::ifHCInMulticastPkts.3 = Counter64: 1486
IF-MIB::ifHCInMulticastPkts.4 = Counter64: 43
IF-MIB::ifHCInBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCInBroadcastPkts.4 = Counter64: 0
IF-MIB::ifHCOutOctets.1 = Counter64: 0
IF-MIB::ifHCOutOctets.3 = Counter64: 58266640
IF-MIB::ifHCOutOctets.4 = Counter64: 20901937
IF-MIB::ifHCOutUcastPkts.1 = Counter64: 0
IF-MIB::ifHCOutUcastPkts.3 = Counter64: 71308
IF-MIB::ifHCOutUcastPkts.4 = Counter64: 53540
IF-MIB::ifHCOutMulticastPkts.1 = Counter64: 0
IF-MIB::ifHCOutMulticastPkts.3 = Counter64: 9
IF-MIB::ifHCOutMulticastPkts.4 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.1 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.3 = Counter64: 0
IF-MIB::ifHCOutBroadcastPkts.4 = Counter64: 0
IF-MIB::ifLinkUpDownTrapEnable.1 = INTEGER: enabled(1)
IF-MIB::ifLinkUpDownTrapEnable.2 = INTEGER: enabled(1)
IF-MIB::ifLinkUpDownTrapEnable.3 = INTEGER: enabled(1)
IF-MIB::ifLinkUpDownTrapEnable.4 = INTEGER: enabled(1)
IF-MIB::ifLinkUpDownTrapEnable.5 = INTEGER: disabled(2)
IF-MIB::ifHighSpeed.1 = Gauge32: 100
IF-MIB::ifHighSpeed.2 = Gauge32: 0
IF-MIB::ifHighSpeed.3 = Gauge32: 100
IF-MIB::ifHighSpeed.4 = Gauge32: 100
IF-MIB::ifHighSpeed.5 = Gauge32: 0
IF-MIB::ifPromiscuousMode.1 = INTEGER: false(2)
IF-MIB::ifPromiscuousMode.2 = INTEGER: false(2)
IF-MIB::ifPromiscuousMode.3 = INTEGER: false(2)
IF-MIB::ifPromiscuousMode.4 = INTEGER: false(2)
IF-MIB::ifPromiscuousMode.5 = INTEGER: false(2)
IF-MIB::ifConnectorPresent.1 = INTEGER: true(1)
IF-MIB::ifConnectorPresent.2 = INTEGER: true(1)
IF-MIB::ifConnectorPresent.3 = INTEGER: true(1)
IF-MIB::ifConnectorPresent.4 = INTEGER: true(1)
IF-MIB::ifConnectorPresent.5 = INTEGER: false(2)
IF-MIB::ifAlias.1 = STRING:
IF-MIB::ifAlias.2 = STRING:
IF-MIB::ifAlias.3 = STRING:
IF-MIB::ifAlias.4 = STRING:
IF-MIB::ifAlias.5 = STRING:
IF-MIB::ifCounterDiscontinuityTime.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifCounterDiscontinuityTime.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifCounterDiscontinuityTime.3 = Timeticks: (0) 0:00:00.00
IF-MIB::ifCounterDiscontinuityTime.4 = Timeticks: (0) 0:00:00.00
IF-MIB::ifCounterDiscontinuityTime.5 = Timeticks: (0) 0:00:00.00

As you can see, the .2 interface (== fxp1) doesn't have 64bit
counters available.  (And it looks like the .1 interface (== fxp0)
doesn't have a valid ifHCInUcastPkts field either.

The value 18446744073709551613 is suspiciously close to 16*1024^5,
in fact, just 3 short of it.  Given that the machine was just rebooted
a few minutes before this snmpwalk was done, it's physically impossible
to have received 16 quadrillion packets in that time frame.

Fix: 

I suspect a bug in bsnmpd, but if one plugs in an ethernet cable between
the interface and the switch, so the interface has link, the 64bit counter
springs into existance...

# snmpwalk -v2c -c XXX gatewayname 1.3.6.1.2.1.31.1.1.1.6
IF-MIB::ifHCInOctets.1 = Counter64: 1153385
IF-MIB::ifHCInOctets.2 = Counter64: 0
IF-MIB::ifHCInOctets.3 = Counter64: 45318695
IF-MIB::ifHCInOctets.4 = Counter64: 68312828
How-To-Repeat: I suspect that if you boot a machine without link on some interface,
start bnsmpd and try to do a snmpwalk using v2c, that you'll run into
this same problem on any interface without link.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:51:34 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"
Comment 2 Andrey V. Elsukov freebsd_committer 2018-12-21 10:54:17 UTC
Created attachment 200330 [details]
Proposed patch

We use this patch to solve this problem. Can you test it?
Comment 3 commit-hook freebsd_committer 2019-04-02 13:38:32 UTC
A commit references this bug:

Author: ae
Date: Tue Apr  2 13:38:00 UTC 2019
New revision: 345798
URL: https://svnweb.freebsd.org/changeset/base/345798

Log:
  Create 64bit mibII counters for all interfaces.

  PR:		157015
  Obtained from:	Yandex LLC
  MFC after:	1 month

Changes:
  head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
Comment 4 commit-hook freebsd_committer 2019-05-02 17:42:29 UTC
A commit references this bug:

Author: ae
Date: Thu May  2 17:41:42 UTC 2019
New revision: 347025
URL: https://svnweb.freebsd.org/changeset/base/347025

Log:
  MFC r345798:
    Create 64bit mibII counters for all interfaces.

    PR:		157015
    Obtained from:	Yandex LLC

Changes:
_U  stable/11/
  stable/11/contrib/bsnmp/snmp_mibII/mibII_interfaces.c
Comment 5 commit-hook freebsd_committer 2019-05-02 17:44:34 UTC
A commit references this bug:

Author: ae
Date: Thu May  2 17:43:48 UTC 2019
New revision: 347026
URL: https://svnweb.freebsd.org/changeset/base/347026

Log:
  MFC r345798:
    Create 64bit mibII counters for all interfaces.

    PR:		157015
    Obtained from:	Yandex LLC

Changes:
_U  stable/12/
  stable/12/contrib/bsnmp/snmp_mibII/mibII_interfaces.c