MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipsec_process_done

Function ipsec_process_done

freebsd/netipsec/ipsec_output.c:712–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710#endif /* INET6 */
711
712int
713ipsec_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

Callers 4

ipcomp_outputFunction · 0.85
ipcomp_output_cbFunction · 0.85
ah_output_cbFunction · 0.85
esp_output_cbFunction · 0.85

Calls 12

key_sa_recordxferFunction · 0.85
key_freesavFunction · 0.85
ipsec4_perform_requestFunction · 0.85
ipsec6_perform_requestFunction · 0.85
key_freespFunction · 0.85
udp_ipsec_outputFunction · 0.85
ip_outputFunction · 0.85
ip6_outputFunction · 0.85
m_tag_getFunction · 0.50
m_tag_prependFunction · 0.50
panicFunction · 0.50
m_freemFunction · 0.50

Tested by

no test coverage detected