Menu

#1040 snmpd logs a non-error when sending response with req-id=0

closed
nobody
None
5
2012-11-09
2010-01-28
Bill Fenner
No

In net-snmp 5.5, the return value of snmp_send() says it's:

* Return on success:
* The request id of the pdu is returned, and the pdu is freed.
* Return on failure:
* Zero (0) is returned.
* The caller must call snmp_free_pdu if 0 is returned.

So, zero means failure. But zero is a valid request id:

PDU ::= SEQUENCE {
request-id INTEGER (-214783648..214783647),

so when a caller (like snmp_agent.c::netsnmp_wrap_up_request() calls snmp_send(), it seems that it must not only check that snmp_send returned zero but also that netsnmp_errno != SUCCESS (and snmp_send should make sure to set netsnmp_errno to success before trying, to enable this type of oob error reporting).

It may be simpler to change snmp_send's return value to simply return 1 if it succeeds or zero if it fails, and if needed find another way to return the request-id. I didn't see any code in agent/ that uses the request-id return value, only success/failure. Or, change the return value to only be the request-id, and make the error indication completely out of band with netsnmp_errno.

Discussion

  • Bill Fenner

    Bill Fenner - 2010-12-01

    A patch that implements my proposed solution: check for errno != SUCCESS if snmp_send returns 0

     
  • Bill Fenner

    Bill Fenner - 2010-12-01

    I've uploaded a patch that leaves snmp_send alone, and just checks for s_snmp_errno != SNMP_SUCCESS in netsnmp_wrap_up_request(). snmp_send() already sets s_snmp_errno to 0 before doing much of anything, so if it is still zero at return it is fairly safe to assume success.

    (I am using the patch with 5.6.)

     
  • Thomas Anders

    Thomas Anders - 2010-12-02

    moving to patches

     
  • Dave Shield

    Dave Shield - 2011-01-06

    Thanks for the patch! It has been applied to the 5.3.x and later code branches and the main development tree, and will appear in future releases of the Net-SNMP package.

     
  • Dave Shield

    Dave Shield - 2011-01-06

    SVN revision 19806

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.