Date: Fri, 1 Dec 2017 09:59:42 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326422 - head/sys/netipsec Message-ID: <201712010959.vB19xgtL061089@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Fri Dec 1 09:59:42 2017 New Revision: 326422 URL: https://svnweb.freebsd.org/changeset/base/326422 Log: Do better cleaning in key_destroy() for VIMAGE case. SPDB was cleaned using TAILQ_CONCAT() instead of calling key_unlink() for each SP, thus we need to properly clean lists in each bucket of V_sphashtbl to avoid panic in hashdestroy() when INVARIANTS is enabled. Do the same for V_acqaddrhashtbl and V_acqseqhashtbl. When we are called in DEFAULT_VNET, destroy also all global locks and drain key_timer callout. Reported by: kp Tested by: kp MFC after: 1 week Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Fri Dec 1 06:37:12 2017 (r326421) +++ head/sys/netipsec/key.c Fri Dec 1 09:59:42 2017 (r326422) @@ -8147,7 +8147,10 @@ key_destroy(void) TAILQ_CONCAT(&drainq, &V_sptree[i], chain); TAILQ_CONCAT(&drainq, &V_sptree_ifnet[i], chain); } + for (i = 0; i < V_sphash_mask + 1; i++) + LIST_INIT(&V_sphashtbl[i]); SPTREE_WUNLOCK(); + sp = TAILQ_FIRST(&drainq); while (sp != NULL) { nextsp = TAILQ_NEXT(sp, chain); @@ -8198,6 +8201,10 @@ key_destroy(void) free(acq, M_IPSEC_SAQ); acq = nextacq; } + for (i = 0; i < V_acqaddrhash_mask + 1; i++) + LIST_INIT(&V_acqaddrhashtbl[i]); + for (i = 0; i < V_acqseqhash_mask + 1; i++) + LIST_INIT(&V_acqseqhashtbl[i]); ACQ_UNLOCK(); SPACQ_LOCK(); @@ -8213,6 +8220,18 @@ key_destroy(void) hashdestroy(V_acqaddrhashtbl, M_IPSEC_SAQ, V_acqaddrhash_mask); hashdestroy(V_acqseqhashtbl, M_IPSEC_SAQ, V_acqseqhash_mask); uma_zdestroy(V_key_lft_zone); + + if (!IS_DEFAULT_VNET(curvnet)) + return; +#ifndef IPSEC_DEBUG2 + callout_drain(&key_timer); +#endif + XFORMS_LOCK_DESTROY(); + SPTREE_LOCK_DESTROY(); + REGTREE_LOCK_DESTROY(); + SAHTREE_LOCK_DESTROY(); + ACQ_LOCK_DESTROY(); + SPACQ_LOCK_DESTROY(); } #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712010959.vB19xgtL061089>