Hi all,

I wrote my own mib file and added it into the agent . But I can’t get the
right value by MIB Browser. The release version of net-snmp source code is
5.6.1.

The memory allocated in the routine “iifo->get_first_data_point” , which was
used to fill my table data, had been prematurely freed before calling the
handle ” netsnmp_call_next_handler( )” in table iterator routine.



          Refer to the mib “nsModuleTable”, I initialized the table module,
registered the handler , defined the iterator access routines such as
“iifo->get_first_data_point”, “iifo->get_first_next_point” and
“iifo->free_loop_context_at_end”. But the value get by tool is wrong. So I
added debug message and found that, the memory, allocated in the routine
“iifo->get_first_data_point”, pointed by the pointer “my_loop_context”, was
freed prematurely by the routine “netsnmp_table_iterator_helper_handler( )”.
So when the routine ” netsnmp_call_next_handler( )” was called, the values
pointed by “my_loop_context” are wrong.



          In file “table_iterator.c”, the 750 line code will do free as
follow.



/* free loop context before going on */

                    if (callback_loop_context &&
iinfo->free_loop_context_at_end) {

                        (iinfo->free_loop_context_at_end)
(callback_loop_context,

                                                   iinfo);

                        callback_loop_context = NULL;

                   }



         But the handle ” netsnmp_call_next_handler( )” was called in line
854.



                  /* Finally, we get to call the next handler below us.
Boy, wasn't

                  all that simple?  They better be glad they don't have to
do it! */

                if (reqinfo->mode != MODE_GET_STASH) {

                    DEBUGMSGTL(("table_iterator", "call subhandler for mode:
%s\n",

                    se_find_label_in_slist("agent_mode", oldmode)));

                    ret =

                           netsnmp_call_next_handler(handler, reginfo,
reqinfo, requests);

 }





          Why the loop context will be freed before calling the handle ”
netsnmp_call_next_handler( )” ?  In that case, the mib “nsModuleTable” will
also do not work and get wrong value? Is that a problem?



So I modified the above code, and moved the code which doing free loop
context from line 750 to the line behind the handler”
netsnmp_call_next_handler”. In this case, my mib will work well and MIB
Browser can get right values.But I cannot ensure this modification is right
and do not have any bad influence.


In addition, I download the previous source code, release version is
5.0.11.2, and found different. The free action will be done after calling
the handle ” netsnmp_call_next_handler( )”. In this case, MIB Browser got
the right value too.



          Can you help me to check this problem? Thank you!





Best wishes,

wise
------------------------------------------------------------------------------
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-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to