Guys, 

I am setting up snmpd on a ARM device with network drivers that supports the 
mii-ioctls, and I found that the host resources mib (hosts/hr_network.c) 
invokes 
the if-mib's interface for every table iteration of the host mib (via the 
Interface_Scan_Init and Next functions).

The problem that I discovered running this on my ARM hardware device is  that 
the constant polling of the MII Registers causes significant delay,  and the 
HOST mib entries will show up with e.g. 2-3 seconds delay. That  again will 
cause the snmpwalk to *choke* unless you specify a greater  timeout value.

If you pay careful attention to the Interface_Scan_Init, it will dispose of the 
container for interface statistics and create a new container which in case 
triggers a full table re-load. Looking at the code for if-mib/ifTable, it uses 
the cache api which prevents this abuse when browsing the IF-MIB. Also note the 
comment from other developers: "ifTable container  shouldn't change, so we 
shouldn't have to re-fetch it every time"

I don't know of any API calls to cache a container in net-snmp. But a simple 
guard (see patch below) did prevent the condition that I am seeing and the 
snmpwalk finished without a problem. I am sure there are better ways to solve 
this, but I really hope that there's a possibility resolving this issue with 
this or an improved patch in future versions of net-snmp.

Best Regards,
- Eivind


+++ 
/work/enaess/neptune-mainline/tps/net-snmp/5.6.1/mainline/src/agent/mibgroup/if-mib/data_access/interface.c
   
 2011-02-10 16:02:22.000000000 -0800
@@ -348,6 +348,7 @@
 static netsnmp_iterator *it = NULL;
 static netsnmp_container *c = NULL;
 static netsnmp_interface_entry *e = NULL;
+static time_t tstamp;
 
 /**
  * 
@@ -359,10 +360,16 @@
      * ifTable container shouldn't change, so we shouldn' have to
      * re-fetch it every time.
      */
+    if (tstamp < time(NULL))
+    {
           if (NULL != c)
+        {
               netsnmp_access_interface_container_free(c, 0);
+        }
 
          c = netsnmp_access_interface_container_load(NULL, 0);
+        tstamp = time(NULL) + 5;
+    }
     
     if (NULL != c) {
         if (NULL != it)


      

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to