diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2024-12-29 07:12:26 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2025-01-13 19:29:32 +0000 |
| commit | 0ff2d00d2aa37cd883ffd8c7363dddef9cba267e (patch) | |
| tree | f2907311f4ad3bf405f3549722286463ab6b760a /sys/netinet/ip_output.c | |
| parent | b0e020764aae970545357b0f146dcba7b4b55864 (diff) | |
ipsec: allow it to work with unmapped mbufs
Only map mbuf when a policy is looked up and indicates that IPSEC needs
to transform the packet. If IPSEC is inline offloaded, it is up to the
interface driver to request remap if needed.
Fetch the IP header using m_copydata() instead of using mtod() to select
policy/SA.
Reviewed by: markj
Sponsored by: NVidia networking
Differential revision: https://reviews.freebsd.org/D48265
Diffstat (limited to 'sys/netinet/ip_output.c')
| -rw-r--r-- | sys/netinet/ip_output.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 4f5d8b7279ba..9317d5d57e1d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -667,26 +667,19 @@ again: sendit: #if defined(IPSEC) || defined(IPSEC_SUPPORT) if (IPSEC_ENABLED(ipv4)) { - struct mbuf *m1; + struct ip ip_hdr; - error = mb_unmapped_to_ext(m, &m1); - if (error != 0) { - if (error == ENOMEM) { - IPSTAT_INC(ips_odropped); - error = ENOBUFS; - goto bad; - } - /* XXXKIB */ - goto no_ipsec; - } - m = m1; if ((error = IPSEC_OUTPUT(ipv4, ifp, m, inp, mtu)) != 0) { if (error == EINPROGRESS) error = 0; goto done; } -no_ipsec:; + + /* Update variables that are affected by ipsec4_output(). */ + m_copydata(m, 0, sizeof(ip_hdr), (char *)&ip_hdr); + hlen = ip_hdr.ip_hl << 2; } + /* * Check if there was a route for this packet; return error if not. */ @@ -695,9 +688,6 @@ no_ipsec:; error = EHOSTUNREACH; goto bad; } - /* Update variables that are affected by ipsec4_output(). */ - ip = mtod(m, struct ip *); - hlen = ip->ip_hl << 2; #endif /* IPSEC */ /* Jump over all PFIL processing if hooks are not active. */ |
