Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 08 Jun 2002 23:51:46 -0400
From:      Andy Sparrow <spadger@best.com>
To:        Larry Rosenman <ler@lerctr.org>
Cc:        Andy Sparrow <spadger@best.com>, freebsd-net@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
Subject:   Re: MIB support for network devices in FreeBSD? 
Message-ID:  <20020609035146.55A8F3E2D@CRWdog.demon.co.uk>
In-Reply-To: Message from Larry Rosenman <ler@lerctr.org>  of "08 Jun 2002 22:11:44 CDT." <1023592304.349.20.camel@lerlaptop> 

next in thread | previous in thread | raw e-mail | index | archive | help
--==_Exmh_160246690P
Content-Type: text/plain; charset=us-ascii


> I believe you can get this info if you add the net/snmp or net/snmp4
> port. 

Hi Larry,

Thanks for replying.

Hmmm. I'm talking about code that uses a FreeBSD-specific sysctl to 
interrogate the in-kernel if MIB counters, like this:

/* gather stats */
int
freebsd_sysctl_get(struct Devices*dev, unsigned long* ip,
    unsigned long* op, unsigned long* ib, unsigned long* ob)
{
  struct ifmibdata* drvdata = dev->drvdata;
  int datamib[6];
  int len;

  *ip = *op = *ib = *ob = 0;

  datamib[0] = CTL_NET;
  datamib[1] = PF_LINK;
  datamib[2] = NETLINK_GENERIC;
  datamib[3] = IFMIB_IFDATA;
  datamib[4] = 1; /* fill in later */
  datamib[5] = IFDATA_GENERAL;

  datamib[4] = IFMIB_IFCOUNT;

  len = sizeof(struct ifmibdata);

  if(sysctl(datamib, 6, drvdata, &len, NULL, 0) < 0)
    return 1;

  *ip = drvdata->ifmd_data.ifi_ipackets;
  *op = drvdata->ifmd_data.ifi_opackets;
  *ib = drvdata->ifmd_data.ifi_ibytes;
  *ob = drvdata->ifmd_data.ifi_obytes;

  return 0;
}



But these stats don't seem to be collected for at least some network card 
drivers, presumably because those drivers aren't collecting those stats, e.g. 
they don't #include <net/if_mib.h>, and thus don't allocate a mib structure or 
increment any counters in that structure.

I can confirm that it definately doesn't work for the 'wi' and 'lo' drivers...

However, it definately seems to work for the xl driver...

Try this:

	cd /usr/src/sys/dev; find . -exec grep mib {} /dev/null \;

'awi', 'ed' & 'ray' drivers seem to have the most complete implementations, 
but 'fe' & 'xe' seem to have partial implementations (error counters only). 
They're relatively short, so here's one by way of illustration:

./xe/if_xe.c:#include <net/if_mib.h>
./xe/if_xe.c:    scp->ifp->if_linkmib = &scp->mibdata;
./xe/if_xe.c:    scp->ifp->if_linkmiblen = sizeof scp->mibdata;
./xe/if_xe.c:     scp->mibdata.dot3StatsSingleCollisionFrames++;
./xe/if_xe.c:     scp->mibdata.dot3StatsCollFrequencies[0]++;
./xe/if_xe.c:       scp->mibdata.dot3StatsMultipleCollisionFrames++;
./xe/if_xe.c:       scp->mibdata.dot3StatsCollFrequencies[scp->
tx_collisions-1]++;
./xe/if_xe.c:       scp->mibdata.dot3StatsMultipleCollisionFrames += sent;
./xe/if_xe.c:      scp->mibdata.dot3StatsExcessiveCollisions++;
./xe/if_xe.c:      scp->mibdata.dot3StatsMultipleCollisionFrames++;
./xe/if_xe.c:      scp->mibdata.dot3StatsCollFrequencies[15]++;
./xe/if_xe.c:     scp->mibData.dot3StatsMissedFrames++;
./xe/if_xe.c:   scp->mibdata.dot3StatsFrameTooLongs++;
./xe/if_xe.c:   scp->mibdata.dot3StatsFCSErrors++;
./xe/if_xe.c:   scp->mibdata.dot3StatsAlignmentErrors++;
./xe/if_xe.c:      scp->mibdata.dot3StatsInternalMacReceiveErrors++;
./xe/if_xevar.h:  struct ifmib_iso_8802_3 mibdata;


However, most of the drivers don't seem to have any code like this in them - 
and at least some of those drivers don't work with the 3rd-party application 
code above.

Should they? Or is this an older interface?

I'd like to advise the author so he can fix a very useful dockapp for me - or, 
if this is the way to go, I'll badger Bill Paul to fix the 'wi' driver - oh, 
wait a moment, maybe generating patches would be safer :)


Regards,

AS



--==_Exmh_160246690P
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)
Comment: Exmh version 2.5 07/13/2001

iD8DBQE9AtDSPHh895bDXeQRAnOAAKC/77wrv0p3U5+EHRjrXvI9d6ewQACggGG+
hr40XuRET6/Y9oFgrGjqUrY=
=4gqz
-----END PGP SIGNATURE-----

--==_Exmh_160246690P--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020609035146.55A8F3E2D>