1 Index: snmplib/container_binary_array.c
2 ===================================================================
3 --- snmplib/container_binary_array.c (revision 16471)
4 +++ snmplib/container_binary_array.c (working copy)
9 +static int _ba_options(netsnmp_container *c, int set, u_int flags)
11 + return netsnmp_binary_array_options_set(c, set, flags);
15 netsnmp_container_get_binary_array(void)
18 c->get_iterator = _ba_iterator_get;
19 c->for_each = _ba_for_each;
21 + c->options = _ba_options;
25 Index: snmplib/container.c
26 ===================================================================
27 --- snmplib/container.c (revision 16471)
28 +++ snmplib/container.c (working copy)
30 int CONTAINER_INSERT(netsnmp_container *x, const void *k)
33 + netsnmp_container *start;
36 /** start at first container */
41 + if (start->next != NULL) {
42 + /* Check if the key would create duplicity in any index.
43 + * This is not needed if there is only one index - x->insert
44 + * will check it instead. */
45 + for(; x; x = x->next) {
46 + int key_allow_duplicates = 0;
47 + CONTAINER_CHECK_OPTION(x, CONTAINER_KEY_ALLOW_DUPLICATES, key_allow_duplicates);
48 + if (key_allow_duplicates < 0)
49 + key_allow_duplicates = 0; /* cannot read the flag -> use default value */
51 + if (key_allow_duplicates)
52 + continue; /* no need to check this index - duplicates are allowed */
54 + if ((NULL != x->insert_filter) &&
55 + (x->insert_filter(x,k) == 1))
56 + continue; /* no need to check this index - index is filtered out */
60 + /* key is already in the index -> forbid the insert */
61 + CONTAINER_CHECK_OPTION(start, CONTAINER_SILENT, silent);
63 + silent = 0; /* cannot read the flag -> use default value */
66 + snmp_log(LOG_ERR,"error on subcontainer '%s' insert would create duplicity (%d)\n",
67 + x->container_name ? x->container_name : "", rc2);
75 for(; x; x = x->next) {
76 if ((NULL != x->insert_filter) &&
77 (x->insert_filter(x,k) == 1))
81 - snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
82 - x->container_name ? x->container_name : "", rc2);
84 + CONTAINER_CHECK_OPTION(start, CONTAINER_SILENT, silent);
86 + silent = 0; /* cannot read the flag -> use default value */
89 + snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
90 + x->container_name ? x->container_name : "", rc2);
96 Index: include/net-snmp/library/container.h
97 ===================================================================
98 --- include/net-snmp/library/container.h (revision 16471)
99 +++ include/net-snmp/library/container.h (working copy)
102 #define CONTAINER_KEY_ALLOW_DUPLICATES 0x00000001
103 #define CONTAINER_KEY_UNSORTED 0x00000002
104 +/* do not print anything to log on CONTAINER_INSERT error */
105 +#define CONTAINER_SILENT 0x00000004
107 #define CONTAINER_SET_OPTIONS(x,o,rc) do { \
108 if (NULL==(x)->options) \
109 @@ -354,23 +356,68 @@
110 int CONTAINER_INSERT(netsnmp_container *x, const void *k)
113 + netsnmp_container *start;
116 /** start at first container */
121 + if (start->next != NULL) {
122 + /* Check if the key would create duplicity in any index.
123 + * This is not needed if there is only one index - x->insert
124 + * will check it instead. */
125 + for(; x; x = x->next) {
126 + int key_allow_duplicates = 0;
127 + CONTAINER_CHECK_OPTION(x, CONTAINER_KEY_ALLOW_DUPLICATES, key_allow_duplicates);
128 + if (key_allow_duplicates < 0)
129 + key_allow_duplicates = 0; /* cannot read the flag -> use default value */
131 + if (key_allow_duplicates)
132 + continue; /* no need to check this index - duplicates are allowed */
134 + if ((NULL != x->insert_filter) &&
135 + (x->insert_filter(x,k) == 1))
136 + continue; /* no need to check this index - index is filtered out */
138 + rc2 = x->find(x,k);
140 + /* key is already in the index -> forbid the insert */
141 + CONTAINER_CHECK_OPTION(start, CONTAINER_SILENT, silent);
143 + silent = 0; /* cannot read the flag -> use default value */
146 + snmp_log(LOG_ERR,"error on subcontainer '%s' insert would create duplicity (%d)\n",
147 + x->container_name ? x->container_name : "", rc2);
155 for(; x; x = x->next) {
156 if ((NULL != x->insert_filter) &&
157 (x->insert_filter(x,k) == 1))
159 rc2 = x->insert(x,k);
161 - snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
162 - x->container_name ? x->container_name : "", rc2);
163 + /* insert failed */
164 + CONTAINER_CHECK_OPTION(start, CONTAINER_SILENT, silent);
166 + silent = 0; /* cannot read the flag -> use default value */
169 + snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
170 + x->container_name ? x->container_name : "", rc2);
179 /*------------------------------------------------------------------
180 * These functions should EXACTLY match the function version in
181 Index: agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c
182 ===================================================================
183 --- agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c 2008-04-23 11:27:45.000000000 +0300
184 +++ agent/mibgroup/ip-mib/data_access/ipaddress_ioctl.c 2008-04-23 11:37:29.000000000 +0300
185 @@ -272,11 +272,14 @@
187 * add entry to container
189 - if (CONTAINER_INSERT(container, entry) < 0)
191 - DEBUGMSGTL(("access:ipaddress:container","error with ipaddress_entry: insert into container failed.\n"));
192 - netsnmp_access_ipaddress_entry_free(entry);
195 + rc = CONTAINER_INSERT(container, entry);
197 + static int logged = 0;
199 + snmp_log(LOG_NOTICE, "Duplicate IPv4 address detected, some interfaces may not be visible in IP-MIB\n");
205 Index: agent/mibgroup/ip-mib/data_access/ipaddress_common.c
206 ===================================================================
207 --- agent/mibgroup/ip-mib/data_access/ipaddress_common.c (revision 16471)
208 +++ agent/mibgroup/ip-mib/data_access/ipaddress_common.c (working copy)
210 netsnmp_access_ipaddress_container_init(u_int flags)
212 netsnmp_container *container1;
215 DEBUGMSGTL(("access:ipaddress:container", "init\n"));
220 container1->container_name = strdup("ia_index");
221 + CONTAINER_SET_OPTIONS(container1, CONTAINER_SILENT, rc);
223 + snmp_log(LOG_ERR, "ipaddress container: cannot set CONTAINER_SILENT flag\n");
224 + CONTAINER_FREE(container1);
228 if (flags & NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR) {
229 netsnmp_container *container2 =
232 container2->compare = _access_ipaddress_entry_compare_addr;
233 container2->container_name = strdup("ia_addr");
235 + CONTAINER_SET_OPTIONS(container2, CONTAINER_SILENT, rc);
237 + snmp_log(LOG_ERR, "ipaddress secondary container: cannot set CONTAINER_SILENT flag\n");
238 + CONTAINER_FREE(container1);
239 + CONTAINER_FREE(container2);
243 netsnmp_container_add_index(container1, container2);
245 Index: agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
246 ===================================================================
247 --- agent/mibgroup/ip-mib/data_access/ipaddress_linux.c (revision 16471)
248 +++ agent/mibgroup/ip-mib/data_access/ipaddress_linux.c (working copy)
251 * add entry to container
253 - CONTAINER_INSERT(container, entry);
254 + rc = CONTAINER_INSERT(container, entry);
256 + static int logged = 0;
258 + snmp_log(LOG_NOTICE, "Duplicate IPv6 address detected, some interfaces may not be visible in IP-MIB\n");
261 + netsnmp_access_ipaddress_entry_free(entry);