Fixed deletion of sav entries in key_delsah()

Approved by:	gnn(mentor)
Obtained from:	NETASQ
MFC after:	1 month
This commit is contained in:
VANHULLEBUS Yvan 2009-03-18 14:01:41 +00:00
parent aa73f8c7a2
commit e0a9f20020
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189962

View File

@ -2687,7 +2687,10 @@ key_delsah(sah)
if (sav->refcnt == 0) {
/* sanity check */
KEY_CHKSASTATE(state, sav->state, __func__);
KEY_FREESAV(&sav);
/* do NOT call KEY_FREESAV here: it will only delete the sav if refcnt == 1,
* where we already know that refcnt == 0
*/
key_delsav(sav);
} else {
/* give up to delete this sa */
zombie++;
@ -4131,6 +4134,8 @@ key_flush_sad(time_t now)
/* if LARVAL entry doesn't become MATURE, delete it. */
LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_LARVAL], chain, nextsav) {
/* Need to also check refcnt for a larval SA ???
*/
if (now - sav->created > V_key_larval_lifetime)
KEY_FREESAV(&sav);
}