Hello Dave,

first of all thank you very much for your detailed answer.

>When you talk about "leaf handlers", do you mean the handlers for scalar
> objects,  or the handlers for column objects within a table

Im just using scalar objects.

> What sort of registration call(s) are you using?

netsnmp_register_scalar( netsnmp_create_handler_registration ("callState", 
handle_callState,
                                                callState_oid, 
OID_LENGTH(callState_oid),
                                                HANDLER_CAN_RONLY ));


The leaf handlers looks like this (just the relevant portion):

int handle_callState( netsnmp_mib_handler           *handler,
                      netsnmp_handler_registration  *reginfo,
                      netsnmp_agent_request_info    *reqinfo,
                      netsnmp_request_info          *requests )
{
        switch ( reqinfo->mode )
        {
                case MODE_GET:
                        snmp_set_var_typed_value(requests->requestvb, 
ASN_INTEGER, (u_char *) &myCallState, sizeof(int));
                break
        }

        return SNMP_ERR_NOERROR;
}



> Of course, if you're not using either of these helpers, and registering
> your module using a basic handler, then this *will* be called twice

That's right, currently I'm not using any caching mechanisms. So thank you 
for the hint 
with the agent/nsCache.c. I have to study this and fix my code.

best regards
Reto




Dave Shield <[email protected]> 
Gesendet von: [email protected]
02.03.2011 17:29

An
Reto Jaeger <[email protected]>
Kopie
[email protected]
Thema
Re: snmpwalk - leaf handlers are called twice






On 1 March 2011 13:04, Reto Jaeger <[email protected]> wrote:
> I have implemented an snmp subagent using the agent-x protocol.
> When I do a snmpwalk operation I see that all leaf handlers are called
> twice. The leaf handlers are called once (as expected) when I performing
> a snmpget operation.

When you talk about "leaf handlers", do you mean the handlers for scalar
objects,  or the handlers for column objects within a table (or both)?

Both scalar and column objects are leaf objects within the SMI structure,
but the implementation code is typically very different.



> My question is: Why the leaf handlers called twice on a snmpwalk 
operation?

How have you implemented these handlers?
What sort of registration call(s) are you using?

Running an 'snmpwalk' on a scalar object will typically result in two 
GETNEXT
requests (one to retrieve the actual value of the scalar instance itself,
and one to retrieve the "next" value, which is then discarded).

But the scalar (and instance) helpers ought to distinguish between
valid and invalid instances,  and filter out the invalid requests 
automatically.
The object-specific handler should only be called once.
   I've just confirmed this with the two scalar objects in the 
agent/nsCache.c
module - issuing
    snmpwalk .... nsCacheDefaultTimeout
           only calls the nsCacheDefaultTimeout handler once (for 
processing
"GetNext nsCacheDefaultTimeout").  The second GETNEXT request
("GetNext nsCacheDefaultTimeout.0") is caught by the scalar helper.


Of course, if you're not using either of these helpers, and registering
your module using a basic handler, then this *will* be called twice,
due to the way that the SNMP GetNext protocol operation works.

A lot will depend on exactly what your code looks like.

Dave

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to