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

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