ipsec: Drain async ipsec_offload work when destroying a vnet

Re-apply commit e196b12f4d.  This was reverted by commit 28294dc924
because it could trigger a deadlock, but the underlying problem there
was fixed in commit f76826b892.

Reported by:	KASAN
Reviewed by:	kib
Fixes:		ef2a572bf6 ("ipsec_offload: kernel infrastructure")
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D46483
This commit is contained in:
Mark Johnston 2024-08-30 00:44:45 +00:00
parent 408c909dc6
commit 01f43479b5
2 changed files with 4 additions and 1 deletions

View file

@ -392,7 +392,7 @@ ipsec_accel_sa_newkey_impl(struct secasvar *sav)
TASK_INIT(&tq->install_task, 0, ipsec_accel_sa_newkey_act, tq);
tq->sav = sav;
tq->install_vnet = curthread->td_vnet; /* XXXKIB liveness */
tq->install_vnet = curthread->td_vnet;
taskqueue_enqueue(ipsec_accel_tq, &tq->install_task);
}

View file

@ -8713,6 +8713,9 @@ key_vnet_destroy(void *arg __unused)
}
SAHTREE_WUNLOCK();
/* Wait for async work referencing this VNET to finish. */
ipsec_accel_sync();
key_freesah_flushed(&sahdrainq);
hashdestroy(V_sphashtbl, M_IPSEC_SP, V_sphash_mask);
hashdestroy(V_savhashtbl, M_IPSEC_SA, V_savhash_mask);