Re: unregister_mib fails

Pal Saint <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAJX137oYP_gzi32RSNm6RX4w7H072BTMQpQnDC-8ZP-5jknnsw@mail.gmail.com>
The problem I mentioned was noticed even with UCD-DLMOD registration and
unregistration code (agent/mibgroup/ucd-snmp/dlmod.c).

Here is the example code I compiled and was able to reproduce on my Linux
2.6.32 (64bit).
I am using net-snmp-5.7.2.

/*
 * example_oid:
 */
oid example_oid[] = { 1,3,6,1,4,1,8076,1,5,2 };

struct variable2 example_variables[] = {
/*  magic number        , variable type , ro/rw , callback fn  , L,
oidsuffix */

#define exampleTableId     1
{exampleTableId,  ASN_INTEGER,  RONLY,   get_exampleTable, 2,  { 1,1 }},
#define exampleTableROps      2
{exampleTableROps,  ASN_COUNTER,  RONLY,   get_exampleTable, 2,  { 1,2 }},
#define exampleTableWops     3
{exampleTableWops,  ASN_COUNTER,  RONLY,   get_exampleTable, 2,  { 1,3 }},
};


void
init_example_table(void)
{

    /* register ourselves with the agent to handle our mib tree */
    REGISTER_MIB("exampleTable", example_variables, variable2,
               example_oid);

}


void deinit_example_table(void) {
    int result;

   result = unregister_mib(example_oid,
                  sizeof(example_oid)/sizeof(oid));
    if (result != MIB_UNREGISTERED_OK) {
        snmp_log(LOG_ERR, "%s: unregistering failed:%d\n", __FUNCTION__,
result);
    }
}



On Mon, Mar 18, 2013 at 10:45 PM, Magnus Fromreide <[email protected]>wrote:

> On Fri, 2013-03-08 at 12:45 -0800, Pal Saint wrote:
> > unregister_mib fails even for standard UCD-DLMOD MIB.
> > While registering all the columns are explicitly registered. But
> > during unregistering, unregister_mib tries to do an exact match with
> > the root oid to the subtree children that were registered. This seems
> > to fail.
> > Checking if unregister_mib_range might help.
> > Could someone comment if you have experience in this area? Thanks
> >
> >
> > On Fri, Mar 8, 2013 at 12:09 PM, Pal Saint <[email protected]> wrote:
> >         I added additional debugging to 'agent_registry.c' file and
> >         recompiled. During unregistering the MIB, the agent complaints
> >         about not finding the child and
> >         returns MIB_NO_SUCH_REGISTRATION.
> >
> >
> >         My subagents registers MIB using default context ("") and
> >         default priority. Any idea why the registering succeeds but
> >         not unregistering MIB? I appreciate your insights and
> >         pointers.
>
>
> What is the code you use for unregistration?
> Normally unregistration is done as a mirror of registration, so to
> mirror the registration you got done you need to mirror REGISTER_MIB,
> like this:
>
> /* generated code */
>
> void
> init_foo(void)
> {
>     DEBUGMSGTL(("foo", "Initializing\n"));
>
>     /* register ourselves with the agent to handle our mib tree */
>     REGISTER_MIB("foo", foo_variables, variable4,foo_variables_oid);
>
>     /* place any other initialization junk you need here */
> }
>
> /* New code you need to add */
> void
> shutdown_foo(void)
> {
>     DEBUGMSGTL(("foo", "Shutting down\n"));
>
>     /* unregister ourselves with the agent */
>     unregister_mib(foo_variables_oid, OID_LENGTH(foo_variables_oid));
> }
>
> You also failed to say which version of Net-SNMP you are working with.
>
> Also, if reporting things like this then a working minimal example of
> the problem is appreciated - right now I have tried to guess what your
> problem is and I might have guessed wrong.
>
> /MF
> >
> >         1695     while(unregistering){
> >         1696         DEBUGMSGTL(("register_mib", "unregistering "));
> >         1697         DEBUGMSGOIDRANGE(("register_mib", name, len,
> >         range_subid, range_ubound));
> >         1698         DEBUGMSG(("register_mib", "\n"));
> >         1699
> >         1700         list = netsnmp_subtree_find(name, len,
> >         netsnmp_subtree_find_first(context),
> >         1701                     context);
> >         1702         if (list == NULL) {
> >         1703             DEBUGMSGTL(("register_mib", "pal:failed to
> >         find subtree"));
> >         1704             return MIB_NO_SUCH_REGISTRATION;
> >         1705         }
> >         1706
> >         1707         for (child = list, prev = NULL; child != NULL;
> >         1708             prev = child, child = child->children) {
> >         1709             if (netsnmp_oid_equals(child->name_a,
> >         child->namelen, name, len) == 0 &&
> >         1710                 child->priority == priority) {
> >         1711                 break;              /* found it */
> >         1712              }
> >         1713         }
> >         1714
> >         1715         if (child == NULL) {
> >         1716             DEBUGMSGTL(("register_mib", "pal:failed null
> >         child")); <<<<<<<<<<<< Returns from here
> >         1717             return MIB_NO_SUCH_REGISTRATION;
> >         1718         }
> >
> >
> >
> >
> >         On Thu, Mar 7, 2013 at 1:22 AM, Pal Saint <[email protected]>
> >         wrote:
> >                 All,
> >
> >
> >                 We use REGISTER_MIB() to register our MIB tables, and
> >                 use unregister_mib() for unregistering them. However,
> >                 when SIGHUP is sent to snmpd, it fails to unregister
> >                 the MIB variables. It fails with
> >                 "MIB_NO_SUCH_REGISTRATION". Registering and
> >                 unregistering code  is actually created by
> >                 mib2c.old_api code generation configuration. Let me
> >                 know if you need more information.
> >
> >
> >                 Here is snmpd debug info...
> >
> >
> >                 dlmod: dlmod_create_module
> >                 dlmod: dlmod_load_module
> >                 exampleTable: /usr/lib/snmp/dlmod/exampleTable.so
> >                 ................. Registering exampleTable
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.1 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.2 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.3 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.4 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.5 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.6 with context ""
> >                 register_mib: registering "exampleTable" at
> >                 SNMPv2-SMI::enterprises.8075.1.3.2.1.7 with context ""
> >
> >
> >                 ...
> >                 dlmod: Calling deinit_exampleTable()
> >                 deinit_exampleTable: unregistering exampleTable...
> >                 register_mib: unregistering
> >                 SNMPv2-SMI::enterprises.8075.1.3.2
> >                 deinit_exampleTable: unregistering exampleTable
> >                 failed:-1
> >                 dlmod: Module exampleTable unloaded
> >
> >
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Everyone hates slow websites. So do we.
> > Make your web apps faster with AppDynamics
> > Download AppDynamics Lite for free today:
> > http://p.sf.net/sfu/appdyn_d2d_mar
> > _______________________________________________ Net-snmp-coders mailing
> list [email protected]
> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
>
>
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.