The following bug report documents a case where AgentX sub-agents
sending a trap that hit a inform receiver that is down crash the main
net-snmp agent:

  
http://sourceforge.net/tracker/index.php?func=detail&aid=1313667&group_id=12694&atid=112694

The following patch fixes this but certainly is not a change that
should be made lightly.  I'm very interested in other opinions about
it, especially in light of the fact it should go into 5.2.2:

Thoughts?

Index: agent_trap.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/agent_trap.c,v
retrieving revision 5.24
diff -u -p -r5.24 agent_trap.c
--- agent_trap.c        30 Aug 2005 00:08:44 -0000      5.24
+++ agent_trap.c        18 Oct 2005 04:31:32 -0000
@@ -800,6 +800,33 @@ send_enterprise_trap_vars(int trap,
     return;
 }
 
+/**
+ * Captures responses or the lack there of from INFORMs that were sent
+ * 1) a response is received from an INFORM
+ * 2) one isn't received and the retries/timeouts have failed
+*/
+int
+handle_inform_response(int op, netsnmp_session * session,
+                       int reqid, netsnmp_pdu *pdu,
+                       void *magic)
+{
+    /* XXX: much more checking of results needed and possibly stats update */
+    switch (op) {
+
+    case NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE:
+        DEBUGMSGTL(("trap", "received the inform response for reqid=%d\n",
+                    reqid));
+        /* snmp_free_pdu(pdu); */
+        break;
+
+    default:
+        DEBUGMSGTL(("trap", "received op=%d for reqid=%d when trying to send 
an inform\n", op, reqid));
+    }
+
+    return 1;
+}
+
+
 /*
  * send_trap_to_sess: sends a trap to a session but assumes that the
  * pdu is constructed correctly for the session type. 
@@ -808,7 +835,6 @@ void
 send_trap_to_sess(netsnmp_session * sess, netsnmp_pdu *template_pdu)
 {
     netsnmp_pdu    *pdu;
-    netsnmp_pdu    *response;
     int            result;
 
     if (!sess || !template_pdu)
@@ -831,10 +857,13 @@ send_trap_to_sess(netsnmp_session * sess
          || template_pdu->command == AGENTX_MSG_NOTIFY
 #endif
        ) {
-        result = snmp_synch_response(sess, pdu, &response);
-        result = !result;      /* XXX - different return code :-( */
-    } else
+        result =
+            snmp_async_send(sess, pdu, &handle_inform_response, NULL);
+        
+    } else {
         result = snmp_send(sess, pdu);
+    }
+
     if (result == 0) {
         snmp_sess_perror("snmpd: send_trap", sess);
         /* snmp_free_pdu(pdu); */


-- 
Wes Hardaker
Sparta, Inc.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to