* Check security policy for *OUTBOUND* IPv4 packet. */
| 597 | * Check security policy for *OUTBOUND* IPv4 packet. |
| 598 | */ |
| 599 | struct secpolicy * |
| 600 | ipsec4_checkpolicy(const struct mbuf *m, struct inpcb *inp, int *error, |
| 601 | int needport) |
| 602 | { |
| 603 | struct secpolicy *sp; |
| 604 | |
| 605 | *error = 0; |
| 606 | sp = ipsec4_getpolicy(m, inp, IPSEC_DIR_OUTBOUND, needport); |
| 607 | if (sp != NULL) |
| 608 | sp = ipsec_checkpolicy(sp, inp, error); |
| 609 | if (sp == NULL) { |
| 610 | switch (*error) { |
| 611 | case 0: /* No IPsec required: BYPASS or NONE */ |
| 612 | break; |
| 613 | case -EINVAL: |
| 614 | IPSECSTAT_INC(ips_out_polvio); |
| 615 | break; |
| 616 | default: |
| 617 | IPSECSTAT_INC(ips_out_inval); |
| 618 | } |
| 619 | } |
| 620 | KEYDBG(IPSEC_STAMP, |
| 621 | printf("%s: using SP(%p), error %d\n", __func__, sp, *error)); |
| 622 | if (sp != NULL) |
| 623 | KEYDBG(IPSEC_DATA, kdebug_secpolicy(sp)); |
| 624 | return (sp); |
| 625 | } |
| 626 | |
| 627 | /* |
| 628 | * Check IPv4 packet against *INBOUND* security policy. |
no test coverage detected