net-snmp/net-snmp-5.4.1-shared-ip.patch

117 lines
4.3 KiB
Diff

TODO: remove with 5.4.3 - another approach is implemented upstream
diff -up net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c.shared-ip net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c
--- net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c.shared-ip 2008-01-17 01:09:33.000000000 +0100
+++ net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c 2008-09-17 16:43:18.000000000 +0200
@@ -279,11 +279,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;
}
}
diff -up net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c.shared-ip net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
--- net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c.shared-ip 2008-08-13 15:02:12.000000000 +0200
+++ net-snmp-5.4.2/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c 2008-09-17 16:43:18.000000000 +0200
@@ -325,7 +325,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);
diff -up net-snmp-5.4.2/include/net-snmp/library/container.h.shared-ip net-snmp-5.4.2/include/net-snmp/library/container.h
--- net-snmp-5.4.2/include/net-snmp/library/container.h.shared-ip 2008-02-14 00:37:48.000000000 +0100
+++ net-snmp-5.4.2/include/net-snmp/library/container.h 2008-09-17 16:43:18.000000000 +0200
@@ -406,8 +406,32 @@ extern "C" {
}
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.
diff -up net-snmp-5.4.2/snmplib/container.c.shared-ip net-snmp-5.4.2/snmplib/container.c
--- net-snmp-5.4.2/snmplib/container.c.shared-ip 2008-02-14 00:37:48.000000000 +0100
+++ net-snmp-5.4.2/snmplib/container.c 2008-09-17 16:43:18.000000000 +0200
@@ -323,6 +323,29 @@ int CONTAINER_REMOVE(netsnmp_container *
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.