Blob Blame History Raw
--- 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
@@ -370,8 +370,32 @@
             }
         }
         return rc;
-    }
+    }    
+
-    
+     NETSNMP_STATIC_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.1/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c.orig	2007-05-17 23:53:28.000000000 +0200
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c	2007-08-07 13:49:49.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;
+            }
+            rc = 0;
             netsnmp_access_ipaddress_entry_free(entry);
-            continue;
         }
     }
 
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c.orig	2006-09-15 02:48:50.000000000 +0200
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c	2007-08-07 13:47:55.000000000 +0200
@@ -324,7 +324,16 @@ _load_v6(netsnmp_container *container, i
         /*
          * 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 IP address detected, some interfaces may not be visible in IP-MIB\n");
+                logged = 1;
+            }
+            netsnmp_access_ipaddress_entry_free(entry);
+        }
+                                    
     }
 
     fclose(in);