Another patch that I think will be better for 5.7 at this point, but I'm
posting them all :-)
ID: 3057090
Last Update: Attachment added ( shemminger )
Details:
Change the use of Linux ethtool interface to match current
conventions used by the ethtool utility:
* allow any reported value for speed
* use ethtool conventions for speed unknown (0 or ffff)
* if device reports unknown speed, don't call MII
* support 32 bits speed data, necessary for 100G
This is newish so need to add autoconf foo to handle it.
Subject: if-mib: add support for more speeds with ethtool
Change the use of Linux ethtool interface to match current
conventions used by the ethtool utility:
* allow any reported value for speed
* use ethtool conventions for speed unknown (0 or ffff)
* if device reports unknown speed, don't call MII
* support 32 bits speed data, necessary for 100G
This is newish so need to add autoconf foo to handle it.
----
Patch against 5.6-rc1
--- a/agent/mibgroup/if-mib/data_access/interface_linux.c 2010-08-31
16:46:11.768178268 -0700
+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c 2010-08-31
16:48:48.742353727 -0700
@@ -805,6 +805,7 @@ netsnmp_linux_interface_get_if_speed(int
{
struct ifreq ifr;
struct ethtool_cmd edata;
+ __u32 speed;
memset(&ifr, 0, sizeof(ifr));
edata.cmd = ETHTOOL_GSET;
@@ -819,24 +820,20 @@ netsnmp_linux_interface_get_if_speed(int
return netsnmp_linux_interface_get_if_speed_mii(fd,name,defaultspeed);
}
- if (edata.speed != SPEED_10 && edata.speed != SPEED_100
-#ifdef SPEED_10000
- && edata.speed != SPEED_10000
+ speed = edata.speed;
+#if HAVE_STRUCT_ETHTOOL_CMD_SPEED_HI
+ speed |= edata.speed_hi << 16;
#endif
-#ifdef SPEED_2500
- && edata.speed != SPEED_2500
-#endif
- && edata.speed != SPEED_1000 ) {
- DEBUGMSGTL(("mibII/interfaces", "fallback to mii for %s\n",
- ifr.ifr_name));
- /* try MII */
- return netsnmp_linux_interface_get_if_speed_mii(fd,name,defaultspeed);
+ if (speed == 0 || speed == (__u16)(-1) || speed == (__u32)(-1)) {
+ DEBUGMSGTL(("mibII/interfaces", "speed is not known for %s\n",
+ ifr.ifr_name));
+ return defaultspeed;
}
/* return in bps */
DEBUGMSGTL(("mibII/interfaces", "ETHTOOL_GSET on %s speed = %d\n",
- ifr.ifr_name, edata.speed));
- return edata.speed*1000LL*1000LL;
+ ifr.ifr_name, speed));
+ return speed*1000LL*1000LL;
}
#endif
--- a/configure.d/config_os_struct_members 2010-08-31 16:46:11.792179204
-0700
+++ b/configure.d/config_os_struct_members 2010-08-31 16:48:48.742353727
-0700
@@ -33,6 +33,17 @@ AC_CHECK_MEMBERS([struct arphd.at_next],
#endif
]])
+
+# struct ethtool_cmd
+# Agent:
+if test "x$ac_cv_header_linux_ethtool_h" = "xyes" ; then
+ AC_CHECK_MEMBERS([struct ethtool_cmd.speed_hi],,,[[
+#if HAVE_LINUX_ETHTOOL_H
+#include <linux/ethtool.h>
+#endif
+ ]])
+fi
+
# struct des_ks_struct
# ('weak_key' indicates older version of OpenSSL)
# Library:
--- a/include/net-snmp/net-snmp-config.h.in 2010-08-31 16:49:23.215724149
-0700
+++ b/include/net-snmp/net-snmp-config.h.in 2010-08-31 16:50:55.451414816
-0700
@@ -316,6 +316,9 @@
/* Define to 1 if you have the <linux/ethtool.h> header file. */
#undef HAVE_LINUX_ETHTOOL_H
+/* Define to 1 if `speed_hi' is member of `struct ethtool_cmd'. */
+#undef HAVE_STRUCT_ETHTOOL_CMD_SPEED_HI
+
/* Define to 1 if you have the <linux/hdreg.h> header file. */
#undef HAVE_LINUX_HDREG_H
--
Wes Hardaker
Please mail all replies to [email protected]
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders