Hi,
 
The problem that I was facing was that snmpwalk goes in an infinite loop after displaying the table in my mib, instead of ending successfully. The same code workes in net-snmp-5.1, and goes in an infinite loop after upgrading to net-snmp-5.2.2.
 
I was able to trace the problem to a code change related to sparse table.
 The problem lies in the agent/helpers/table.c file, in the function table_helper_handler. In net-snmp-5.2.2 an additional function sparse_table_helper_handler is called, which checks the request->requestvb->type. If it is ASN_NULL, it sets it to ASN_PRIV_RETRY, so net-snmp goes in an infinite loop trying to get the next value after the end of the table which does not exist. ( Note that if I return without setting anything after I reach the end of table, request-requestvb->type gets set to ASN_NULL by default, and so we enter this infinite loop ).
 
So, instead of returning without setting anything when I reach the end of table, if I return SNMP_NOSUCHOBJECT when I get the get_next request for the last element in the table, the sparse_table_helper_handler replaces it with ASN_NULL and so net-snmp then correctly goes to the next registered mib.
 
netsnmp_table_build_result(reginfo, requests,
                                   table_info, SNMP_NOSUCHOBJECT,
                                   (u_char*) &x,
                                   sizeof(x));
 
So basically, for snmpwalk to work correctly for my mib in net-snmp-5.2.2 without going into an infinite loop at the end, I need to return SNMP_NOSUCHOBJECT after reaching the end of the table. After adding this code, now the snmpwalk works even in net-snmp-5.2.2
 
Is this a bug in net-snmp-5.2.2 or is it by design ? Is this an additional requirement for using net-snmp-5.2.2 to return SNMP_NOSUCHOBJECT ?
 
Regards,
Amita


From: [EMAIL PROTECTED] on behalf of Amita Mhaskar
Sent: Mon 4/10/2006 6:00 AM
To: net-snmp-users@lists.sourceforge.net
Subject: snmpwalk does not understand the END of a Table for my MIB

Hi,
 
I am using net-snmp-5.2.2 linux 4.2. I have an enterprise MIB which contains 2 tables. When I give snmpwalk command for a table, it correctly returns all the entries for the table, but timesout in the end. From the logs enabled for snmpd, I see that snmpd keeps sending a get-next request for the last entry in the table, and it keeps getting NOSUCHINSTANCE, but it does not go on to the next registered part in the MIB and does not realize that the table is complete, and so the snmpwalk command timesout in the end.
 
 
My MIB has the following :
18359(enterprises).1(ipSanMib).1(objects).1(realm).1(realmTable).1(realmEntry).1(realmIndex)
to
18359(enterprises).1(ipSanMib).1(objects).1(realm).1(realmTable).1(realmEntry).22(realmSystemTime)
 
18359(enterprises).1(ipSanMib).1(objects).2(alert).1(alertTable).1(alertEntry).1(alertIndex)
to
18359(enterprises).1(ipSanMib).1(objects).2(alert).1(alertTable).1(alertEntry).9(alertDescription)
 
From the snmpd.log file:
 
handler:calling: calling handler table for mode GETNEXT
trace: table_helper_handler(): table.c, 184:
helper:table:req: Got request for handler table: base oid:SNMPv2-SMI::enterprises.18359.1.1.1.1
SNMPv2-SMI::enterprises.18359.1.1.1.1.1.22.1  ===> (realmSystemTime)
:
:
handler:returned: handler IntransaIpSanAlert returned 0
sparse: retry for NOSUCHINSTANCE
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler table returned 0
trace: handle_getnext_loop(): snmp_agent.c, 2834:
results: getnext results, before next pass:
trace: handle_getnext_loop(): snmp_agent.c, 2837:
results:        trace: sprint_realloc_by_type(): mib.c, 1977:
 
SNMPv2-SMI::enterprises.18359.1.1.1.1.1.22.1 is the last entry in the table.
 
 
Fot the normal mibs like system, I saw that after the last entry for system: SNMPv2-MIB::sysORUpTime.9 = Timeticks: (2204) 0:00:22.04, the getnext for this goes on to IF-MIB and snmpwalk knows that it has received the complete output for "system".
 
race: snmp_pdu_parse(): snmp_api.c, 4366:
dumph_recv:       VarBind
trace: snmp_parse_var_op(): snmp.c, 166:
dumph_recv:         Name
dumpx_recv:          06 0A 2B 06 01 02 01 01 09 01 04 09
dumpv_recv:            ObjID: SNMPv2-MIB::sysORUpTime.9
trace: snmp_pdu_parse(): snmp_api.c, 4375:
dumph_recv:         Value
  GETNEXT message
    -- SNMPv2-MIB::sysORUpTime.9
 
:
:
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1901:
snmp_agent: tp->start SNMPv2-MIB::sysORUpTime, tp->end SNMPv2-MIB::sysOREntry.5,
:
:
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1901:
snmp_agent: tp->start SNMPv2-MIB::sysOREntry.5, tp->end IF-MIB::ifNumber,
 
 
What change do I need to do so that I can get a snmpwalk successfully completed instead of a timeout, after it has finished displaying all the values?
 
Is the mail chain : "Re: Repost: Retrieving scalar objects"  from the archives related to this problem?
Thanks & Regards,
Amita

Reply via email to