| 710 | #endif /* INET6 */ |
| 711 | |
| 712 | int |
| 713 | ipsec_process_done(struct mbuf *m, struct secpolicy *sp, struct secasvar *sav, |
| 714 | u_int idx) |
| 715 | { |
| 716 | struct epoch_tracker et; |
| 717 | struct xform_history *xh; |
| 718 | struct secasindex *saidx; |
| 719 | struct m_tag *mtag; |
| 720 | int error; |
| 721 | |
| 722 | saidx = &sav->sah->saidx; |
| 723 | switch (saidx->dst.sa.sa_family) { |
| 724 | #ifdef INET |
| 725 | case AF_INET: |
| 726 | /* Fix the header length, for AH processing. */ |
| 727 | mtod(m, struct ip *)->ip_len = htons(m->m_pkthdr.len); |
| 728 | break; |
| 729 | #endif /* INET */ |
| 730 | #ifdef INET6 |
| 731 | case AF_INET6: |
| 732 | /* Fix the header length, for AH processing. */ |
| 733 | if (m->m_pkthdr.len < sizeof (struct ip6_hdr)) { |
| 734 | error = ENXIO; |
| 735 | goto bad; |
| 736 | } |
| 737 | if (m->m_pkthdr.len - sizeof (struct ip6_hdr) > IPV6_MAXPACKET) { |
| 738 | /* No jumbogram support. */ |
| 739 | error = ENXIO; /*?*/ |
| 740 | goto bad; |
| 741 | } |
| 742 | mtod(m, struct ip6_hdr *)->ip6_plen = |
| 743 | htons(m->m_pkthdr.len - sizeof(struct ip6_hdr)); |
| 744 | break; |
| 745 | #endif /* INET6 */ |
| 746 | default: |
| 747 | DPRINTF(("%s: unknown protocol family %u\n", __func__, |
| 748 | saidx->dst.sa.sa_family)); |
| 749 | error = ENXIO; |
| 750 | goto bad; |
| 751 | } |
| 752 | |
| 753 | /* |
| 754 | * Add a record of what we've done to the packet. |
| 755 | */ |
| 756 | mtag = m_tag_get(PACKET_TAG_IPSEC_OUT_DONE, sizeof(*xh), M_NOWAIT); |
| 757 | if (mtag == NULL) { |
| 758 | DPRINTF(("%s: could not get packet tag\n", __func__)); |
| 759 | error = ENOMEM; |
| 760 | goto bad; |
| 761 | } |
| 762 | |
| 763 | xh = (struct xform_history *)(mtag + 1); |
| 764 | xh->dst = saidx->dst; |
| 765 | xh->proto = saidx->proto; |
| 766 | xh->mode = saidx->mode; |
| 767 | xh->spi = sav->spi; |
| 768 | m_tag_prepend(m, mtag); |
| 769 |
no test coverage detected