From owner-freebsd-hackers Sat Jun 8 20:51:59 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from CRWdog.demon.co.uk (p69-199.acedsl.com [66.114.69.199]) by hub.freebsd.org (Postfix) with ESMTP id 51B7B37B400; Sat, 8 Jun 2002 20:51:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by CRWdog.demon.co.uk (Postfix) with ESMTP id 55A8F3E2D; Sat, 8 Jun 2002 23:51:46 -0400 (EDT) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Larry Rosenman Cc: Andy Sparrow , freebsd-net@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: MIB support for network devices in FreeBSD? In-Reply-To: Message from Larry Rosenman of "08 Jun 2002 22:11:44 CDT." <1023592304.349.20.camel@lerlaptop> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_160246690P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Date: Sat, 08 Jun 2002 23:51:46 -0400 From: Andy Sparrow Message-Id: <20020609035146.55A8F3E2D@CRWdog.demon.co.uk> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --==_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 , 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 ./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