From: Anand Je Sypureddy <anan...@mvista.com> Source: https://github.com/net-snmp/net-snmp.git MR: 114066 Type: Defect Fix Disposition: Backport from https://github.com/net-snmp/net-snmp/commit/951fd2d9b07e29455ff0251b0f44ed76d935ff00 ChangeID: af87abf2aeefdac65fcd57b7faaaa0e3679fe57f Description:
snmpd: Restore SNMPD_CALLBACK_SEND_TRAP[12] behavior Instead of only invoking the SNMPD_CALLBACK_SEND_TRAP[12] callbacks if one or more sessions with the corresponding SNMP version exist, invoke these callbacks unconditionally. Signed-off-by: Anand Je Sypureddy <anan...@mvista.com> Reviewed-by: Sam Kappen <skap...@mvista.com> Signed-off-by: Jeremy Puhlman <jpuhl...@mvista.com> --- ...SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch | 133 ++++++++++++++++++ .../net-snmp/net-snmp_5.8.bb | 1 + 2 files changed, 134 insertions(+) create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmpd-Restore-SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmpd-Restore-SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmpd-Restore-SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch new file mode 100644 index 000000000..8279aff32 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-snmpd-Restore-SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch @@ -0,0 +1,133 @@ +From 6be94cf81d56f9395b85848bbf7129eb9f992d96 Mon Sep 17 00:00:00 2001 +From: Bart Van Assche <bvanass...@acm.org> +Date: Tue, 29 Dec 2020 15:22:42 -0800 +Subject: [PATCH] snmpd: Restore SNMPD_CALLBACK_SEND_TRAP[12] behavior + +Instead of only invoking the SNMPD_CALLBACK_SEND_TRAP[12] callbacks if one +or more sessions with the corresponding SNMP version exist, invoke these +callbacks unconditionally. + +Fixes: f770e0f74932 ("skip send_trap callbacks if no sessions for version") +Fixes: https://github.com/net-snmp/net-snmp/issues/247 + +Upstream Status: Backport https://github.com/net-snmp/net-snmp/commit/951fd2d9b07e29455ff0251b0f44ed76d935ff00 + +Signed-off-by: Anand Je Sypureddy <anan...@mvista.com> +--- + agent/agent_trap.c | 62 ++-------------------------------------------- + 1 file changed, 2 insertions(+), 60 deletions(-) + +diff --git a/agent/agent_trap.c b/agent/agent_trap.c +index d49c2dc..0289901 100644 +--- a/agent/agent_trap.c ++++ b/agent/agent_trap.c +@@ -92,11 +92,6 @@ struct trap_sink { + + struct trap_sink *sinks = NULL; + +-#ifndef NETSNMP_DISABLE_SNMPV1 +-static int _v1_sessions = 0; +-#endif /* NETSNMP_DISABLE_SNMPV1 */ +-static int _v2_sessions = 0; +- + const oid objid_enterprisetrap[] = { NETSNMP_NOTIFICATION_MIB }; + const oid trap_version_id[] = { NETSNMP_SYSTEM_MIB }; + const int enterprisetrap_len = OID_LENGTH(objid_enterprisetrap); +@@ -159,55 +154,6 @@ free_trap_session(struct trap_sink *sp) + free(sp); + } + +-static void +-_trap_version_incr(int version) +-{ +- switch (version) { +-#ifndef NETSNMP_DISABLE_SNMPV1 +- case SNMP_VERSION_1: +- ++_v1_sessions; +- break; +-#endif +-#ifndef NETSNMP_DISABLE_SNMPV2C +- case SNMP_VERSION_2c: +-#endif +- case SNMP_VERSION_3: +- ++_v2_sessions; +- break; +- default: +- snmp_log(LOG_ERR, "unknown snmp version %d\n", version); +- } +- return; +-} +- +-static void +-_trap_version_decr(int version) +-{ +- switch (version) { +-#ifndef NETSNMP_DISABLE_SNMPV1 +- case SNMP_VERSION_1: +- if (--_v1_sessions < 0) { +- snmp_log(LOG_ERR,"v1 session count < 0! fixed.\n"); +- _v1_sessions = 0; +- } +- break; +-#endif +-#ifndef NETSNMP_DISABLE_SNMPV2C +- case SNMP_VERSION_2c: +-#endif +- case SNMP_VERSION_3: +- if (--_v2_sessions < 0) { +- snmp_log(LOG_ERR,"v2 session count < 0! fixed.\n"); +- _v2_sessions = 0; +- } +- break; +- default: +- snmp_log(LOG_ERR, "unknown snmp version %d\n", version); +- } +- return; +-} +- +- + #ifndef NETSNMP_NO_TRAP_STATS + static void + _dump_trap_stats(netsnmp_session *sess) +@@ -285,8 +231,6 @@ netsnmp_add_notification_session(netsnmp_session * ss, int pdutype, + sinks = new_sink; + } + +- _trap_version_incr(version); +- + return 1; + } + +@@ -338,7 +282,6 @@ remove_trap_session(netsnmp_session * ss) + } else { + sinks = sp->next; + } +- _trap_version_decr(ss->version); + /* + * I don't believe you *really* want to close the session here; + * it may still be in use for other purposes. In particular this +@@ -490,7 +433,6 @@ snmpd_free_trapsinks(void) + DEBUGMSGTL(("trap", "freeing trap sessions\n")); + while (sp) { + sinks = sinks->next; +- _trap_version_decr(sp->version); + free_trap_session(sp); + sp = sinks; + } +@@ -1025,11 +967,11 @@ netsnmp_send_traps(int trap, int specific, + } + } + #ifndef NETSNMP_DISABLE_SNMPV1 +- if (template_v1pdu && _v1_sessions) ++ if (template_v1pdu) + snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, + SNMPD_CALLBACK_SEND_TRAP1, template_v1pdu); + #endif +- if (template_v2pdu && _v2_sessions) ++ if (template_v2pdu) + snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, + SNMPD_CALLBACK_SEND_TRAP2, template_v2pdu); + snmp_free_pdu(template_v1pdu); +-- +2.25.1 + diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.8.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.8.bb index 6b4b6ce8e..b28e71890 100644 --- a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.8.bb +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.8.bb @@ -35,6 +35,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \ file://CVE-2020-15861-0004.patch \ file://CVE-2020-15861-0005.patch \ file://CVE-2020-15862.patch \ + file://0001-snmpd-Restore-SNMPD_CALLBACK_SEND_TRAP-12-behavior.patch \ " SRC_URI[md5sum] = "63bfc65fbb86cdb616598df1aff6458a" SRC_URI[sha256sum] = "b2fc3500840ebe532734c4786b0da4ef0a5f67e51ef4c86b3345d697e4976adf" -- 2.31.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#96557): https://lists.openembedded.org/g/openembedded-devel/message/96557 Mute This Topic: https://lists.openembedded.org/mt/90406993/21656 Group Owner: openembedded-devel+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-