bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * CDDL HEADER START
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * The contents of this file are subject to the terms of the
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Common Development and Distribution License (the "License").
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * You may not use this file except in compliance with the License.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * See the License for the specific language governing permissions
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * and limitations under the License.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * When distributing Covered Code, include this CDDL HEADER in each
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If applicable, add the following below this CDDL HEADER, with the
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * fields enclosed by brackets "[]" replaced with your own identifying
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * information: Portions Copyright [yyyy] [name of copyright owner]
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * CDDL HEADER END
1eee170a5f6cf875d905524fea524c7c5c870aa0Erik Nordmark * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * Copyright (c) 2012, Joyent, Inc. All rights reserved.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Routines for handling destination cache entries.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * There is always one DCEF_DEFAULT for each ip_stack_t created at init time.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * That entry holds both the IP ident value and the dce generation number.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Any time a DCE is changed significantly (different path MTU, but NOT
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * different ULP info!), the dce_generation number is increased.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Also, when a new DCE is created, the dce_generation number in the default
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * DCE is bumped. That allows the dce_t information to be cached efficiently
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * as long as the entity caching the dce_t also caches the dce_generation,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * and compares the cached generation to detect any changes.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Furthermore, when a DCE is deleted, if there are any outstanding references
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * to the DCE it will be marked as condemned. The condemned mark is
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * a designated generation number which is never otherwise used, hence
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * the single comparison with the generation number captures that as well.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * An example of code which caches is as follows:
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * if (mystruct->my_dce_generation != mystruct->my_dce->dce_generation) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * The DCE has changed
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * mystruct->my_dce = dce_lookup_pkt(mp, ixa,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * &mystruct->my_dce_generation);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Not needed in practice, since we have the default DCE:
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * if (DCE_IS_CONDEMNED(mystruct->my_dce))
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * return failure;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Note that for IPv6 link-local addresses we record the ifindex since the
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * link-locals are not globally unique.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Hash bucket structure for DCEs
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkstatic void dce_delete_locked(dcb_t *, dce_t *);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek/* Global so it can be tuned in /etc/system. This must be a power of two. */
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek/* The time in seconds between executions of the IP DCE reclaim worker. */
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek/* The factor of the DCE threshold at which to start hard reclaims */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark/* Operates on a uint64_t */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark#define RANDOM_HASH(p) ((p) ^ ((p)>>16) ^ ((p)>>32) ^ ((p)>>48))
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Reclaim a fraction of dce's in the dcb.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * For now we have a higher probability to delete DCEs without DCE_PMTU.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdcb_reclaim(dcb_t *dcb, ip_stack_t *ipst, uint_t fraction)
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek uint_t max = ipst->ips_ip_dce_reclaim_threshold;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = nextdce) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Clear DCEF_PMTU if the pmtu is too old */
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni TICK_TO_SEC(ddi_get_lbolt64()) - dce->dce_last_change_time >
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek hash = RANDOM_HASH((uint64_t)((uintptr_t)dce | seed));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * kmem_cache callback to free up memory.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Walk all CONNs that can have a reference on an ire, nce or dce.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Get them to update any stale references to drop any refholds they
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipcl_walk(conn_ixa_cleanup, (void *)B_FALSE, ipst);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * Called by dce_reclaim_worker() below, and no one else. Typically this will
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * mean that the number of entries in the hash buckets has exceeded a tunable
4ba231cedd10104ba0c43236736c7a3b1bbc1143Kacheong Poon * netstack_next() can return a netstack_t with a NULL
4ba231cedd10104ba0c43236736c7a3b1bbc1143Kacheong Poon * netstack_ip at boot time.
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek if (atomic_swap_uint(&ipst->ips_dce_reclaim_needed, 0) != 0)
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek/* ARGSUSED */
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek CALLB_CPR_INIT(&cprinfo, &dce_reclaim_lock, callb_generic_cpr,
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek "dce_reclaim_worker");
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek (void) cv_timedwait(&dce_reclaim_cv, &dce_reclaim_lock,
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek ddi_get_lbolt() + ip_dce_reclaim_interval * hz);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek CALLB_CPR_SAFE_END(&cprinfo, &dce_reclaim_lock);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek CALLB_CPR_EXIT(&cprinfo); /* drops the lock */
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek sizeof (dce_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek mutex_init(&dce_reclaim_lock, NULL, MUTEX_DEFAULT, NULL);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek cv_init(&dce_reclaim_cv, NULL, CV_DEFAULT, NULL);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek dce_reclaim_thread = thread_create(NULL, 0, dce_reclaim_worker,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Allocate a default DCE and a hash table for per-IP address DCEs
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_default = kmem_cache_alloc(dce_cache, KM_SLEEP);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_default->dce_flags = DCEF_DEFAULT;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_default->dce_generation = DCE_GENERATION_INITIAL;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_default->dce_refcnt = 1; /* Should never go away */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* This must be a power of two since we are using IRE_ADDR_HASH macro */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_hash_v4 = kmem_zalloc(ipst->ips_dce_hashsize *
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ipst->ips_dce_hash_v6 = kmem_zalloc(ipst->ips_dce_hashsize *
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark rw_init(&ipst->ips_dce_hash_v4[i].dcb_lock, NULL, RW_DEFAULT,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark rw_init(&ipst->ips_dce_hash_v6[i].dcb_lock, NULL, RW_DEFAULT,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark rw_destroy(&ipst->ips_dce_hash_v4[i].dcb_lock);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark rw_destroy(&ipst->ips_dce_hash_v6[i].dcb_lock);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ASSERT(ipst->ips_dce_default->dce_refcnt == 1);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark kmem_cache_free(dce_cache, ipst->ips_dce_default);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark/* When any DCE is good enough */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Generic for IPv4 and IPv6.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Used by callers that need to cache e.g., the datapath
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Returns the generation number in the last argument.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_lookup_pkt(mblk_t *mp, ip_xmit_attr_t *ixa, uint_t *generationp)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If we have a source route we need to look for the final
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * destination in the source route option.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark return (dce_lookup_v4(final_dst, ixa->ixa_ipst, generationp));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If we have a routing header we need to look for the final
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * destination in the routing extension header.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark if (IN6_IS_ADDR_LINKSCOPE(&final_dst) && ixa->ixa_nce != NULL) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ifindex = ixa->ixa_nce->nce_common->ncec_ill->
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark return (dce_lookup_v6(&final_dst, ifindex, ixa->ixa_ipst,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Used by callers that need to cache e.g., the datapath
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Returns the generation number in the last argument.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_lookup_v4(ipaddr_t dst, ip_stack_t *ipst, uint_t *generationp)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Set *generationp before dropping the lock(s) that allow additions */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark *generationp = ipst->ips_dce_default->dce_generation;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark hash = IRE_ADDR_HASH(dst, ipst->ips_dce_hashsize);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Not found */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Used by callers that need to cache e.g., the datapath
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Returns the generation number in the last argument.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * ifindex should only be set for link-locals
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_lookup_v6(const in6_addr_t *dst, uint_t ifindex, ip_stack_t *ipst,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Set *generationp before dropping the lock(s) that allow additions */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark *generationp = ipst->ips_dce_default->dce_generation;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark hash = IRE_ADDR_HASH_V6(*dst, ipst->ips_dce_hashsize);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark if (IN6_ARE_ADDR_EQUAL(&dce->dce_v6addr, dst) &&
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Not found */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Atomically looks for a non-default DCE, and if not found tries to create one.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If there is no memory it returns NULL.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * When an entry is created we increase the generation number on
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * the default DCE so that conn_ip_output will detect there is a new DCE.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_lookup_and_add_v4(ipaddr_t dst, ip_stack_t *ipst)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark hash = IRE_ADDR_HASH(dst, ipst->ips_dce_hashsize);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * Assuming that we get fairly even distribution across all of the
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * buckets, once one bucket is overly full, prune the whole cache.
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek if (dcb->dcb_cnt > ipst->ips_ip_dce_reclaim_threshold)
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek atomic_or_uint(&ipst->ips_dce_reclaim_needed, 1);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce = kmem_cache_alloc(dce_cache, KM_NOSLEEP);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni dce->dce_last_change_time = TICK_TO_SEC(ddi_get_lbolt64());
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Link into list */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Initialize dce_ident to be different than for the last packet */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_ident = ipst->ips_dce_default->dce_ident + 1;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce_increment_generation(ipst->ips_dce_default);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Atomically looks for a non-default DCE, and if not found tries to create one.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If there is no memory it returns NULL.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * When an entry is created we increase the generation number on
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * the default DCE so that conn_ip_output will detect there is a new DCE.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * ifindex should only be used with link-local addresses.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_lookup_and_add_v6(const in6_addr_t *dst, uint_t ifindex, ip_stack_t *ipst)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* We should not create entries for link-locals w/o an ifindex */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ASSERT(!(IN6_IS_ADDR_LINKSCOPE(dst)) || ifindex != 0);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark hash = IRE_ADDR_HASH_V6(*dst, ipst->ips_dce_hashsize);
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * Assuming that we get fairly even distribution across all of the
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek * buckets, once one bucket is overly full, prune the whole cache.
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek if (dcb->dcb_cnt > ipst->ips_ip_dce_reclaim_threshold)
7c6d7024e51780d3aacf9063d2133c1e957d7eeaJerry Jelinek atomic_or_uint(&ipst->ips_dce_reclaim_needed, 1);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark if (IN6_ARE_ADDR_EQUAL(&dce->dce_v6addr, dst) &&
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce = kmem_cache_alloc(dce_cache, KM_NOSLEEP);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni dce->dce_last_change_time = TICK_TO_SEC(ddi_get_lbolt64());
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Link into list */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Initialize dce_ident to be different than for the last packet */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_ident = ipst->ips_dce_default->dce_ident + 1;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce_increment_generation(ipst->ips_dce_default);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Set/update uinfo. Creates a per-destination dce if none exists.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Note that we do not bump the generation number here.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * New connections will find the new uinfo.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * The only use of this (tcp, sctp using iulp_t) is to set rtt+rtt_sd.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Update the round trip time estimate and/or the max frag size
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * and/or the slow start threshold.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * We serialize multiple advises using dce_lock.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Gard against setting to zero */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * If there is no old cached values, initialize them
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * conservatively. Set them to be (1.5 * new value).
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_uinfo.iulp_rtt = (dce->dce_uinfo.iulp_rtt +
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_uinfo.iulp_rtt_sd = uinfo->iulp_rtt_sd +
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_pmtu = MIN(uinfo->iulp_mtu, dce->dce_pmtu);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_pmtu = MIN(uinfo->iulp_mtu, IP_MAXPACKET);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni dce->dce_last_change_time = TICK_TO_SEC(ddi_get_lbolt64());
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_uinfo.iulp_ssthresh = uinfo->iulp_ssthresh;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* We have uinfo for sure */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_update_uinfo_v4(ipaddr_t dst, iulp_t *uinfo, ip_stack_t *ipst)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_update_uinfo_v6(const in6_addr_t *dst, uint_t ifindex, iulp_t *uinfo,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce = dce_lookup_and_add_v6(dst, ifindex, ipst);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark/* Common routine for IPv4 and IPv6 */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_update_uinfo(const in6_addr_t *dst, uint_t ifindex, iulp_t *uinfo,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark return (dce_update_uinfo_v4(dst4, uinfo, ipst));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark return (dce_update_uinfo_v6(dst, ifindex, uinfo, ipst));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce->dce_generation = DCE_GENERATION_CONDEMNED;
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Count how many condemned dces for kmem_cache callback */
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_inc_32(&ipst->ips_num_dce_condemned);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Increment the generation avoiding the special condemned value
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Increment the generation number on all dces that have a path MTU and
1eee170a5f6cf875d905524fea524c7c5c870aa0Erik Nordmark * the default DCE. Used when ill_mtu or ill_mc_mtu changes.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkdce_increment_all_generations(boolean_t isv6, ip_stack_t *ipst)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark dce_increment_generation(ipst->ips_dce_default);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Caller needs to do a dce_refrele since we can't do the
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * dce_refrele under dcb_lock.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Count how many condemned dces for kmem_cache callback */
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_dec_32(&ipst->ips_num_dce_condemned);
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek if (atomic_dec_32_nv(&dce->dce_refcnt) == 0)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark/* No tracing support yet hence the same as the above functions */
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek if (atomic_dec_32_nv(&dce->dce_refcnt) == 0)
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark/* Report both the IPv4 and IPv6 DCEs. */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmarkip_snmp_get_mib2_ip_dce(queue_t *q, mblk_t *mpctl, ip_stack_t *ipst)
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni current_time = TICK_TO_SEC(ddi_get_lbolt64());
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * make a copy of the original message
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* First we do IPv4 entries */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark sizeof (struct T_optmgmt_ack)];
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark if (!snmp_append_data2(mpctl->b_cont, &mp_tail,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark (char *)&dest_cache, (int)sizeof (dest_cache))) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark "failed to allocate %u bytes\n",
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark optp->len = (t_uscalar_t)msgdsize(mpctl->b_cont);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ip3dbg(("ip_snmp_get: level %d, name %d, len %d\n",
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark (int)optp->level, (int)optp->name, (int)optp->len));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Copymsg failed above */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark /* Now for IPv6 */
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark sizeof (struct T_optmgmt_ack)];
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = dce->dce_next) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark if (!snmp_append_data2(mpctl->b_cont, &mp_tail,
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark (char *)&dest_cache, (int)sizeof (dest_cache))) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark "failed to allocate %u bytes\n",
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark optp->len = (t_uscalar_t)msgdsize(mpctl->b_cont);
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark ip3dbg(("ip_snmp_get: level %d, name %d, len %d\n",
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark (int)optp->level, (int)optp->name, (int)optp->len));
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Remove IPv6 DCEs which refer to an ifindex that is going away.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * This is not required for correctness, but it avoids netstat -d
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * showing stale stuff that will never be used.
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (i = 0; i < ipst->ips_dce_hashsize; i++) {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark for (dce = dcb->dcb_dce; dce != NULL; dce = nextdce) {