Resolves: #1663027 - fix daemon crash on resend request
This commit is contained in:
parent
2bee86eba7
commit
1c3bbf5bde
122
net-snmp-5.8-agent-of-death.patch
Normal file
122
net-snmp-5.8-agent-of-death.patch
Normal file
@ -0,0 +1,122 @@
|
||||
diff -urNp a/agent/agent_trap.c b/agent/agent_trap.c
|
||||
--- a/agent/agent_trap.c 2019-02-13 13:10:36.862269252 +0100
|
||||
+++ b/agent/agent_trap.c 2019-02-13 15:02:11.396042356 +0100
|
||||
@@ -174,6 +174,11 @@ _trap_version_incr(int version)
|
||||
case SNMP_VERSION_3:
|
||||
++_v2_sessions;
|
||||
break;
|
||||
+#ifdef USING_AGENTX_PROTOCOL_MODULE
|
||||
+ case AGENTX_VERSION_1:
|
||||
+ /* agentx registers in sinks, no need to count */
|
||||
+ break;
|
||||
+#endif
|
||||
default:
|
||||
snmp_log(LOG_ERR, "unknown snmp version %d\n", version);
|
||||
}
|
||||
@@ -201,6 +206,11 @@ _trap_version_decr(int version)
|
||||
_v2_sessions = 0;
|
||||
}
|
||||
break;
|
||||
+#ifdef USING_AGENTX_PROTOCOL_MODULE
|
||||
+ case AGENTX_VERSION_1:
|
||||
+ /* agentx registers in sinks, no need to count */
|
||||
+ break;
|
||||
+#endif
|
||||
default:
|
||||
snmp_log(LOG_ERR, "unknown snmp version %d\n", version);
|
||||
}
|
||||
diff -urNp old/agent/mibgroup/agentx/master.c new/agent/mibgroup/agentx/master.c
|
||||
--- old/agent/mibgroup/agentx/master.c 2019-04-03 12:13:55.115769783 +0200
|
||||
+++ new/agent/mibgroup/agentx/master.c 2019-04-10 09:49:53.277168497 +0200
|
||||
@@ -280,6 +280,11 @@ agentx_got_response(int operation,
|
||||
netsnmp_free_delegated_cache(cache);
|
||||
return 0;
|
||||
|
||||
+ case NETSNMP_CALLBACK_OP_RESEND:
|
||||
+ DEBUGMSGTL(("agentx/master", "resend on session %8p req=0x%x\n",
|
||||
+ session, (unsigned)reqid));
|
||||
+ return 0;
|
||||
+
|
||||
case NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE:
|
||||
/*
|
||||
* This session is alive
|
||||
diff -urNp old/snmplib/snmp_api.c new/snmplib/snmp_api.c
|
||||
--- old/snmplib/snmp_api.c 2019-04-24 00:28:34.904357292 +0200
|
||||
+++ new/snmplib/snmp_api.c 2019-04-24 00:24:40.101830685 +0200
|
||||
@@ -352,6 +352,7 @@ static int snmpv3_build(u_char ** p
|
||||
netsnmp_pdu *pdu);
|
||||
static int snmp_parse_version(u_char *, size_t);
|
||||
static int snmp_resend_request(struct session_list *slp,
|
||||
+ netsnmp_request_list *orp,
|
||||
netsnmp_request_list *rp,
|
||||
int incr_retries);
|
||||
static void register_default_handlers(void);
|
||||
@@ -5717,7 +5718,7 @@ _sess_process_packet_handle_pdu(void *se
|
||||
* * inifinite resend
|
||||
*/
|
||||
if (rp->retries <= sp->retries) {
|
||||
- snmp_resend_request(slp, rp, TRUE);
|
||||
+ snmp_resend_request(slp, orp, rp, TRUE);
|
||||
break;
|
||||
} else {
|
||||
/* We're done with retries, so no longer waiting for a response */
|
||||
@@ -6662,9 +6663,22 @@ snmp_timeout(void)
|
||||
snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
|
||||
}
|
||||
|
||||
+static void
|
||||
+remove_request(struct snmp_internal_session *isp,
|
||||
+ netsnmp_request_list *orp, netsnmp_request_list *rp)
|
||||
+{
|
||||
+ if (orp)
|
||||
+ orp->next_request = rp->next_request;
|
||||
+ else
|
||||
+ isp->requests = rp->next_request;
|
||||
+ if (isp->requestsEnd == rp)
|
||||
+ isp->requestsEnd = orp;
|
||||
+ snmp_free_pdu(rp->pdu);
|
||||
+}
|
||||
+
|
||||
static int
|
||||
-snmp_resend_request(struct session_list *slp, netsnmp_request_list *rp,
|
||||
- int incr_retries)
|
||||
+snmp_resend_request(struct session_list *slp, netsnmp_request_list *orp,
|
||||
+ netsnmp_request_list *rp, int incr_retries)
|
||||
{
|
||||
struct snmp_internal_session *isp;
|
||||
netsnmp_session *sp;
|
||||
@@ -6731,9 +6745,11 @@ snmp_resend_request(struct session_list
|
||||
sp->s_snmp_errno = SNMPERR_BAD_SENDTO;
|
||||
sp->s_errno = errno;
|
||||
snmp_set_detail(strerror(errno));
|
||||
- if (rp->callback)
|
||||
+ if (rp->callback) {
|
||||
rp->callback(NETSNMP_CALLBACK_OP_SEND_FAILED, sp,
|
||||
rp->pdu->reqid, rp->pdu, rp->cb_data);
|
||||
+ remove_request(isp, orp, rp);
|
||||
+ }
|
||||
return -1;
|
||||
} else {
|
||||
netsnmp_get_monotonic_clock(&now);
|
||||
@@ -6813,19 +6829,12 @@ snmp_sess_timeout(void *sessp)
|
||||
callback(NETSNMP_CALLBACK_OP_TIMED_OUT, sp,
|
||||
rp->pdu->reqid, rp->pdu, magic);
|
||||
}
|
||||
- if (orp)
|
||||
- orp->next_request = rp->next_request;
|
||||
- else
|
||||
- isp->requests = rp->next_request;
|
||||
- if (isp->requestsEnd == rp)
|
||||
- isp->requestsEnd = orp;
|
||||
- snmp_free_pdu(rp->pdu);
|
||||
+ remove_request(isp, orp, rp);
|
||||
freeme = rp;
|
||||
continue; /* don't update orp below */
|
||||
} else {
|
||||
- if (snmp_resend_request(slp, rp, TRUE)) {
|
||||
+ if (snmp_resend_request(slp, orp, rp, TRUE))
|
||||
break;
|
||||
- }
|
||||
}
|
||||
}
|
||||
orp = rp;
|
@ -43,6 +43,7 @@ Patch13: net-snmp-5.8-key-leak-backport.patch
|
||||
Patch14: net-snmp-5.8-python-ld-flags.patch
|
||||
Patch15: net-snmp-5.8-ipv6-clientaddr.patch
|
||||
Patch16: net-snmp-5.8-licensing.patch
|
||||
Patch17: net-snmp-5.8-agent-of-death.patch
|
||||
|
||||
# Modern RPM API means at least EL6
|
||||
Patch101: net-snmp-5.8-modern-rpm-api.patch
|
||||
@ -213,6 +214,7 @@ cp %{SOURCE10} .
|
||||
%patch14 -p1 -b .python-ld-flags
|
||||
%patch15 -p1 -b .ipv6-clientaddr
|
||||
%patch16 -p1
|
||||
%patch17 -p1 -b .agent-of-death
|
||||
|
||||
%patch101 -p1 -b .modern-rpm-api
|
||||
%patch102 -p1
|
||||
@ -485,6 +487,7 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
|
||||
%changelog
|
||||
* Fri Jun 28 2019 Josef Ridky <jridky@redhat.com> - 1:5.8-10
|
||||
- remove file with unsupported license
|
||||
- fix daemon crash on resend request (#1663027)
|
||||
|
||||
* Mon Jun 10 22:13:21 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1:5.8-9
|
||||
- Rebuild for RPM 4.15
|
||||
|
Loading…
Reference in New Issue
Block a user