[AGENT++] agentX++ interoperability with NET-SNMP version 5.7.3.rc1

Claus Klein claus.klein at arcormail.de
Sun Nov 23 13:36:09 CET 2014


Hi Frank,

I tested again with the subagent example.

In general, I can say:
	• any_index()
	• new_index()
does not work!

//FIXME ifTable->new_index(); //TODO err=AGENTX_INDEX_NONE_AVAILABLE with noIndexAllocation! ck
//FIXME ifTable->any_index();	 //TODO first call to any_index() creates the illegal ifIndex 0!

In case of any error with index allocation, the subagent ends with memory violation!
You may see below the log output of such a case.

But this code seems to work with net-snmp as master agent as long as there are no errors while index (de)allocation:

while ((run) && (!mib->get_agentx()->quit()))
{

    req = reqList->receive(4000);
    if (req) {
        mib->process_request(req);
    } else {
        // ping the master
        mib->ping_master();

        /**
         * This shows how manipulation of a shared
         * table can be done from outside the table class:
        **/
        if (ifEntry::instance) {
            ifEntry* ifTable = ifEntry::instance;
            static bool deAllocateIndices = false;
            //NOTE: default index strategy is firstSubIndexOnly;   it works OK
            //FIXME ifTable->set_index_strategy(noIndexAllocation);	//TODO does NOT work with net-snmp master agent; why? ck
            //OK ifTable->set_index_strategy(anyNonAllocatedSubIndex);	// OK
            //OK ifTable->set_index_strategy(alwaysFirstSubIndex);	// OK

            if (!deAllocateIndices && ifTable->size() < 3) {
                //FIXME ifTable->new_index();//TODO err=AGENTX_INDEX_NONE_AVAILABLE with noIndexAllocation! ck
                //FIXME ifTable->any_index();	//TODO first call to any_index() creates the illegal ifIndex 0!
                //
                // or this works better if there are NO errors while (de)allocation at master agent.
                //=========================================================
                Oidx index(ifTable->get_next_avail_index());
                if (ifTable->allocate_index(index)) {
                    std::cout << std::endl << "ifEntry(" <<
                              index.get_printable() << ") allocated"
                              << std::endl << std::endl;
                } else {
                    std::cout << std::endl << "ifEntry(" <<
                              index.get_printable() << ") allocation failed!"
                              << std::endl << std::endl;
                }
                //=========================================================

            } else if (!deAllocateIndices && ifTable->size() == 3) {
                deAllocateIndices = true;
            } else {

                //=========================================================
                if (deAllocateIndices && (ifTable->size())) {
                    List<MibTableRow>* l = ifTable->get_rows();
                    Oidx index(l->last()->get_index());
                    l->clear();
                    delete l;
                    ifTable->remove_row(index);
                    std::cout << std::endl << "ifEntry(" <<
                              index.get_printable() << ") removed"
                              << std::endl << std::endl;
                }
                //=========================================================

                if (!ifTable->size()) {
                    deAllocateIndices = false;	// done
                }
            }
        }
    }
}

Best regards,
Claus

########################################################################################

			/**
			 * This shows how manipulation of a shared
			 * table can be done from outside the table class:
			**/
			if (ifEntry::instance) {
				ifEntry* ifTable = ifEntry::instance;
				//FIXME				ifTable->set_index_strategy(noIndexAllocation);			//TODO check this! ck
				ifTable->set_index_strategy(anyNonAllocatedSubIndex);	//TODO check this! ck

				if (!done && ifTable->size() < 3) {
					ifTable->new_index();	//FIXME err=AGENTX_INDEX_NONE_AVAILABLE with noIndexAllocation! ck
				}
			}

20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (5)INFO   : AgentXSlave: no request within (milli seconds): (20000)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (3)EVENT  : AgentX: sending agentx pdu (sd)(type)(sid)(tid)(pid)(err)(errind): (3), (13), (22), (106), (109), (0), (0)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXSlave: sending index allocate PDU (sz)(type): (1), (NEW_INDEX)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (3)EVENT  : AgentX: sending agentx pdu (sd)(type)(sid)(tid)(pid)(err)(errind): (3), (14), (22), (107), (110), (0), (0)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (4)DEBUG  : AgentXSlave: received something on ports
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXRequestList: request received (context)(tid)(pid)(siz)(type)(err)(status): (), (106), (109), (0), (18), (0), (0)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : LockQueue: adding lock request (ptr): (4320162192)
20141123.11:41:08:   00 70 43 01 01 00 00 00                            .pC.....
: (8)DEBUG  : Synchronized: trylock success (id): (669)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (4)DEBUG  : AgentXSlave: received something on ports
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXRequestList: request received (context)(tid)(pid)(siz)(type)(err)(status): (), (107), (110), (1), (18), (0), (0)
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : SubAgent: starting thread execution
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : LockQueue: adding lock request (ptr): (4303367056)
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : Agent: finished thread execution
20141123.11:41:08:   00 70 43 01 01 00 00 00                            .pC.....
: (8)DEBUG  : Synchronized: trylock success (id): (672)
20141123.11:41:08:   00 10 5C 00 01 00 00 00                            ..\.....
: (1)INFO   : SubAgentXMib: PING response received (sid)(tid)(pid)(uptime): (22), (106), (109), (927257)
20141123.11:41:08:   00 10 5C 00 01 00 00 00                            ..\.....
: (2)DEBUG  : LockQueue: adding release request (ptr): (4320162192)
20141123.11:41:08:   00 10 5C 00 01 00 00 00                            ..\.....
: (8)DEBUG  : Synchronized: trylock success (id): (244)
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:08:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : SubAgent: starting thread execution
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:08:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : Agent: finished thread execution
20141123.11:41:08:   00 10 5C 00 01 00 00 00                            ..\.....
: (1)DEBUG  : SubAgentXMib: index (de)allocate response (oid)(err)(errind)(values..): (0), (0), (1.3.6.1.2.1.2.2.1), (1.3.6.1.2.1.2.2.1.1), (0)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (2)DEBUG  : AgentXSlave: sending register PDU (context)(oid)(rangeid)(upper): (), (1.3.6.1.2.1.2.2.1.1.0), (10), (1.3.6.1.2.1.2.2.1.22.0)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (3)EVENT  : AgentX: sending agentx pdu (sd)(type)(sid)(tid)(pid)(err)(errind): (3), (3), (22), (108), (111), (0), (0)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (2)DEBUG  : LockQueue: adding release request (ptr): (4303367056)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (8)DEBUG  : Synchronized: trylock success (id): (244)
20141123.11:41:21:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (4)DEBUG  : AgentXSlave: received something on ports
20141123.11:41:21:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXRequestList: request received (context)(tid)(pid)(siz)(type)(err)(status): (), (108), (111), (1), (18), (0), (0)
20141123.11:41:21:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : LockQueue: adding lock request (ptr): (4320162192)
20141123.11:41:21:   00 70 43 01 01 00 00 00                            .pC.....
: (8)DEBUG  : Synchronized: trylock success (id): (699)
20141123.11:41:21:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:21:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:21:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : SubAgent: starting thread execution
20141123.11:41:21:   00 70 5E 00 01 00 00 00                            .p^.....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:21:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:21:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : Agent: finished thread execution
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (1)DEBUG  : SubAgentXMib: registration success (oid): (1.3.6.1.2.1.2.2.1.1.0)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (2)DEBUG  : LockQueue: adding release request (ptr): (4320162192)
20141123.11:41:21:   00 10 5C 00 01 00 00 00                            ..\.....
: (8)DEBUG  : Synchronized: trylock success (id): (244)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....

: (5)INFO   : AgentXSlave: no request within (milli seconds): (20000)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (3)EVENT  : AgentX: sending agentx pdu (sd)(type)(sid)(tid)(pid)(err)(errind): (3), (13), (22), (109), (113), (0), (0)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXSlave: sending index allocate PDU (sz)(type): (1), (NEW_INDEX)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (3)EVENT  : AgentX: sending agentx pdu (sd)(type)(sid)(tid)(pid)(err)(errind): (3), (14), (22), (110), (114), (0), (0)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (4)DEBUG  : AgentXSlave: received something on ports
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXRequestList: request received (context)(tid)(pid)(siz)(type)(err)(status): (), (109), (113), (0), (18), (0), (0)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : LockQueue: adding lock request (ptr): (4320162192)
20141123.11:41:41:   00 70 43 01 01 00 00 00                            .pC.....
: (8)DEBUG  : Synchronized: trylock success (id): (703)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : SubAgent: starting thread execution
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (4)DEBUG  : AgentXSlave: received something on ports
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)EVENT  : AgentXRequestList: request received (context)(tid)(pid)(siz)(type)(err)(status): (), (110), (114), (1), (18), (260), (0)	<<<< AGENTX_INDEX_NONE_AVAILABLE
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:41:   00 10 5C 00 01 00 00 00                            ..\.....
: (1)INFO   : SubAgentXMib: PING response received (sid)(tid)(pid)(uptime): (22), (109), (113), (930560)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : LockQueue: adding lock request (ptr): (4320163728)
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : Agent: finished thread execution
20141123.11:41:41:   00 10 5C 00 01 00 00 00                            ..\.....
: (2)DEBUG  : LockQueue: adding release request (ptr): (4320162192)
20141123.11:41:41:   00 70 43 01 01 00 00 00                            .pC.....
: (8)DEBUG  : Synchronized: trylock success (id): (706)
20141123.11:41:41:   00 10 5C 00 01 00 00 00                            ..\.....
: (8)DEBUG  : Synchronized: trylock success (id): (244)
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:41:   10 A3 F3 73 FF 7F 00 00                            ...s....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : SubAgent: starting thread execution
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (1)DEBUG  : TaskManager: task manager found
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)DEBUG  : TaskManager: after notify
20141123.11:41:41:   00 70 5E 00 01 00 00 00                            .p^.....
: (2)EVENT  : Agent: finished thread execution
20141123.11:41:41:   00 10 5C 00 01 00 00 00                            ..\.....
: (1)DEBUG  : SubAgentXMib: index (de)allocate response (oid)(err)(errind)(values..): (260), (0), (1.3.6.1.2.1.2.2.1), (1.3.6.1.2.1.2.2.1.1), (0)
subagent(95249,0x1005c1000) malloc: *** error for object 0x1006153a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
(lldb) 
On 23.11.2014, at 09:50, Frank Fock <fock at agentpp.com> wrote:

> Hi Claus,
> 
> There are several index allocation strategies available in AgentX++. You should choose
> the strategy that fits best to your shared table index definition. Using the wrong 
> strategy could lead to a duplicate index registration. 
> 
> Best regards,
> Frank



More information about the AGENTPP mailing list