[AGENT++] Handling result of missing object?

dominik.vogt at external.thalesgroup.com dominik.vogt at external.thalesgroup.com
Tue Jan 25 07:35:26 CET 2011


On Mon, Jan 24, 2011 at 11:15:05PM +0100, Jochen Katz wrote:
>    > * An snmp manager based on snmp++ queries some oid from some snmp
>    >   agent, say 1.3.6.1.2.1.2.2.1.8.10101 (column 8, row 10101 in
>    >   some table).  In case it matters:  In the same request other
>    >   oids in the same table and totally unrelated oids.
>    >
>    > * The row with 1.3.6.1.2.1.2.2.1.8.10101 does not exist, and in
>    >   the response, the agent properly says "no such object".
>    >
>    > * The async response is received by the manager.  Later on the
>    >   code calls pdu.get_vb(vb, ...) for the missing object which returns
>    >   TRUE.
> 
>    yes, this is ok, as the Vb exists.

Alright, I thought as much.

>    > * vb.get_value() does not return SNMP_CLASS_INVALID (I actually
>    >   did not check that ..._SUCCESS is returned, but in the source I
>    >   see that if it's not ...INVALID, it must be ...SUCCESS).
>    >   The actual value returned is some random value from an earlier
>    >   request into that table.
> 
>    You've hit a bug: The snmp++ Pdu parser reuses the previous Vb object.
>    In case of exceptions (nosuchobject, nosuchinstance,...) it uses
>    Vb::set_exception_status(), which does not free the value of the vb. So
>    the get_value() functions return the old value. The patch below fixes
>    this.

Ah, I see.  The patch does indeed fix my problem.  Thank you!

>    Index: include/snmp_pp/vb.h
>    ===================================================================
>    --- include/snmp_pp/vb.h        (Revision 1952)
>    +++ include/snmp_pp/vb.h        (Arbeitskopie)
>    @@ -367,7 +367,7 @@
>        * @param status - the new SNMPv2 exception status.
>        */
>       void set_exception_status(const SmiUINT32 status)
>    -    { exception_status = status; };
>    +    { free_vb(); exception_status = status; };
> 
>       /**
>        * Get the exception status.
> 
>    > How do I detect that the response did not contain a value at all?
> 
>    With Vb::get_exception_status() or get_syntax().

For the records:  With the patch, Vb::get_value() returns
SNMP_CLASS_INVALID, so it's not necessary to add an additional
get_syntax() or get_exception_status().

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt



More information about the AGENTPP mailing list