Diff below is needed for migrating snmpd's mib.c to a libagentx based
environment. Specifically the OPENBSD-MEM-MIB:memIfTable, which relies
on IF-MIB:ifIndex.

The issue bubbles forth from the following behaviour:
In libagentx both an object and an index are enabled (started) based
when their respective region is started. The order in which these
regions are started is undetermined.
For agentx_object the agentx_object_start function is halted when not
all indices are in AX_CSTATE_OPEN.

The problem arises from the fact that agentx_index_finalize (the
function called when we know that the request to be opened can be
answered) is combined with a dynamic index (an index not registered
at the snmpd server, but determined by the libagentx based application):
The index is placed in the AX_CSTATE_OPEN state, but it returns
immediately, ignoring any objects that rely on it being opened.

The diff below replaces the return statement to a jump statement
to the final part of the function trying to open the functions.

OK?

martijn@

Index: agentx.c
===================================================================
RCS file: /cvs/src/lib/libagentx/agentx.c,v
retrieving revision 1.14
diff -u -p -r1.14 agentx.c
--- agentx.c    24 Oct 2021 18:03:27 -0000      1.14
+++ agentx.c    17 Jul 2022 12:03:55 -0000
@@ -1660,7 +1660,7 @@ agentx_index_finalize(struct ax_pdu *pdu
 #endif
        if (axi->axi_type == AXI_TYPE_DYNAMIC) {
                axi->axi_cstate = AX_CSTATE_OPEN;
-               return 0;
+               goto objects_start;
        }
 
        resp = &(pdu->ap_payload.ap_response);
@@ -1717,6 +1717,7 @@ agentx_index_finalize(struct ax_pdu *pdu
        if (axi->axi_dstate == AX_DSTATE_CLOSE)
                return agentx_index_close(axi);
 
+ objects_start:
        /* TODO Make use of range_subid register */
        for (i = 0; i < axi->axi_objectlen; i++) {
                if (axi->axi_object[i]->axo_dstate == AX_DSTATE_OPEN) {

Reply via email to