| 410 | } |
| 411 | |
| 412 | static struct secpolicy * |
| 413 | ipsec_checkpolicy(struct secpolicy *sp, struct inpcb *inp, int *error) |
| 414 | { |
| 415 | |
| 416 | /* Save found OUTBOUND policy into PCB SP cache. */ |
| 417 | if (inp != NULL && inp->inp_sp != NULL && inp->inp_sp->sp_out == NULL) |
| 418 | ipsec_cachepolicy(inp, sp, IPSEC_DIR_OUTBOUND); |
| 419 | |
| 420 | switch (sp->policy) { |
| 421 | default: |
| 422 | printf("%s: invalid policy %u\n", __func__, sp->policy); |
| 423 | /* FALLTHROUGH */ |
| 424 | case IPSEC_POLICY_DISCARD: |
| 425 | *error = -EINVAL; /* Packet is discarded by caller. */ |
| 426 | /* FALLTHROUGH */ |
| 427 | case IPSEC_POLICY_BYPASS: |
| 428 | case IPSEC_POLICY_NONE: |
| 429 | key_freesp(&sp); |
| 430 | sp = NULL; /* NB: force NULL result. */ |
| 431 | break; |
| 432 | case IPSEC_POLICY_IPSEC: |
| 433 | /* XXXAE: handle LARVAL SP */ |
| 434 | break; |
| 435 | } |
| 436 | KEYDBG(IPSEC_DUMP, |
| 437 | printf("%s: get SP(%p), error %d\n", __func__, sp, *error)); |
| 438 | return (sp); |
| 439 | } |
| 440 | |
| 441 | static struct secpolicy * |
| 442 | ipsec_getpcbpolicy(struct inpcb *inp, u_int dir) |
no test coverage detected