[AGENT++] illegal value at RowStatus after commitFailed

Frank Fock fock at agentpp.com
Sun Apr 12 11:22:17 CEST 2015


Hi Claus,

In ::prepare_set_request you should check if the commit will succeed and 
lock
corresponding resources. If you cannot check some operation then the ::set
(or ::commit_set_request) may fail. However, in case of the ::snmpRowStatus
you should call the super class first to allow it it create the undo 
value etc.

Beste regards,
Frank

Am 11.04.2015 um 22:21 schrieb Claus Klein:
> Hi Frank,
>
>> On 11 Apr 2015, at 16:26, Frank Fock <fock at agentpp.com 
>> <mailto:fock at agentpp.com>> wrote:
>>
>> Hi Claus,
>>
>> The code of snmpRowStatus::unset() is correct as it is. If there is 
>> no undo value (undo == NULL)
>> the undo cannot fail because there is nothing to undo.
> OK, I agree.
>
>> The problem with the row creation is caused something else. If the 
>> row creation fails, the new
>> (intermediate) row has to be deleted (not added) to the table, but 
>> that works only if an
>> undo value had been set.
> That was my expectation.
>
>>
>> In your cause this seems not to be happened. Why?
>> A possible cause could be an overwriting of the snmpRowStatus::set 
>> method in a snmpRowStatus
>> sub-class.
>> Other causes have to be found or sorted out by debugging the code.
> The problem occurred because the call to netSnmpExampleInteger::set() 
> fails (hard coded for demo).
>
> intnetSnmpExampleInteger::set(constVbx& vb)
> {
> //--AgentGen BEGIN=netSnmpExampleInteger::set
> returnSNMP_ERROR_AUTH_ERR;//FIXME only for test
> //--AgentGen END
> #ifdef MIB_TRACE
> std::cerr<< BOOST_CURRENT_FUNCTION<< std::endl; // XXX
> #endif // MIB_TRACE
> return MibLeaf::set(vb);
> }
>
> int netSnmpExampleInteger::commit_set_request(Request* req, int ind)
> {
> //--AgentGen BEGIN=netSnmpExampleInteger::commit_set_request
> returnSNMP_ERROR_COMITFAIL; // FIXME READONLY for test!
> //--AgentGen END
> #ifdef MIB_TRACE
> std::cerr<< BOOST_CURRENT_FUNCTION<< std::endl; // XXX
> #endif // MIB_TRACE
> int status = MibLeaf::commit_set_request(req, ind);
> //--AgentGen BEGIN=netSnmpExampleInteger::commit_set_request2
> //--AgentGen END
> return status;
> }
>
>
> A general question:
> When should I write to the HW, file, driver or what ever is below the 
> MIB entry?
>
> I use the set() method. But in our project, this may fail in some cases!
>
> Best regards
> Claus
>
>
>>
>> Best regards,
>> Frank
>>
>>
>> Am 08.04.2015 um 23:20 schrieb Claus Klein:
>>> Hi all,
>>>
>>> I found a problem with the table RowStatus and snmpRowStatus::unset():
>>>
>>> Claus-MBP:AgentPro clausklein$ snmpset -r0 -t10 -v3 -u unsecureUser 
>>> -n subagent localhost:4700 'netSnmpHostRowStatus."test2"' = 
>>> createAndGo \
>>>     'netSnmpHostAddressType."test2"' = ipv4 
>>> 'netSnmpHostAddress."test2"' x 7F000002  netSnmpExampleInteger.0 = 1
>>> Error in packet.
>>> Reason: commitFailed
>>> Failed object: NET-SNMP-EXAMPLES-MIB::netSnmpExampleInteger.0
>>>
>>> Claus-MBP:AgentPro clausklein$ snmptable -Cib -r0 -t10 -v3 -u 
>>> unsecureUser -n subagent localhost:4700 netSnmpHostsTable
>>> SNMP table: NET-SNMP-EXAMPLES-MIB::netSnmpHostsTable
>>>
>>>             index AddressType 
>>>                                            Address     Storage RowStatus
>>>         \"nmsv6\"        ipv6 "00 00 00 00 00 00 00 00 00 00 00 00 
>>> 00 00 00 01 " nonVolatile    active
>>>         \"test2\"     unknown 
>>>                                                 "" nonVolatile         0
>>>     \"localhost\"        ipv6 "00 00 00 00 00 00 00 00 00 00 00 00 
>>> 00 00 00 01 " nonVolatile    active
>>> \"broadcasthost\"        ipv4 
>>>                                     "FF FF FF FF " nonVolatile    active
>>> Claus-MBP:AgentPro clausklein$
>>>
>>> The undo ptr is NULL in this case and the row left in an illegal state?
>>> By the way, older versions of agent++ lib use this NULL pointer and 
>>> crash!
>>>
>>> Is this a BUG or a feature?
>>>
>>> Should the code be like this:
>>> diff --git a/agent++/src/mib.cpp b/agent++/src/mib.cpp
>>> index 5d41353..64b57be 100644
>>> --- a/agent++/src/mib.cpp
>>> +++ b/agent++/src/mib.cpp
>>> @@ -668,8 +668,9 @@ int snmpRowStatus::unset()
>>>                 value = undo;
>>>                 undo = 0;
>>>         }
>>> +       return SNMP_ERROR_SUCCESS;
>>>    }
>>> -  return SNMP_ERROR_SUCCESS;
>>> +  return SNMP_ERROR_UNDO_FAIL;
>>>  }
>>>    /**
>>>
>>> Best regards
>>> Claus
>>> _______________________________________________
>>> AGENTPP mailing list
>>> AGENTPP at agentpp.org <mailto:AGENTPP at agentpp.org>
>>> https://oosnmp.net/mailman/listinfo/agentpp
>>
>> -- 
>> ---
>> AGENT++
>> Maximilian-Kolbe-Str. 10
>> 73257 Koengen, Germany
>> https://agentpp.com
>> Phone: +49 7024 8688230
>> Fax:   +49 7024 8688231
>>
>> _______________________________________________
>> AGENTPP mailing list
>> AGENTPP at agentpp.org
>> https://oosnmp.net/mailman/listinfo/agentpp
>

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the AGENTPP mailing list