FreeBSD/sys/netipsec/key.c
/* %%% SAD management */
/*
 * allocating a memory for new SA head, and copy from the values of mhp.
 * OUT:	NULL	: failure due to the lack of memory.
 *	others	: pointer to new SA head.
 */
%%% SAD management
allocating a memory for new SA head, and copy from the values of mhp.
OUT: NULL    : failure due to the lack of memory.
others  : pointer to new SA head.
%%% SAD management allocating a memory for new SA head and copy from the values of mhp . OUT : NULL : failure due to the lack of memory . others : pointer to new SA head .
static struct secashead *
key_newsah(struct secasindex *saidx)
{
	struct secashead *newsah;
	IPSEC_ASSERT(saidx != NULL, ("null saidx"));
	newsah = malloc(sizeof(struct secashead), M_IPSEC_SAH, M_NOWAIT|M_ZERO);
	if (newsah != NULL) {
		int i;
		for (i = 0; i < sizeof(newsah->savtree)/sizeof(newsah->savtree[0]); i++)
			LIST_INIT(&newsah->savtree[i]);
		newsah->saidx = *saidx;
		newsah->state = SADB_SASTATE_MATURE;
		SAHTREE_LOCK();
		LIST_INSERT_HEAD(&V_sahtree, newsah, chain);
		SAHTREE_UNLOCK();
	}
	return(newsah);
}
static struct secashead * key_newsah ( struct secasindex * saidx ) { struct secashead * newsah ; IPSEC_ASSERT ( saidx != NULL , ( " " ) ) ; newsah = malloc ( sizeof ( struct secashead ) , M_IPSEC_SAH , M_NOWAIT | M_ZERO ) ; if ( newsah != NULL ) { int i ; for ( i = 0 ; i < sizeof ( newsah -> savtree ) / sizeof ( newsah -> savtree [ 0 ] ) ; i ++ ) LIST_INIT ( & newsah -> savtree [ i ] ) ; newsah -> saidx = * saidx ; newsah -> state = SADB_SASTATE_MATURE ; SAHTREE_LOCK ( ) ; LIST_INSERT_HEAD ( & V_sahtree , newsah , chain ) ; SAHTREE_UNLOCK ( ) ; } return ( newsah ) ; }
%%% SAD management
 allocating a memory for new SA head, and copy from the values of mhp.
%%% SAD management allocating a memory for new SA head and copy from the values of mhp .
/* add to saidxtree */