From 828e6a6e1e0a9d9b98aa75990d98f80ff1dbcb268463c5976170e8793a5a928d Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Tue, 17 Apr 2012 20:00:04 +0000 Subject: [PATCH] Accepting request 113786 from net-snmp:factory Automatic submission by obs-autosubmit OBS-URL: https://build.opensuse.org/request/show/113786 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/net-snmp?expand=0&rev=56 --- net-snmp-5.7.1-agentx-crash.patch | 23 ------ ...-crashing-when-an-agentx-disconnects.patch | 54 +++++++++++++ ...snmp-5.7.1-log-agentx-disconnections.patch | 24 ++++++ ...ore-robust-handling-of-agentx-errors.patch | 76 +++++++++++++++++++ ...y-clean-up-old-requests-in-subagents.patch | 58 ++++++++++++++ net-snmp-5.7.1-recognize-ocfs2.patch | 32 ++++++++ ....1-reduce-code-duplication-in-agentx.patch | 55 ++++++++++++++ ...ort-problems-with-setundo-processing.patch | 19 +++++ net-snmp.changes | 11 +++ net-snmp.spec | 16 +++- 10 files changed, 343 insertions(+), 25 deletions(-) delete mode 100644 net-snmp-5.7.1-agentx-crash.patch create mode 100644 net-snmp-5.7.1-fix-snmpd-crashing-when-an-agentx-disconnects.patch create mode 100644 net-snmp-5.7.1-log-agentx-disconnections.patch create mode 100644 net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch create mode 100644 net-snmp-5.7.1-properly-clean-up-old-requests-in-subagents.patch create mode 100644 net-snmp-5.7.1-recognize-ocfs2.patch create mode 100644 net-snmp-5.7.1-reduce-code-duplication-in-agentx.patch create mode 100644 net-snmp-5.7.1-report-problems-with-setundo-processing.patch diff --git a/net-snmp-5.7.1-agentx-crash.patch b/net-snmp-5.7.1-agentx-crash.patch deleted file mode 100644 index 0e7a203..0000000 --- a/net-snmp-5.7.1-agentx-crash.patch +++ /dev/null @@ -1,23 +0,0 @@ -Index: net-snmp-5.7.1.rc1/agent/mibgroup/agentx/master_admin.c -=================================================================== ---- net-snmp-5.7.1.rc1.orig/agent/mibgroup/agentx/master_admin.c -+++ net-snmp-5.7.1.rc1/agent/mibgroup/agentx/master_admin.c -@@ -135,11 +135,16 @@ close_agentx_session(netsnmp_session * s - * requests, so that the delegated request will be completed and - * further requests can be processed - */ -- netsnmp_remove_delegated_requests_for_session(session); -+ while (netsnmp_remove_delegated_requests_for_session(session)) { -+ DEBUGMSGTL(("agentx/master", "Continue removing delegated requests\n")); -+ } -+ - if (session->subsession != NULL) { - netsnmp_session *subsession = session->subsession; - for(; subsession; subsession = subsession->next) { -- netsnmp_remove_delegated_requests_for_session(subsession); -+ while (netsnmp_remove_delegated_requests_for_session(subsession)) { -+ DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession requests\n")); -+ } - } - } - diff --git a/net-snmp-5.7.1-fix-snmpd-crashing-when-an-agentx-disconnects.patch b/net-snmp-5.7.1-fix-snmpd-crashing-when-an-agentx-disconnects.patch new file mode 100644 index 0000000..c5f2eef --- /dev/null +++ b/net-snmp-5.7.1-fix-snmpd-crashing-when-an-agentx-disconnects.patch @@ -0,0 +1,54 @@ +commit f9304c83f76202db0e684269ca1af32e43cd9db4 +Author: Jan Safranek +Date: Tue Feb 7 14:53:44 2012 +0100 + + CHANGES: PATCH 1633670: fixed snmpd crashing when an AgentX subagent disconnect in the middle of processing of a request. + + I fixed also the memory leak reported in the tracker comments. + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/master.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/master.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/master.c +@@ -219,6 +219,9 @@ agentx_got_response(int operation, + if (!cache) { + DEBUGMSGTL(("agentx/master", "response too late on session %8p\n", + session)); ++ /* response is too late, free the cache */ ++ if (magic) ++ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic); + return 0; + } + requests = cache->requests; +@@ -606,6 +609,8 @@ agentx_master_handler(netsnmp_mib_handle + result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data); + if (result == 0) { + snmp_free_pdu(pdu); ++ if (cb_data) ++ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) cb_data); + } + + return SNMP_ERR_NOERROR; +Index: net-snmp-5.7.1/agent/mibgroup/agentx/master_admin.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/master_admin.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/master_admin.c +@@ -135,11 +135,16 @@ close_agentx_session(netsnmp_session * s + * requests, so that the delegated request will be completed and + * further requests can be processed + */ +- netsnmp_remove_delegated_requests_for_session(session); ++ while (netsnmp_remove_delegated_requests_for_session(session)) { ++ DEBUGMSGTL(("agentx/master", "Continue removing delegated reqests\n")); ++ } ++ + if (session->subsession != NULL) { + netsnmp_session *subsession = session->subsession; + for(; subsession; subsession = subsession->next) { +- netsnmp_remove_delegated_requests_for_session(subsession); ++ while (netsnmp_remove_delegated_requests_for_session(subsession)) { ++ DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession reqests\n")); ++ } + } + } + diff --git a/net-snmp-5.7.1-log-agentx-disconnections.patch b/net-snmp-5.7.1-log-agentx-disconnections.patch new file mode 100644 index 0000000..bdb89db --- /dev/null +++ b/net-snmp-5.7.1-log-agentx-disconnections.patch @@ -0,0 +1,24 @@ +commit 1be8cf08a67a91855fee1ec4a2d8e087c7812456 +Author: Dave Shield +Date: Tue Dec 27 18:04:10 2011 +0000 + + CHANGES: agentx: PATCHES: 3445437: Log AgentX disconnections + (in line with connections) Patch provided by Bill Fenner + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +@@ -298,8 +298,10 @@ handle_agentx_packet(int operation, nets + * agentx_reopen_session unregisters itself if it succeeds in talking + * to the master agent. + */ +- snmp_alarm_register(period, SA_REPEAT, agentx_reopen_session, +- NULL); ++ snmp_alarm_register(period, SA_REPEAT, agentx_reopen_session, NULL); ++ snmp_log(LOG_INFO, "AgentX master disconnected us, reconnecting in %d\n", period); ++ } else { ++ snmp_log(LOG_INFO, "AgentX master disconnected us, not reconnecting\n"); + } + return 0; + } else if (operation != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE) { diff --git a/net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch b/net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch new file mode 100644 index 0000000..18d2194 --- /dev/null +++ b/net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch @@ -0,0 +1,76 @@ +commit 2a17b37430c1852998c3588e547d7eb61c06da71 +Author: Dave Shield +Date: Tue Dec 27 21:45:38 2011 +0000 + + CHANGES: agentx: PATCHES: 3445440: More robust handling of AgentX errors + Patch provided by Bill Fenner + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +@@ -243,6 +243,24 @@ free_set_vars(netsnmp_session * ss, nets + } + #endif /* !NETSNMP_NO_WRITE_SUPPORT */ + ++static void ++send_agentx_error(netsnmp_session *session, netsnmp_pdu *pdu, int errstat, int errindex) ++{ ++ pdu = snmp_clone_pdu(pdu); ++ pdu->command = AGENTX_MSG_RESPONSE; ++ pdu->version = session->version; ++ pdu->errstat = errstat; ++ pdu->errindex = errindex; ++ snmp_free_varbind(pdu->variables); ++ pdu->variables = NULL; ++ ++ DEBUGMSGTL(("agentx/subagent", "Sending AgentX response error stat %d idx %d\n", ++ errstat, errindex)); ++ if (!snmp_send(session, pdu)) { ++ snmp_free_pdu(pdu); ++ } ++} ++ + int + handle_agentx_packet(int operation, netsnmp_session * session, int reqid, + netsnmp_pdu *pdu, void *magic) +@@ -327,6 +345,7 @@ handle_agentx_packet(int operation, nets + (ns_subagent_magic *) calloc(1, sizeof(ns_subagent_magic)); + if (smagic == NULL) { + DEBUGMSGTL(("agentx/subagent", "couldn't malloc() smagic\n")); ++ /* would like to send_agentx_error(), but it needs memory too */ + return 1; + } + smagic->original_command = pdu->command; +@@ -391,6 +410,7 @@ handle_agentx_packet(int operation, nets + if (asi == NULL) { + SNMP_FREE(smagic); + snmp_log(LOG_WARNING, "save_set_vars() failed\n"); ++ send_agentx_error(session, pdu, AGENTX_ERR_PARSE_FAILED, 0); + return 1; + } + asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_RESERVE1; +@@ -404,6 +424,7 @@ handle_agentx_packet(int operation, nets + if (asi == NULL) { + SNMP_FREE(smagic); + snmp_log(LOG_WARNING, "restore_set_vars() failed\n"); ++ send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); + return 1; + } + if (asi->mode != SNMP_MSG_INTERNAL_SET_RESERVE2) { +@@ -411,6 +432,7 @@ handle_agentx_packet(int operation, nets + snmp_log(LOG_WARNING, + "dropping bad AgentX request (wrong mode %d)\n", + asi->mode); ++ send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); + return 1; + } + asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_ACTION; +@@ -424,6 +446,7 @@ handle_agentx_packet(int operation, nets + if (asi == NULL) { + SNMP_FREE(smagic); + snmp_log(LOG_WARNING, "restore_set_vars() failed\n"); ++ send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); + return 1; + } + if (asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE1 || diff --git a/net-snmp-5.7.1-properly-clean-up-old-requests-in-subagents.patch b/net-snmp-5.7.1-properly-clean-up-old-requests-in-subagents.patch new file mode 100644 index 0000000..5af4aff --- /dev/null +++ b/net-snmp-5.7.1-properly-clean-up-old-requests-in-subagents.patch @@ -0,0 +1,58 @@ +commit 13952f6bee9f408867ab6d2fdfdde4f284074957 +Author: Jan Safranek +Date: Wed Oct 26 14:05:16 2011 +0200 + + CHANGES: snmplib: from Siddhesh Poyarekar: properly clean up old requests in a subagent when we reconnect to master. + + An snmp subagent linked against net-snmp-libs may crash if it handles a + response which has magic referring to an older disconnected main session. This + may happen when the subagent + attempts to clean up old requests on reconnection of the disconnected master + session. + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +@@ -484,6 +484,26 @@ handle_agentx_packet(int operation, nets + return 1; + } + ++static int ++_invalid_op_and_magic(int op, ns_subagent_magic *smagic) ++{ ++ int invalid = 0; ++ ++ if (smagic && (snmp_sess_pointer(smagic->session) == NULL || ++ op == NETSNMP_CALLBACK_OP_TIMED_OUT)) { ++ if (smagic->ovars != NULL) { ++ snmp_free_varbind(smagic->ovars); ++ } ++ free(smagic); ++ invalid = 1; ++ } ++ ++ if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || smagic == NULL) ++ invalid = 1; ++ ++ return invalid; ++} ++ + int + handle_subagent_response(int op, netsnmp_session * session, int reqid, + netsnmp_pdu *pdu, void *magic) +@@ -492,13 +512,7 @@ handle_subagent_response(int op, netsnmp + netsnmp_variable_list *u = NULL, *v = NULL; + int rc = 0; + +- if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || magic == NULL) { +- if (op == NETSNMP_CALLBACK_OP_TIMED_OUT && magic != NULL) { +- if (smagic->ovars != NULL) { +- snmp_free_varbind(smagic->ovars); +- } +- free(smagic); +- } ++ if (_invalid_op_and_magic(op, magic)) { + return 1; + } + diff --git a/net-snmp-5.7.1-recognize-ocfs2.patch b/net-snmp-5.7.1-recognize-ocfs2.patch new file mode 100644 index 0000000..78eea62 --- /dev/null +++ b/net-snmp-5.7.1-recognize-ocfs2.patch @@ -0,0 +1,32 @@ +commit debac498fe8410110107a2fe64f8afb748edaa07 +Author: Jan Safranek +Date: Mon Feb 6 16:48:09 2012 +0100 + + CHANGES: added OCFS2 (Oracle Cluster FS) to hrStorageTable and hrFSTable + +Index: net-snmp-5.7.1/agent/mibgroup/hardware/fsys/fsys_mntent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/hardware/fsys/fsys_mntent.c ++++ net-snmp-5.7.1/agent/mibgroup/hardware/fsys/fsys_mntent.c +@@ -136,6 +136,7 @@ _fsys_type( char *typename ) + !strcmp(typename, MNTTYPE_XFS) || + !strcmp(typename, MNTTYPE_JFS) || + !strcmp(typename, MNTTYPE_REISERFS) || ++ !strcmp(typename, MNTTYPE_OCFS2) || + !strcmp(typename, MNTTYPE_LOFS)) + return NETSNMP_FS_TYPE_OTHER; + +Index: net-snmp-5.7.1/agent/mibgroup/hardware/fsys/mnttypes.h +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/hardware/fsys/mnttypes.h ++++ net-snmp-5.7.1/agent/mibgroup/hardware/fsys/mnttypes.h +@@ -133,6 +133,9 @@ + #ifndef MNTTYPE_MVFS + #define MNTTYPE_MVFS "mvfs" + #endif ++#ifndef MNTTYPE_OCFS2 ++#define MNTTYPE_OCFS2 "ocfs2" ++#endif + + /* + * File systems to skip diff --git a/net-snmp-5.7.1-reduce-code-duplication-in-agentx.patch b/net-snmp-5.7.1-reduce-code-duplication-in-agentx.patch new file mode 100644 index 0000000..d51456f --- /dev/null +++ b/net-snmp-5.7.1-reduce-code-duplication-in-agentx.patch @@ -0,0 +1,55 @@ +commit 7bead9ca917c67566d5ed98ab507bbc02816217d +Author: Bart Van Assche +Date: Wed Nov 30 14:08:08 2011 +0100 + + AgentX subagent: Reduce code duplication + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +@@ -792,6 +792,7 @@ subagent_open_master_session(void) + { + netsnmp_transport *t; + netsnmp_session sess; ++ const char *agentx_socket; + + DEBUGMSGTL(("agentx/subagent", "opening session...\n")); + +@@ -809,9 +810,9 @@ subagent_open_master_session(void) + sess.callback = handle_agentx_packet; + sess.authenticator = NULL; + +- t = netsnmp_transport_open_client( +- "agentx", netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, +- NETSNMP_DS_AGENT_X_SOCKET)); ++ agentx_socket = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, ++ NETSNMP_DS_AGENT_X_SOCKET); ++ t = netsnmp_transport_open_client("agentx", agentx_socket); + if (t == NULL) { + /* + * Diagnose snmp_open errors with the input +@@ -820,12 +821,9 @@ subagent_open_master_session(void) + if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_NO_CONNECTION_WARNINGS)) { + char buf[1024]; +- const char *socket = +- netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, +- NETSNMP_DS_AGENT_X_SOCKET); + snprintf(buf, sizeof(buf), "Warning: " + "Failed to connect to the agentx master agent (%s)", +- socket ? socket : "[NIL]"); ++ agentx_socket ? agentx_socket : "[NIL]"); + if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) { + netsnmp_sess_log_error(LOG_WARNING, buf, &sess); +@@ -846,8 +844,7 @@ subagent_open_master_session(void) + char buf[1024]; + snprintf(buf, sizeof(buf), "Error: " + "Failed to create the agentx master agent session (%s)", +- netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, +- NETSNMP_DS_AGENT_X_SOCKET)); ++ agentx_socket); + snmp_sess_perror(buf, &sess); + } + netsnmp_transport_free(t); diff --git a/net-snmp-5.7.1-report-problems-with-setundo-processing.patch b/net-snmp-5.7.1-report-problems-with-setundo-processing.patch new file mode 100644 index 0000000..f6fdcfb --- /dev/null +++ b/net-snmp-5.7.1-report-problems-with-setundo-processing.patch @@ -0,0 +1,19 @@ +commit 0815a7536c76f7e4842638683f674894a1a8ce14 +Author: Dave Shield +Date: Thu Dec 29 14:42:54 2011 +0000 + + Report problems with SetUndo processing + Missed when applying patch #3445440 + +Index: net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +=================================================================== +--- net-snmp-5.7.1.orig/agent/mibgroup/agentx/subagent.c ++++ net-snmp-5.7.1/agent/mibgroup/agentx/subagent.c +@@ -471,6 +471,7 @@ handle_agentx_packet(int operation, nets + if (asi == NULL) { + SNMP_FREE(smagic); + snmp_log(LOG_WARNING, "restore_set_vars() failed\n"); ++ send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0); + return 1; + } + asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_UNDO; diff --git a/net-snmp.changes b/net-snmp.changes index 0353652..89b801b 100644 --- a/net-snmp.changes +++ b/net-snmp.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Thu Mar 29 22:14:55 UTC 2012 - lchiquitto@suse.com + +- fix agent crash when reloading a subagent (AgentX) during a query + (bnc#670789) + +------------------------------------------------------------------- +Thu Mar 29 22:14:04 UTC 2012 - lchiquitto@suse.com + +- add OCFS2 to the list of known file systems + ------------------------------------------------------------------- Thu Mar 22 11:04:08 UTC 2012 - lchiquitto@suse.com diff --git a/net-snmp.spec b/net-snmp.spec index 25b4dc3..815a4a4 100644 --- a/net-snmp.spec +++ b/net-snmp.spec @@ -62,7 +62,6 @@ Patch5: net-snmp-5.6.1-net-snmp-config-headercheck.patch Patch6: net-snmp-5.5.0-perl-tk-warning.patch Patch7: net-snmp-5.7.0-velocity-mib.patch Patch8: net-snmp-5.7.0-recognize-reiserfs.patch -Patch9: net-snmp-5.7.1-agentx-crash.patch Patch10: net-snmp-5.7.1-snmplib-zero-timeout.patch Patch11: net-snmp-5.7.1-old-api-double-free.patch Patch12: net-snmp-5.7.1-use-pclose-to-close-pipes.patch @@ -70,6 +69,13 @@ Patch13: net-snmp-5.7.1-fix-handling-of-large-filesystems.patch Patch14: net-snmp-5.7.1-snmplib-default-retries.patch Patch15: net-snmp-5.7.1-fsys-memory-leak.patch Patch16: net-snmp-5.7.1-adjust-copyright-in-agent-txt-file.patch +Patch17: net-snmp-5.7.1-recognize-ocfs2.patch +Patch18: net-snmp-5.7.1-properly-clean-up-old-requests-in-subagents.patch +Patch19: net-snmp-5.7.1-reduce-code-duplication-in-agentx.patch +Patch20: net-snmp-5.7.1-log-agentx-disconnections.patch +Patch21: net-snmp-5.7.1-more-robust-handling-of-agentx-errors.patch +Patch22: net-snmp-5.7.1-report-problems-with-setundo-processing.patch +Patch23: net-snmp-5.7.1-fix-snmpd-crashing-when-an-agentx-disconnects.patch # Summary: SNMP Daemon License: BSD-3-Clause ; MIT @@ -217,7 +223,6 @@ Authors: %patch6 -p1 %patch7 -p1 %patch8 -p1 -%patch9 -p1 %patch10 -p1 %patch11 -p1 %patch12 -p1 @@ -225,6 +230,13 @@ Authors: %patch14 -p1 %patch15 -p1 %patch16 -p1 +%patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 +%patch22 -p1 +%patch23 -p1 %build MIBS="misc/ipfwacc ucd-snmp/diskio etherlike-mib rmon-mib velocity smux \