| 8314 | |
| 8315 | #ifdef VIMAGE |
| 8316 | void |
| 8317 | key_destroy(void) |
| 8318 | { |
| 8319 | struct secashead_queue sahdrainq; |
| 8320 | struct secpolicy_queue drainq; |
| 8321 | struct secpolicy *sp, *nextsp; |
| 8322 | struct secacq *acq, *nextacq; |
| 8323 | struct secspacq *spacq, *nextspacq; |
| 8324 | struct secashead *sah; |
| 8325 | struct secasvar *sav; |
| 8326 | struct secreg *reg; |
| 8327 | int i; |
| 8328 | |
| 8329 | /* |
| 8330 | * XXX: can we just call free() for each object without |
| 8331 | * walking through safe way with releasing references? |
| 8332 | */ |
| 8333 | TAILQ_INIT(&drainq); |
| 8334 | SPTREE_WLOCK(); |
| 8335 | for (i = 0; i < IPSEC_DIR_MAX; i++) { |
| 8336 | TAILQ_CONCAT(&drainq, &V_sptree[i], chain); |
| 8337 | TAILQ_CONCAT(&drainq, &V_sptree_ifnet[i], chain); |
| 8338 | } |
| 8339 | for (i = 0; i < V_sphash_mask + 1; i++) |
| 8340 | LIST_INIT(&V_sphashtbl[i]); |
| 8341 | SPTREE_WUNLOCK(); |
| 8342 | spdcache_destroy(); |
| 8343 | |
| 8344 | sp = TAILQ_FIRST(&drainq); |
| 8345 | while (sp != NULL) { |
| 8346 | nextsp = TAILQ_NEXT(sp, chain); |
| 8347 | key_freesp(&sp); |
| 8348 | sp = nextsp; |
| 8349 | } |
| 8350 | |
| 8351 | TAILQ_INIT(&sahdrainq); |
| 8352 | SAHTREE_WLOCK(); |
| 8353 | TAILQ_CONCAT(&sahdrainq, &V_sahtree, chain); |
| 8354 | for (i = 0; i < V_savhash_mask + 1; i++) |
| 8355 | LIST_INIT(&V_savhashtbl[i]); |
| 8356 | for (i = 0; i < V_sahaddrhash_mask + 1; i++) |
| 8357 | LIST_INIT(&V_sahaddrhashtbl[i]); |
| 8358 | TAILQ_FOREACH(sah, &sahdrainq, chain) { |
| 8359 | sah->state = SADB_SASTATE_DEAD; |
| 8360 | TAILQ_FOREACH(sav, &sah->savtree_larval, chain) { |
| 8361 | sav->state = SADB_SASTATE_DEAD; |
| 8362 | } |
| 8363 | TAILQ_FOREACH(sav, &sah->savtree_alive, chain) { |
| 8364 | sav->state = SADB_SASTATE_DEAD; |
| 8365 | } |
| 8366 | } |
| 8367 | SAHTREE_WUNLOCK(); |
| 8368 | |
| 8369 | key_freesah_flushed(&sahdrainq); |
| 8370 | hashdestroy(V_sphashtbl, M_IPSEC_SP, V_sphash_mask); |
| 8371 | hashdestroy(V_savhashtbl, M_IPSEC_SA, V_savhash_mask); |
| 8372 | hashdestroy(V_sahaddrhashtbl, M_IPSEC_SAH, V_sahaddrhash_mask); |
| 8373 |
nothing calls this directly
no test coverage detected