# HG changeset patch # User Lijo George - Oracle Corporation - Bangalore India # Date 1362853071 28800 # Node ID 2021fa9cf02060e07fa8382797a1e78e1b70d037 # Parent 6f6004780f3652e3da3b80d273d2f430dbed1831 15745743 SUNBT7097655 snmpd core files are seen in s11b174 with T4-1B diff -r 6f6004780f36 -r 2021fa9cf020 components/net-snmp/patches/029.7097655.ipAddressTable_container.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/net-snmp/patches/029.7097655.ipAddressTable_container.patch Sat Mar 09 10:17:51 2013 -0800 @@ -0,0 +1,457 @@ +diff -ur net-snmp-5.4.1.org/agent/helpers/table_tdata.c net-snmp-5.4.1.container/agent/helpers/table_tdata.c +--- net-snmp-5.4.1.org/agent/helpers/table_tdata.c 2012-04-02 01:31:08.387259100 -0700 ++++ net-snmp-5.4.1.container/agent/helpers/table_tdata.c 2012-04-02 01:58:23.019636200 -0700 +@@ -57,9 +57,18 @@ + if ( !table ) + return NULL; + ++ table->flags = flags; + if (name) + table->name = strdup(name); +- table->container = netsnmp_container_find( "table_container" ); ++ ++ if (!(table->flags & TDATA_FLAG_NO_CONTAINER)) { ++ table->container = netsnmp_container_find( name ); ++ if (!table->container) ++ table->container = netsnmp_container_find( "table_container" ); ++ if (table->container) ++ table->container->container_name = strdup(name); ++ } ++ + return table; + } + +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/data_access/route_common.c net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/data_access/route_common.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/data_access/route_common.c 2012-04-02 01:31:08.334343300 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/data_access/route_common.c 2012-04-02 02:00:46.671129800 -0700 +@@ -47,8 +47,11 @@ + + DEBUGMSGTL(("access:route:container", "load\n")); + +- if (NULL == container) ++ if (NULL == container) { + container = netsnmp_container_find("access:_route:table_container"); ++ if (container) ++ container->container_name = strdup("_route"); ++ } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_route\n"); + return NULL; +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c 2012-04-02 01:31:08.341048100 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_interface.c 2012-04-02 02:05:22.940847300 -0700 +@@ -2307,9 +2307,12 @@ + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + inetCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("inetCidrRouteTable:table_container"); ++ if (NULL != if_ctx->container) ++ if_ctx->container->container_name = strdup("inetCidrRouteTable"); ++ } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "inetCidrRouteTable_container_init\n"); +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c 2012-04-02 01:31:08.337647600 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_interface.c 2012-04-02 02:08:16.825508200 -0700 +@@ -2259,9 +2259,12 @@ + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + ipCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("ipCidrRouteTable:table_container"); ++ if (NULL != if_ctx->container) ++ if_ctx->container->container_name = strdup("ipCidrRouteTable"); ++ } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipCidrRouteTable_container_init\n"); +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/data_access/arp_common.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/data_access/arp_common.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-mib/data_access/arp_common.c 2012-04-02 01:31:08.353034100 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/data_access/arp_common.c 2012-04-02 02:10:39.120984300 -0700 +@@ -62,8 +62,11 @@ + + DEBUGMSGTL(("access:arp:container", "load\n")); + +- if (NULL == container) ++ if (NULL == container) { + container = netsnmp_container_find("access:arp:table_container"); ++ if (container) ++ container->container_name = strdup("arp"); ++ } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_arp\n"); + return NULL; +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/data_access/systemstats_common.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/data_access/systemstats_common.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-mib/data_access/systemstats_common.c 2012-04-02 01:31:08.353793700 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/data_access/systemstats_common.c 2012-04-02 02:12:30.680237000 -0700 +@@ -96,8 +96,11 @@ + + DEBUGMSGTL(("access:systemstats:container", "load\n")); + +- if (NULL == container) ++ if (NULL == container) { + container = netsnmp_access_systemstats_container_init(load_flags); ++ if (NULL != container) ++ container->container_name = strdup("systemstats_autocreate"); ++ } + if (NULL == container) { + snmp_log(LOG_ERR, "no container specified/found for access_systemstats\n"); + return NULL; +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c 2012-04-02 01:31:08.349583400 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/inetNetToMediaTable/inetNetToMediaTable_interface.c 2012-04-02 02:13:41.237688000 -0700 +@@ -1935,9 +1935,12 @@ + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + inetNetToMediaTable_container_init(&if_ctx->container, if_ctx->cache); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("inetNetToMediaTable:table_container"); ++ if (if_ctx->container) ++ if_ctx->container->container_name = strdup("inetNetToMediaTable"); ++ } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "inetNetToMediaTable_container_init\n"); +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c 2012-04-02 01:31:08.365565600 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipv4InterfaceTable/ipv4InterfaceTable_interface.c 2012-04-02 03:44:15.669526200 -0700 +@@ -1251,15 +1251,18 @@ + * container init + */ + ipv4InterfaceTable_container_init(&if_ctx->container); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) + if_ctx->container = + netsnmp_container_find("ipv4InterfaceTable:table_container"); ++ + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "ipv4InterfaceTable_container_init\n"); + return; + } + ++ if_ctx->container->container_name = strdup("ipv4InterfaceTable"); ++ + } /* _ipv4InterfaceTable_container_init */ + + /** +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c 2012-04-02 01:31:08.363180800 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipv6InterfaceTable/ipv6InterfaceTable_interface.c 2012-04-02 03:45:04.295800900 -0700 +@@ -1341,6 +1341,7 @@ + "ipv6InterfaceTable_container_init\n"); + return; + } ++ if_ctx->container->container_name = strdup("ipv6InterfaceTable"); + + } /* _ipv6InterfaceTable_container_init */ + +diff -ur net-snmp-5.4.1.org/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c 2012-04-02 01:31:08.199286300 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/tcp-mib/tcpConnectionTable/tcpConnectionTable_interface.c 2012-04-02 03:47:50.113861500 -0700 +@@ -1731,9 +1731,12 @@ + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + tcpConnectionTable_container_init(&if_ctx->container, if_ctx->cache); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("tcpConnectionTable:table_container"); ++ if (if_ctx->container) ++ if_ctx->container->container_name = strdup("tcpConnectionTable"); ++ } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "tcpConnectionTable_container_init\n"); +diff -ur net-snmp-5.4.1.org/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c net-snmp-5.4.1.container/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c +--- net-snmp-5.4.1.org/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c 2012-04-02 01:31:08.201001900 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_interface.c 2012-04-02 03:48:52.542497400 -0700 +@@ -922,9 +922,12 @@ + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + tcpListenerTable_container_init(&if_ctx->container, if_ctx->cache); +- if (NULL == if_ctx->container) ++ if (NULL == if_ctx->container) { + if_ctx->container = + netsnmp_container_find("tcpListenerTable:table_container"); ++ if (if_ctx->container) ++ if_ctx->container->container_name = strdup("tcpListenerTable"); ++ } + if (NULL == if_ctx->container) { + snmp_log(LOG_ERR, "error creating container in " + "tcpListenerTable_container_init\n"); +diff -ur net-snmp-5.4.1.org/include/net-snmp/agent/table_tdata.h net-snmp-5.4.1.container/include/net-snmp/agent/table_tdata.h +--- net-snmp-5.4.1.org/include/net-snmp/agent/table_tdata.h 2012-04-02 01:31:08.444022500 -0700 ++++ net-snmp-5.4.1.container/include/net-snmp/agent/table_tdata.h 2012-04-02 23:50:13.830827600 -0700 +@@ -21,6 +21,7 @@ + #define TABLE_TDATA_TABLE "table_tdata_table" + + #define TDATA_FLAG_NO_STORE_INDEXES 0x01 ++#define TDATA_FLAG_NO_CONTAINER 0x02 /* user will provide container */ + + /* + * The (table-independent) per-row data structure +diff -ur net-snmp-5.4.1.org/include/net-snmp/library/container.h net-snmp-5.4.1.container/include/net-snmp/library/container.h +--- net-snmp-5.4.1.orig/include/net-snmp/library/container.h 2012-09-13 03:44:03.378177029 -0700 ++++ net-snmp-5.4.1.container/include/net-snmp/library/container.h 2012-09-05 12:05:44.822831595 -0700 +@@ -373,31 +373,42 @@ + */ + int CONTAINER_FREE(netsnmp_container *x); + #else +- /*------------------------------------------------------------------ +- * These functions should EXACTLY match the function version in +- * container.c. If you change one, change them both. +- */ +- NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */ +- int CONTAINER_INSERT(netsnmp_container *x, const void *k) +- { +- int rc2, rc = 0; +- +- /** start at first container */ +- while(x->prev) +- x = x->prev; +- for(; x; x = x->next) { +- if ((NULL != x->insert_filter) && +- (x->insert_filter(x,k) == 1)) +- continue; +- rc2 = x->insert(x,k); +- if (rc2) { +- snmp_log(LOG_DEBUG,"error on subcontainer '%s' insert (%d)\n", +- x->container_name ? x->container_name : "", rc2); +- rc = rc2; +- } +- } +- return rc; +- } ++ /*------------------------------------------------------------------ ++ * These functions should EXACTLY match the function version in ++ * container.c. If you change one, change them both. ++ */ ++ NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */ ++ int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k) ++ { ++ while(x && x->insert_filter && x->insert_filter(x,k) == 1) ++ x = x->next; ++ if(x) { ++ int rc = x->insert(x,k); ++ if(rc) ++ snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n", ++ x->container_name ? x->container_name : "", rc); ++ else { ++ rc = CONTAINER_INSERT_HELPER(x->next, k); ++ if(rc) ++ x->remove(x,k); ++ } ++ return rc; ++ } ++ return 0; ++ } ++ ++ /*------------------------------------------------------------------ ++ * These functions should EXACTLY match the function version in ++ * container.c. If you change one, change them both. ++ */ ++ NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */ ++ int CONTAINER_INSERT(netsnmp_container* x, const void* k) ++ { ++ /** start at first container */ ++ while(x->prev) ++ x = x->prev; ++ return CONTAINER_INSERT_HELPER(x, k); ++ } + + /*------------------------------------------------------------------ + * These functions should EXACTLY match the function version in +diff -ur net-snmp-5.4.1.org/snmplib/container.c net-snmp-5.4.1.container/snmplib/container.c +--- net-snmp-5.4.1/snmplib/container.c 2012-09-13 03:44:03.380247622 -0700 ++++ net-snmp-5.4.1.container/snmplib/container.c 2012-09-13 03:33:19.759881202 -0700 +@@ -49,7 +49,8 @@ + */ + containers = netsnmp_container_get_binary_array(); + containers->compare = netsnmp_compare_cstring; +- ++ containers->container_name = strdup("container list"); ++ + /* + * register containers + */ +@@ -265,25 +266,34 @@ + * These functions should EXACTLY match the inline version in + * container.h. If you change one, change them both. + */ +-int CONTAINER_INSERT(netsnmp_container *x, const void *k) +-{ +- int rc2, rc = 0; +- +- /** start at first container */ ++int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k) ++{ ++ while(x && x->insert_filter && x->insert_filter(x,k) == 1) ++ x = x->next; ++ if(x) { ++ int rc = x->insert(x,k); ++ if(rc) ++ snmp_log(LOG_DEBUG,"error on subcontainer '%s' insert (%d)\n", ++ x->container_name ? x->container_name : "", rc); ++ else { ++ rc = CONTAINER_INSERT_HELPER(x->next, k); ++ if(rc) ++ x->remove(x,k); ++ } ++ return rc; ++ } ++ return 0; ++ } ++ ++/*------------------------------------------------------------------ ++ * These functions should EXACTLY match the inline version in ++ * container.h. If you change one, change them both. ++ */ ++int CONTAINER_INSERT(netsnmp_container* x, const void* k) ++{ + while(x->prev) +- x = x->prev; +- for(; x; x = x->next) { +- if ((NULL != x->insert_filter) && +- (x->insert_filter(x,k) == 1)) +- continue; +- rc2 = x->insert(x,k); +- if (rc2) { +- snmp_log(LOG_DEBUG,"error on subcontainer '%s' insert (%d)\n", +- x->container_name ? x->container_name : "", rc2); +- rc = rc2; +- } +- } +- return rc; ++ x = x->prev; ++ return CONTAINER_INSERT_HELPER(x, k); + } + + /*------------------------------------------------------------------ +diff -ur net-snmp-5.4.1.org/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c +--- net-snmp-5.4.1.orig/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2007-05-17 14:53:28.000000000 -0700 ++++ net-snmp-5.4.1.container/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2012-09-13 03:45:25.253102053 -0700 +@@ -134,6 +134,7 @@ + *container_ptr_ptr = + netsnmp_container_find("ipAddressTable:table_container"); + if (NULL != *container_ptr_ptr) { ++ (*container_ptr_ptr)->container_name = strdup("ipAddressTable"); + ipAddressTable_container_load(*container_ptr_ptr); + CONTAINER_FOR_EACH(*container_ptr_ptr, + (netsnmp_container_obj_func *) _clear_times, +@@ -344,56 +345,58 @@ + * what we've already got, and make any adjustments, saving + * missing addresses to be deleted. + */ +- tmp_ptr[0] = ipaddress_container->next; +- tmp_ptr[1] = NULL; +- CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *) +- _check_entry_for_updates, tmp_ptr); +- +- /* +- * now add any new interfaces +- */ +- CONTAINER_FOR_EACH(ipaddress_container, +- (netsnmp_container_obj_func *) _add_new_entry, +- container); +- +- /* +- * free the container. we've either claimed each entry, or released it, +- * so the access function doesn't need to clear the container. +- */ +- netsnmp_access_ipaddress_container_free(ipaddress_container, +- NETSNMP_ACCESS_IPADDRESS_FREE_DONT_CLEAR); +- +- /* +- * remove deleted addresses from table container +- */ +- if (NULL != tmp_ptr[1]) { +- netsnmp_container *tmp_container = +- (netsnmp_container *) tmp_ptr[1]; +- ipAddressTable_rowreq_ctx *tmp_ctx; +- +- /* +- * this works because the tmp_container is a linked list, +- * which can be used like a stack... +- */ +- while (CONTAINER_SIZE(tmp_container)) { +- /* +- * get from delete list +- */ +- tmp_ctx = CONTAINER_FIRST(tmp_container); +- +- /* +- * release context, delete from table container +- */ +- CONTAINER_REMOVE(container, tmp_ctx); +- ipAddressTable_release_rowreq_ctx(tmp_ctx); +- +- /* +- * pop off delete list +- */ +- CONTAINER_REMOVE(tmp_container, NULL); +- } ++ if(ipaddress_container != NULL) ++ { ++ tmp_ptr[0] = ipaddress_container->next; ++ tmp_ptr[1] = NULL; ++ CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *) ++ _check_entry_for_updates, tmp_ptr); ++ ++ /* ++ * now add any new interfaces ++ */ ++ CONTAINER_FOR_EACH(ipaddress_container, ++ (netsnmp_container_obj_func *) _add_new_entry, ++ container); ++ ++ /* ++ * free the container. we've either claimed each entry, or released it, ++ * so the access function doesn't need to clear the container. ++ */ ++ netsnmp_access_ipaddress_container_free(ipaddress_container, ++ NETSNMP_ACCESS_IPADDRESS_FREE_DONT_CLEAR); ++ ++ /* ++ * remove deleted addresses from table container ++ */ ++ if (NULL != tmp_ptr[1]) { ++ netsnmp_container *tmp_container = ++ (netsnmp_container *) tmp_ptr[1]; ++ ipAddressTable_rowreq_ctx *tmp_ctx; ++ ++ /* ++ * this works because the tmp_container is a linked list, ++ * which can be used like a stack... ++ */ ++ while (CONTAINER_SIZE(tmp_container)) { ++ /* ++ * get from delete list ++ */ ++ tmp_ctx = CONTAINER_FIRST(tmp_container); ++ ++ /* ++ * release context, delete from table container ++ */ ++ CONTAINER_REMOVE(container, tmp_ctx); ++ ipAddressTable_release_rowreq_ctx(tmp_ctx); ++ ++ /* ++ * pop off delete list ++ */ ++ CONTAINER_REMOVE(tmp_container, NULL); ++ } ++ } + } +- + DEBUGMSGT(("verbose:ipAddressTable:ipAddressTable_cache_load", + "%d records\n", CONTAINER_SIZE(container))); +