FreeBSD/sys/netgraph/netflow/netflow.c
/* Initialize new FIB table for v5 and v9 */
Initialize new FIB table for v5 and v9
Initialize new FIB table for v5 and v9
int
ng_netflow_fib_init(priv_p priv, int fib)
{
	fib_export_p	fe = priv_to_fib(priv, fib);
	CTR1(KTR_NET, "ng_netflow(): fib init: %d", fib);
	if (fe != NULL)
		return (0);
	if ((fe = malloc(sizeof(struct fib_export), M_NETGRAPH,
	    M_NOWAIT | M_ZERO)) == NULL)
		return (ENOMEM);
	mtx_init(&fe->export_mtx, "export dgram lock", NULL, MTX_DEF);
	mtx_init(&fe->export9_mtx, "export9 dgram lock", NULL, MTX_DEF);
	fe->fib = fib;
	fe->domain_id = fib;
	if (atomic_cmpset_ptr((volatile uintptr_t *)&priv->fib_data[fib],
	    (uintptr_t)NULL, (uintptr_t)fe) == 0) {
		CTR3(KTR_NET, "ng_netflow(): fib init: %d setup %p but got %p",
		    fib, fe, priv_to_fib(priv, fib));
		mtx_destroy(&fe->export_mtx);
		mtx_destroy(&fe->export9_mtx);
		free(fe, M_NETGRAPH);
	} else {
		CTR3(KTR_NET, "ng_netflow(): fib %d setup to %p (%p)",
		    fib, fe, priv_to_fib(priv, fib));
		priv->nfinfo_alloc_fibs++;
	}
	return (0);
}
int ng_netflow_fib_init ( priv_p priv , int fib ) { fib_export_p fe = priv_to_fib ( priv , fib ) ; CTR1 ( KTR_NET , " " , fib ) ; if ( fe != NULL ) return ( 0 ) ; if ( ( fe = malloc ( sizeof ( struct fib_export ) , M_NETGRAPH , M_NOWAIT | M_ZERO ) ) == NULL ) return ( ENOMEM ) ; mtx_init ( & fe -> export_mtx , " " , NULL , MTX_DEF ) ; mtx_init ( & fe -> export9_mtx , " " , NULL , MTX_DEF ) ; fe -> fib = fib ; fe -> domain_id = fib ; if ( atomic_cmpset_ptr ( ( volatile uintptr_t * ) & priv -> fib_data [ fib ] , ( uintptr_t ) NULL , ( uintptr_t ) fe ) == 0 ) { CTR3 ( KTR_NET , " " , fib , fe , priv_to_fib ( priv , fib ) ) ; mtx_destroy ( & fe -> export_mtx ) ; mtx_destroy ( & fe -> export9_mtx ) ; free ( fe , M_NETGRAPH ) ; } else { CTR3 ( KTR_NET , " " , fib , fe , priv_to_fib ( priv , fib ) ) ; priv -> nfinfo_alloc_fibs ++ ; } return ( 0 ) ; }
Initialize new FIB table for v5 and v9
Initialize new FIB table for v5 and v9
/* FIB already set up by other ISR */ /* Increase counter for statistics */