b5ae06
Bug 1140234 - unexpected messages in log while smux processing
b5ae06
Bug 1189393 - unexpected messages in log while smux processing
b5ae06
b5ae06
Backported from:
b5ae06
b5ae06
commit 75d17a242e524e66b6c8214f68dc9920d5bd59df
b5ae06
Author: Jan Safranek <jsafranek@users.sourceforge.net>
b5ae06
Date:   Fri Jan 30 11:29:53 2015 +0100
b5ae06
b5ae06
    CHANGES: snmpd: Remove some log messages from SMUX processing.
b5ae06
    
b5ae06
    These messages are not useful to system admin and only makes system log unreadable. Let's move them to debug level.
b5ae06
b5ae06
diff -up net-snmp-5.7.2/agent/mibgroup/smux/smux.c.smux-logging net-snmp-5.7.2/agent/mibgroup/smux/smux.c
b5ae06
--- net-snmp-5.7.2/agent/mibgroup/smux/smux.c.smux-logging	2015-06-18 10:49:01.165899644 +0200
b5ae06
+++ net-snmp-5.7.2/agent/mibgroup/smux/smux.c	2015-06-18 10:50:01.650157657 +0200
b5ae06
@@ -536,8 +536,8 @@ var_smux_write(int action,
b5ae06
 
b5ae06
             if (buf[0] == SMUX_TRAP) {
b5ae06
                 DEBUGMSGTL(("smux", "[var_smux_write] Received trap\n"));
b5ae06
-                snmp_log(LOG_INFO, "Got trap from peer on fd %d\n",
b5ae06
-                         rptr->sr_fd);
b5ae06
+                DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n",
b5ae06
+                         rptr->sr_fd));
b5ae06
                 ptr = asn_parse_header(buf, &len, &type);
b5ae06
                 smux_trap_process(ptr, &len;;
b5ae06
 
b5ae06
@@ -646,9 +646,9 @@ smux_accept(int sd)
b5ae06
         snmp_log_perror("[smux_accept] accept failed");
b5ae06
         return -1;
b5ae06
     } else {
b5ae06
-        snmp_log(LOG_INFO, "[smux_accept] accepted fd %d from %s:%d\n",
b5ae06
+    	DEBUGMSGTL(("smux", "[smux_accept] accepted fd %d from %s:%d\n",
b5ae06
                  fd, inet_ntoa(in_socket.sin_addr),
b5ae06
-                 ntohs(in_socket.sin_port));
b5ae06
+                 ntohs(in_socket.sin_port)));
b5ae06
         if (npeers + 1 == SMUXMAXPEERS) {
b5ae06
             snmp_log(LOG_ERR,
b5ae06
                      "[smux_accept] denied peer on fd %d, limit %d reached",
b5ae06
@@ -747,7 +747,8 @@ smux_process(int fd)
b5ae06
 
b5ae06
     if (length <= 0)
b5ae06
     {
b5ae06
-       snmp_log_perror("[smux_process] peek failed");
b5ae06
+       if (length < 0)
b5ae06
+    	   snmp_log_perror("[smux_process] peek failed");
b5ae06
        smux_peer_cleanup(fd);
b5ae06
        return -1;
b5ae06
     }
b5ae06
@@ -837,7 +838,7 @@ smux_pdu_process(int fd, u_char * data,
b5ae06
             DEBUGMSGTL(("smux", "This shouldn't have happened!\n"));
b5ae06
             break;
b5ae06
         case SMUX_TRAP:
b5ae06
-            snmp_log(LOG_INFO, "Got trap from peer on fd %d\n", fd);
b5ae06
+        	DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n", fd));
b5ae06
             if (ptr)
b5ae06
             {
b5ae06
                DEBUGMSGTL(("smux", "[smux_pdu_process] call smux_trap_process.\n"));
b5ae06
@@ -943,9 +944,9 @@ smux_open_process(int fd, u_char * ptr,
b5ae06
         *fail = TRUE;
b5ae06
         return ptr;
b5ae06
     }
b5ae06
-    snmp_log(LOG_INFO,
b5ae06
+    DEBUGMSGTL(("smux",
b5ae06
              "accepted smux peer: oid %s, descr %s\n",
b5ae06
-             oid_print, descr);
b5ae06
+             oid_print, descr));
b5ae06
     *fail = FALSE;
b5ae06
     return ptr;
b5ae06
 }
b5ae06
@@ -1538,7 +1539,7 @@ smux_snmp_process(int exact,
b5ae06
 
b5ae06
         if (result[0] == SMUX_TRAP) {
b5ae06
             DEBUGMSGTL(("smux", "[smux_snmp_process] Received trap\n"));
b5ae06
-            snmp_log(LOG_INFO, "Got trap from peer on fd %d\n", sd);
b5ae06
+            DEBUGMSGTL(("smux", "Got trap from peer on fd %d\n", sd));
b5ae06
             ptr = asn_parse_header(result, (size_t *) &length, &type);
b5ae06
             smux_trap_process(ptr, (size_t *) &length);
b5ae06
 
b5ae06
@@ -1906,7 +1907,7 @@ smux_peer_cleanup(int sd)
b5ae06
             Auths[i]->sa_active_fd = -1;
b5ae06
             snprint_objid(oid_name, sizeof(oid_name), Auths[i]->sa_oid,
b5ae06
                           Auths[i]->sa_oid_len);
b5ae06
-            snmp_log(LOG_INFO, "peer disconnected: %s\n", oid_name);
b5ae06
+            DEBUGMSGTL(("smux", "peer disconnected: %s\n", oid_name));
b5ae06
         }
b5ae06
     }
b5ae06
 }