Blob Blame History Raw
Bug 1146948 - snmptrapd "Forward failed" when SNMPv3 requestid=0
Bug 1192511 - snmptrapd "Forward failed" when SNMPv3 requestid=0

commit 148f2de48e1cd6ba8ebdab8591424df64ab967a3
Author: Jan Safranek <jsafranek@users.sourceforge.net>
Date:   Thu Feb 5 14:01:44 2015 +0100

    CHANGES: snmptrapd: Correctly forward traps with Request-ID '0'.
    
    Request-ID of forwarded traps is taken from the incoming trap and it can be zero.
    We should not report error in this case.

diff --git a/apps/snmptrapd_handlers.c b/apps/snmptrapd_handlers.c
index 37ca5ab..74cc62e 100644
--- a/apps/snmptrapd_handlers.c
+++ b/apps/snmptrapd_handlers.c
@@ -1013,9 +1013,12 @@ int   forward_handler( netsnmp_pdu           *pdu,
         pdu2->transport_data        = NULL;
         pdu2->transport_data_length = 0;
     }
-    if (!snmp_send( ss, pdu2 )) {
-	snmp_sess_perror("Forward failed", ss);
-	snmp_free_pdu(pdu2);
+
+    ss->s_snmp_errno = SNMPERR_SUCCESS;
+    if (!snmp_send( ss, pdu2 ) &&
+            ss->s_snmp_errno != SNMPERR_SUCCESS) {
+        snmp_sess_perror("Forward failed", ss);
+        snmp_free_pdu(pdu2);
     }
     snmp_close( ss );
     return NETSNMPTRAPD_HANDLER_OK;