* insert a secpolicy into the SP database. Lower priorities first */
| 1230 | * insert a secpolicy into the SP database. Lower priorities first |
| 1231 | */ |
| 1232 | static void |
| 1233 | key_insertsp(struct secpolicy *newsp) |
| 1234 | { |
| 1235 | struct secpolicy *sp; |
| 1236 | |
| 1237 | SPTREE_WLOCK_ASSERT(); |
| 1238 | TAILQ_FOREACH(sp, &V_sptree[newsp->spidx.dir], chain) { |
| 1239 | if (newsp->priority < sp->priority) { |
| 1240 | TAILQ_INSERT_BEFORE(sp, newsp, chain); |
| 1241 | goto done; |
| 1242 | } |
| 1243 | } |
| 1244 | TAILQ_INSERT_TAIL(&V_sptree[newsp->spidx.dir], newsp, chain); |
| 1245 | done: |
| 1246 | LIST_INSERT_HEAD(SPHASH_HASH(newsp->id), newsp, idhash); |
| 1247 | newsp->state = IPSEC_SPSTATE_ALIVE; |
| 1248 | V_spd_size++; |
| 1249 | V_sp_genid++; |
| 1250 | } |
| 1251 | |
| 1252 | /* |
| 1253 | * Insert a bunch of VTI secpolicies into the SPDB. |