Blame SOURCES/net-snmp-5.8-agent-of-death.patch

23ac29
diff -urNp a/agent/agent_trap.c b/agent/agent_trap.c
23ac29
--- a/agent/agent_trap.c	2019-02-13 13:10:36.862269252 +0100
23ac29
+++ b/agent/agent_trap.c	2019-02-13 15:02:11.396042356 +0100
23ac29
@@ -174,6 +174,11 @@ _trap_version_incr(int version)
23ac29
         case SNMP_VERSION_3:
23ac29
             ++_v2_sessions;
23ac29
             break;
23ac29
+#ifdef USING_AGENTX_PROTOCOL_MODULE
23ac29
+        case AGENTX_VERSION_1:
23ac29
+            /* agentx registers in sinks, no need to count */
23ac29
+            break;
23ac29
+#endif
23ac29
         default:
23ac29
             snmp_log(LOG_ERR, "unknown snmp version %d\n", version);
23ac29
     }
23ac29
@@ -201,6 +206,11 @@ _trap_version_decr(int version)
23ac29
                 _v2_sessions = 0;
23ac29
             }
23ac29
             break;
23ac29
+#ifdef USING_AGENTX_PROTOCOL_MODULE
23ac29
+        case AGENTX_VERSION_1:
23ac29
+            /* agentx registers in sinks, no need to count */
23ac29
+            break;
23ac29
+#endif
23ac29
         default:
23ac29
             snmp_log(LOG_ERR, "unknown snmp version %d\n", version);
23ac29
     }
23ac29
diff -urNp old/agent/mibgroup/agentx/master.c new/agent/mibgroup/agentx/master.c
23ac29
--- old/agent/mibgroup/agentx/master.c	2019-04-03 12:13:55.115769783 +0200
23ac29
+++ new/agent/mibgroup/agentx/master.c	2019-04-10 09:49:53.277168497 +0200
23ac29
@@ -280,6 +280,11 @@ agentx_got_response(int operation,
23ac29
         netsnmp_free_delegated_cache(cache);
23ac29
         return 0;
23ac29
 
23ac29
+    case NETSNMP_CALLBACK_OP_RESEND:
23ac29
+        DEBUGMSGTL(("agentx/master", "resend on session %8p req=0x%x\n",
23ac29
+                    session, (unsigned)reqid));
23ac29
+        return 0;
23ac29
+
23ac29
     case NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE:
23ac29
         /*
23ac29
          * This session is alive 
23ac29
diff -urNp old/snmplib/snmp_api.c new/snmplib/snmp_api.c
23ac29
--- old/snmplib/snmp_api.c	2019-04-24 00:28:34.904357292 +0200
23ac29
+++ new/snmplib/snmp_api.c	2019-04-24 00:24:40.101830685 +0200
23ac29
@@ -352,6 +352,7 @@ static int      snmpv3_build(u_char ** p
23ac29
                              netsnmp_pdu *pdu);
23ac29
 static int      snmp_parse_version(u_char *, size_t);
23ac29
 static int      snmp_resend_request(struct session_list *slp,
23ac29
+                                    netsnmp_request_list *orp,
23ac29
                                     netsnmp_request_list *rp,
23ac29
                                     int incr_retries);
23ac29
 static void     register_default_handlers(void);
23ac29
@@ -5717,7 +5718,7 @@ _sess_process_packet_handle_pdu(void *se
23ac29
 	     * * inifinite resend                      
23ac29
 	     */
23ac29
 	    if (rp->retries <= sp->retries) {
23ac29
-	      snmp_resend_request(slp, rp, TRUE);
23ac29
+	      snmp_resend_request(slp, orp, rp, TRUE);
23ac29
 	      break;
23ac29
 	    } else {
23ac29
 	      /* We're done with retries, so no longer waiting for a response */
23ac29
@@ -6662,9 +6663,22 @@ snmp_timeout(void)
23ac29
     snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
23ac29
 }
23ac29
 
23ac29
+static void
23ac29
+remove_request(struct snmp_internal_session *isp,
23ac29
+               netsnmp_request_list *orp, netsnmp_request_list *rp)
23ac29
+{
23ac29
+    if (orp)
23ac29
+        orp->next_request = rp->next_request;
23ac29
+    else
23ac29
+        isp->requests = rp->next_request;
23ac29
+    if (isp->requestsEnd == rp)
23ac29
+        isp->requestsEnd = orp;
23ac29
+    snmp_free_pdu(rp->pdu);
23ac29
+}
23ac29
+
23ac29
 static int
23ac29
-snmp_resend_request(struct session_list *slp, netsnmp_request_list *rp,
23ac29
-                    int incr_retries)
23ac29
+snmp_resend_request(struct session_list *slp, netsnmp_request_list *orp,
23ac29
+                    netsnmp_request_list *rp, int incr_retries)
23ac29
 {
23ac29
     struct snmp_internal_session *isp;
23ac29
     netsnmp_session *sp;
23ac29
@@ -6731,9 +6745,11 @@ snmp_resend_request(struct session_list
23ac29
         sp->s_snmp_errno = SNMPERR_BAD_SENDTO;
23ac29
         sp->s_errno = errno;
23ac29
         snmp_set_detail(strerror(errno));
23ac29
-        if (rp->callback)
23ac29
+        if (rp->callback) {
23ac29
             rp->callback(NETSNMP_CALLBACK_OP_SEND_FAILED, sp,
23ac29
                          rp->pdu->reqid, rp->pdu, rp->cb_data);
23ac29
+            remove_request(isp, orp, rp);
23ac29
+        }
23ac29
         return -1;
23ac29
     } else {
23ac29
         netsnmp_get_monotonic_clock(&now;;
23ac29
@@ -6813,19 +6829,12 @@ snmp_sess_timeout(void *sessp)
23ac29
                     callback(NETSNMP_CALLBACK_OP_TIMED_OUT, sp,
23ac29
                              rp->pdu->reqid, rp->pdu, magic);
23ac29
                 }
23ac29
-                if (orp)
23ac29
-                    orp->next_request = rp->next_request;
23ac29
-                else
23ac29
-                    isp->requests = rp->next_request;
23ac29
-                if (isp->requestsEnd == rp)
23ac29
-                    isp->requestsEnd = orp;
23ac29
-                snmp_free_pdu(rp->pdu);
23ac29
+                remove_request(isp, orp, rp); 
23ac29
                 freeme = rp;
23ac29
                 continue;       /* don't update orp below */
23ac29
             } else {
23ac29
-                if (snmp_resend_request(slp, rp, TRUE)) {
23ac29
+                if (snmp_resend_request(slp, orp, rp, TRUE))
23ac29
                     break;
23ac29
-                }
23ac29
             }
23ac29
         }
23ac29
         orp = rp;