On Mon, 2005-08-22 at 16:19 +0200, Johannes Schmidt-Fischer wrote:
> The snmpget command seems to have two problems (or errors):
>
> a) for SNMPv1 snmpget returns an error code 2 when the given OID doesn't
> exist, but for SNMPv2c and SNMPv3 snmpget returns an exit code 0 whether
> the given OID exists or not
>
> b) the output from snmpget differs between SNMPv1, SNMPv2c and SNMPv3 if
> the given OID doesn't exist - for SNMPv1 it prints an appropriate error
> message whereas for both other protocols the message looks more like a
> normal output with the difference that the value has been replaced by an
> error message
That's because this is exactly what's happening :-)
With SNMPv1, if a given OID isn't available, then the agent returns
an error ("noSuchName") and the request fails.
With SNMPv2 (i.e. SNMPv2c and SNMPv3), if a given OID isn't available,
then the agent returns an *exception* ("noSuchObject"/"noSuchInstance"),
but the overall request succeeds.
The difference becomes clearer if you asked for two things in the same
request:
snmpget -Cf .... ipRoutingDiscards.0 sysLocation.0
SNMPv1 would return an error (and not display either value).
An SNMPv2 request would succeed, and tell you both that the
ipRoutingDiscards value was not available, and where the system was
located.
> Since checking a test for its correctness first uses the command's exit
> code, and if it is 0 (ok) it checks whether the given OID is part of the
> command's output, the tests for SNMPV2c and SNMPv3 seem to pass the test
> although they fail in reality (and should fail in those test I think).
Yup.
The code to check the validity of the output is not sufficiently
rigourous. It needs to ensure that the output *does* include a value.
I suspect that checking for the syntax token might be sufficient.
> I didn't checked (yet) in the sources but I presume that the second
> problem is a follow-up of the first one. If the command would recognize
> that the given OID doesn't exist it would exit with an appropriate exit
> code and it would show a message saying that the OID doesn't exist
> before exiting.
Except that this is not necessarily appropriate behaviour for the
"snmpget" command (see above).
You're quite correct - the test validation checks need to be updated.
But I don't think your proposed solution is the right way.
> Unfortunately this might mean that passing the net-snmp testsuite for
> net-snmp 5.2.x (this is afaik the first version these tests were
> introduced) without errors in tests 48 and 49 doesn't mean that those
> tests were really ok. Other tests using SNMPv2c or SNMPv3 might be
> affected too but I can't say for sure.
Quite possibly.
But it'll *only* affect GET and GETNEXT (and GETBULK) tests - any
problems with processing SET requests will still return an error,
regardless of SNMP version.
Dave
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders