Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 20db51d70e6b59a061db97ce9b89c771 > files > 39

net-snmp-5.3.2.2-14.el5.src.rpm

--- net-snmp-5.3.1/include/net-snmp/library/container.h.orig	2005-12-04 19:43:04.000000000 +0100
+++ net-snmp-5.3.1/include/net-snmp/library/container.h	2007-05-04 10:01:38.000000000 +0200
@@ -330,6 +330,11 @@
     int CONTAINER_INSERT(netsnmp_container *x, const void *k);
 
     /*
+     * check if k is in any container and insert it into all if not
+     */
+    int CONTAINER_TRY_INSERT(netsnmp_container *x, const void *k);
+    
+    /*
      * remove k from all containers
      */
     int CONTAINER_REMOVE(netsnmp_container *x, const void *k);
@@ -370,8 +370,33 @@
             }
         }
         return rc;
-    }
+    }    
+    
     
+    NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
+    int CONTAINER_TRY_INSERT(netsnmp_container *x, const void *k)
+    {
+        const void *res = NULL;
+
+        netsnmp_container *start;
+        /** start at first container */
+        while(x->prev)
+            x = x->prev;
+
+       start = x;
+
+       for(; x; x = x->next) {
+            if ((NULL != x->insert_filter) &&
+               (x->insert_filter(x,k) == 1))
+                continue;
+            res = x->find(x,k);
+	    if (res) {
+               return -1;
+            }
+        }
+        return CONTAINER_INSERT(start, k);
+    }
+
     /*------------------------------------------------------------------
      * These functions should EXACTLY match the function version in
      * container.c. If you change one, change them both.
--- net-snmp-5.3.1/snmplib/container.c.orig	2006-04-21 02:24:47.000000000 +0200
+++ net-snmp-5.3.1/snmplib/container.c	2007-05-04 10:34:23.000000000 +0200
@@ -286,6 +286,29 @@
     return rc;
 }
 
+int CONTAINER_TRY_INSERT(netsnmp_container *x, const void *k)
+{
+    const void *res = NULL;
+
+    netsnmp_container *start;
+    /** start at first container */
+    while(x->prev)
+        x = x->prev;
+
+    start = x;
+
+    for(; x; x = x->next) {
+        if ((NULL != x->insert_filter) &&
+            (x->insert_filter(x,k) == 1))
+            continue;
+        res = x->find(x,k);
+        if (res) {
+            return -1;
+        }
+    }
+    return CONTAINER_INSERT(start, k);
+}
+
 /*------------------------------------------------------------------
  * These functions should EXACTLY match the inline version in
  * container.h. If you change one, change them both.
--- net-snmp-5.4/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c.orig	2006-09-15 02:48:40.000000000 +0200
+++ net-snmp-5.4/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c	2007-05-04 12:03:44.000000000 +0200
@@ -324,7 +324,17 @@
         /*
          * add entry to container
          */
-        CONTAINER_INSERT(container, entry);
+        rc = CONTAINER_TRY_INSERT(container, entry);
+        if (rc < 0) {
+            static int logged = 0;
+            if (!logged) {
+                snmp_log(LOG_NOTICE, "Duplicate IPv6 address detected, some interfaces may not be visible in IP-MIB\n");
+                logged = 1;
+            }
+            netsnmp_access_ipaddress_entry_free(entry);
+            rc = 0;
+        }
+                                    
     }
 
     fclose(in);
--- net-snmp-5.3.2.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c.orig	2008-07-10 13:56:42.000000000 +0200
+++ net-snmp-5.3.2.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c	2008-07-10 14:02:16.000000000 +0200
@@ -272,11 +272,15 @@ _netsnmp_ioctl_ipaddress_container_load_
         /*
          * add entry to container
          */
-        if (CONTAINER_INSERT(container, entry) < 0)
-        {
-            DEBUGMSGTL(("access:ipaddress:container","error with ipaddress_entry: insert into container failed.\n"));
+        rc = CONTAINER_TRY_INSERT(container, entry);
+        if (rc < 0) {
+            static int logged = 0;
+            if (!logged) {
+                snmp_log(LOG_NOTICE, "Duplicate IP address detected, some interfaces may not be visible in IP-MIB\n");
+                logged = 1;
+            }
             netsnmp_access_ipaddress_entry_free(entry);
-            continue;
+            rc = 0;
         }
     }