I use net-snmp-5.4 on linux-2.6.16 with sk98lin driver.
If link of some interface is off, snmpd will core dump periodically.
After investigation, I find that netsnmp_linux_interface_get_if_speed
will cause stack corrupt.
If link is off, speed returned by ETHTOOL_GSET will be 0(not 10 100 1000).
And then it will call ioctl with 0x8947.
Because sk98lin does not support mii, it will call ioctl again with
SIOCDEVPRIVATE.
SIOCDEVPRIVATE in sk98lin is SK_IOCTL_GETMIB, and cause stack corrupt.
I have a quick fix for this.
--- net-snmp-5.4/agent/mibgroup/if-mib/data_access/interface_linux.c
2006-09-21 06:09:18.000000000 -0700
+++ net-snmp-5.4-new/agent/mibgroup/if-mib/data_access/interface_linux.c
2007-07-12 19:20:52.000000000 -0700
@@ -728,7 +728,18 @@
DEBUGMSGTL(("mibII/interfaces", "fallback to mii for %s\n",
ifr.ifr_name));
/* try MII */
- return netsnmp_linux_interface_get_if_speed_mii(fd,name);
+
+ /*
+ * If link is off, this path will be taken and then
+ * SIOCDEVPRIVATE on sk98lin is SK_IOCTL_GETMIB.
+ * It will cause stack corrupt because there is no enough
space in ifreq.
+ *
+ * Note: we assume link is off if ethtool returns successful
and speed is not
+ * 10 100 or 1000. better solution is to use ETHTOOL_GLINK to
detect if link is on.
+ */
+ return SPEED_100 * 1000 * 1000;
+
+ //return netsnmp_linux_interface_get_if_speed_mii(fd,name);
}
/* return in bps */
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders