FreeBSD/sys/netgraph/netflow/netflow.c
/* Free all flow cache memory. Called from node close method. */
Free all flow cache memory. Called from node close method.
Free all flow cache memory . Called from node close method .
void
ng_netflow_cache_flush(priv_p priv)
{
	struct flow_entry	*fle, *fle1;
	struct flow_hash_entry	*hsh;
	struct netflow_export_item exp;
	fib_export_p fe;
	int i;
	bzero(&exp, sizeof(exp));
	for (hsh = priv->hash, i = 0; i < NBUCKETS; hsh++, i++)
		TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) {
			TAILQ_REMOVE(&hsh->head, fle, fle_hash);
			fe = priv_to_fib(priv, fle->f.r.fib);
			expire_flow(priv, fe, fle, NG_QUEUE);
		}
#ifdef INET6
	for (hsh = priv->hash6, i = 0; i < NBUCKETS; hsh++, i++)
		TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) {
			TAILQ_REMOVE(&hsh->head, fle, fle_hash);
			fe = priv_to_fib(priv, fle->f.r.fib);
			expire_flow(priv, fe, fle, NG_QUEUE);
		}
#endif
	uma_zdestroy(priv->zone);
	for (i = 0, hsh = priv->hash; i < NBUCKETS; i++, hsh++)
		mtx_destroy(&hsh->mtx);
	if (priv->hash != NULL)
		free(priv->hash, M_NETFLOW_HASH);
#ifdef INET6
	uma_zdestroy(priv->zone6);
	for (i = 0, hsh = priv->hash6; i < NBUCKETS; i++, hsh++)
		mtx_destroy(&hsh->mtx);
	if (priv->hash6 != NULL)
		free(priv->hash6, M_NETFLOW_HASH);
#endif
	for (i = 0; i < priv->maxfibs; i++) {
		if ((fe = priv_to_fib(priv, i)) == NULL)
			continue;
		if (fe->exp.item != NULL)
			export_send(priv, fe, fe->exp.item, NG_QUEUE);
		if (fe->exp.item9 != NULL)
			export9_send(priv, fe, fe->exp.item9,
			    fe->exp.item9_opt, NG_QUEUE);
		mtx_destroy(&fe->export_mtx);
		mtx_destroy(&fe->export9_mtx);
		free(fe, M_NETGRAPH);
	}
	counter_u64_free(priv->nfinfo_bytes);
	counter_u64_free(priv->nfinfo_packets);
	counter_u64_free(priv->nfinfo_bytes6);
	counter_u64_free(priv->nfinfo_packets6);
	counter_u64_free(priv->nfinfo_sbytes);
	counter_u64_free(priv->nfinfo_spackets);
	counter_u64_free(priv->nfinfo_sbytes6);
	counter_u64_free(priv->nfinfo_spackets6);
	counter_u64_free(priv->nfinfo_act_exp);
	counter_u64_free(priv->nfinfo_inact_exp);
	ng_netflow_v9_cache_flush(priv);
}
void ng_netflow_cache_flush ( priv_p priv ) { struct flow_entry * fle , * fle1 ; struct flow_hash_entry * hsh ; struct netflow_export_item exp ; fib_export_p fe ; int i ; bzero ( & exp , sizeof ( exp ) ) ; for ( hsh = priv -> hash , i = 0 ; i < NBUCKETS ; hsh ++ , i ++ ) TAILQ_FOREACH_SAFE ( fle , & hsh -> head , fle_hash , fle1 ) { TAILQ_REMOVE ( & hsh -> head , fle , fle_hash ) ; fe = priv_to_fib ( priv , fle -> f . r . fib ) ; expire_flow ( priv , fe , fle , NG_QUEUE ) ; } #ifdef INET6 for ( hsh = priv -> hash6 , i = 0 ; i < NBUCKETS ; hsh ++ , i ++ ) TAILQ_FOREACH_SAFE ( fle , & hsh -> head , fle_hash , fle1 ) { TAILQ_REMOVE ( & hsh -> head , fle , fle_hash ) ; fe = priv_to_fib ( priv , fle -> f . r . fib ) ; expire_flow ( priv , fe , fle , NG_QUEUE ) ; } #endif uma_zdestroy ( priv -> zone ) ; for ( i = 0 , hsh = priv -> hash ; i < NBUCKETS ; i ++ , hsh ++ ) mtx_destroy ( & hsh -> mtx ) ; if ( priv -> hash != NULL ) free ( priv -> hash , M_NETFLOW_HASH ) ; #ifdef INET6 uma_zdestroy ( priv -> zone6 ) ; for ( i = 0 , hsh = priv -> hash6 ; i < NBUCKETS ; i ++ , hsh ++ ) mtx_destroy ( & hsh -> mtx ) ; if ( priv -> hash6 != NULL ) free ( priv -> hash6 , M_NETFLOW_HASH ) ; #endif for ( i = 0 ; i < priv -> maxfibs ; i ++ ) { if ( ( fe = priv_to_fib ( priv , i ) ) == NULL ) continue ; if ( fe -> exp . item != NULL ) export_send ( priv , fe , fe -> exp . item , NG_QUEUE ) ; if ( fe -> exp . item9 != NULL ) export9_send ( priv , fe , fe -> exp . item9 , fe -> exp . item9_opt , NG_QUEUE ) ; mtx_destroy ( & fe -> export_mtx ) ; mtx_destroy ( & fe -> export9_mtx ) ; free ( fe , M_NETGRAPH ) ; } counter_u64_free ( priv -> nfinfo_bytes ) ; counter_u64_free ( priv -> nfinfo_packets ) ; counter_u64_free ( priv -> nfinfo_bytes6 ) ; counter_u64_free ( priv -> nfinfo_packets6 ) ; counter_u64_free ( priv -> nfinfo_sbytes ) ; counter_u64_free ( priv -> nfinfo_spackets ) ; counter_u64_free ( priv -> nfinfo_sbytes6 ) ; counter_u64_free ( priv -> nfinfo_spackets6 ) ; counter_u64_free ( priv -> nfinfo_act_exp ) ; counter_u64_free ( priv -> nfinfo_inact_exp ) ; ng_netflow_v9_cache_flush ( priv ) ; }
Free all flow cache memory.
Free all flow cache memory .
/*
	 * We are going to free probably billable data.
	 * Expire everything before freeing it.
	 * No locking is required since callout is already drained.
	 */ /* Destroy hash mutexes. */ /* Free hash memory. */ /* Destroy hash mutexes. */ /* Free hash memory. */