ID: 3057092
  Last Update: Attachment added ( shemminger )
  Details:

  Linux has a way of recording an ifAlias value for each interface.
  The value is configurable with iproute utilities or sysfs.

Like the previous, I look forward to applying this post-5.6 but think it
shouldn't go into 5.6.  Other thoughts welcome, however.


--- a/agent/mibgroup/if-mib/data_access/interface_linux.c       2010-08-30 
16:32:14.000000000 -0700
+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c       2010-08-30 
16:45:16.000000000 -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-30 16:32:14.000000000 
-0700
+++ b/configure.d/config_os_struct_members      2010-08-31 09:26:16.002014237 
-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:
@@ -615,4 +626,3 @@ if test "x$ac_cv_struct_rtentry" = "x"; 
 fi
 AC_DEFINE_UNQUOTED(RTENTRY,struct ${ac_cv_struct_rtentry},
         [define rtentry to ortentry on SYSV machines (alphas)])
-


-- 
Wes Hardaker
Please mail all replies to net-snmp-coders@lists.sourceforge.net

------------------------------------------------------------------------------
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
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to