Exemplo n.º 1
0
/* ARGSUSED */
void
ip_dce_reclaim(void *args)
{
	netstack_handle_t nh;
	netstack_t *ns;

	netstack_next_init(&nh);
	while ((ns = netstack_next(&nh)) != NULL) {
		ip_dce_reclaim_stack(ns->netstack_ip);
		netstack_rele(ns);
	}
	netstack_next_fini(&nh);
}
Exemplo n.º 2
0
/* ARGSUSED */
void
sctp_conn_reclaim(void *arg)
{
	netstack_handle_t nh;
	netstack_t *ns;
	sctp_stack_t *sctps;
	extern pgcnt_t lotsfree, needfree;

	if (!sctp_do_reclaim)
		return;

	/*
	 * The reclaim function may be called even when the system is not
	 * really under memory pressure.
	 */
	if (freemem >= lotsfree + needfree)
		return;

	netstack_next_init(&nh);
	while ((ns = netstack_next(&nh)) != NULL) {
		int i;
		int64_t tot_assoc = 0;

		/*
		 * During boot time, the first netstack_t is created and
		 * initialized before SCTP has registered with the netstack
		 * framework.  If this reclaim function is called before SCTP
		 * has finished its initialization, netstack_next() will
		 * return the first netstack_t (since its netstack_flags is
		 * not NSF_UNINIT).  And its netstack_sctp will be NULL.  We
		 * need to catch it.
		 *
		 * All subsequent netstack_t creation will not have this
		 * problem since the initialization is not finished until SCTP
		 * has finished its own sctp_stack_t initialization.  Hence
		 * netstack_next() will not return one with NULL netstack_sctp.
		 */
		if ((sctps = ns->netstack_sctp) == NULL) {
			netstack_rele(ns);
			continue;
		}

		/*
		 * Even if the system is under memory pressure, the reason may
		 * not be because of SCTP activity.  Check the number of
		 * associations in each stack.  If the number exceeds the
		 * threshold (maxusers), turn on defensive mode.
		 */
		for (i = 0; i < sctps->sctps_sc_cnt; i++)
			tot_assoc += sctps->sctps_sc[i]->sctp_sc_assoc_cnt;
		if (tot_assoc < maxusers) {
			netstack_rele(ns);
			continue;
		}

		mutex_enter(&sctps->sctps_reclaim_lock);
		if (!sctps->sctps_reclaim) {
			sctps->sctps_reclaim = B_TRUE;
			sctps->sctps_reclaim_tid = timeout(sctp_reclaim_timer,
			    sctps, MSEC_TO_TICK(sctps->sctps_reclaim_period));
			SCTP_KSTAT(sctps, sctp_reclaim_cnt);
		}
		mutex_exit(&sctps->sctps_reclaim_lock);
		netstack_rele(ns);
	}
	netstack_next_fini(&nh);
}