| 1199 | } |
| 1200 | |
| 1201 | static void |
| 1202 | key_unlink(struct secpolicy *sp) |
| 1203 | { |
| 1204 | |
| 1205 | IPSEC_ASSERT(sp->spidx.dir == IPSEC_DIR_INBOUND || |
| 1206 | sp->spidx.dir == IPSEC_DIR_OUTBOUND, |
| 1207 | ("invalid direction %u", sp->spidx.dir)); |
| 1208 | SPTREE_UNLOCK_ASSERT(); |
| 1209 | |
| 1210 | KEYDBG(KEY_STAMP, |
| 1211 | printf("%s: SP(%p)\n", __func__, sp)); |
| 1212 | SPTREE_WLOCK(); |
| 1213 | if (sp->state != IPSEC_SPSTATE_ALIVE) { |
| 1214 | /* SP is already unlinked */ |
| 1215 | SPTREE_WUNLOCK(); |
| 1216 | return; |
| 1217 | } |
| 1218 | sp->state = IPSEC_SPSTATE_DEAD; |
| 1219 | TAILQ_REMOVE(&V_sptree[sp->spidx.dir], sp, chain); |
| 1220 | V_spd_size--; |
| 1221 | LIST_REMOVE(sp, idhash); |
| 1222 | V_sp_genid++; |
| 1223 | SPTREE_WUNLOCK(); |
| 1224 | if (SPDCACHE_ENABLED()) |
| 1225 | spdcache_clear(); |
| 1226 | key_freesp(&sp); |
| 1227 | } |
| 1228 | |
| 1229 | /* |
| 1230 | * insert a secpolicy into the SP database. Lower priorities first |
no test coverage detected