diff options
| author | Bruce M Simpson <bms@FreeBSD.org> | 2026-07-30 16:08:34 +0000 |
|---|---|---|
| committer | Bruce M Simpson <bms@FreeBSD.org> | 2026-08-03 11:27:45 +0000 |
| commit | b451bdb7894dea69f74dd641861f800ac2268f5c (patch) | |
| tree | 422afa8692aac6029398e1a88415c8e640a41ce4 | |
| parent | 4a59a0cf99bb9a48ccea62e9499186e892cf51bc (diff) | |
netipsec: Refactor TCP-MD5 shim to use ip6_hdr_pseudo{} for brevity.
This brings xform_tcp.c into line with possible future OCF related imports.
| -rw-r--r-- | sys/netipsec/xform_tcp.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sys/netipsec/xform_tcp.c b/sys/netipsec/xform_tcp.c index a87b27048dd7..f2e8f4975e35 100644 --- a/sys/netipsec/xform_tcp.c +++ b/sys/netipsec/xform_tcp.c @@ -63,6 +63,7 @@ #ifdef INET6 #include <netinet/ip6.h> +#include <netinet6/ip6_var.h> #include <netipsec/ipsec6.h> #endif @@ -154,25 +155,23 @@ ip_pseudo_compute(struct mbuf *m, MD5_CTX *ctx) static int ip6_pseudo_compute(struct mbuf *m, MD5_CTX *ctx) { - struct ip6_pseudo { - struct in6_addr src, dst; - uint32_t len; - uint32_t nxt; - } ip6p __aligned(4); + struct ip6_hdr_pseudo ip6ph = { + .ip6ph_zero = {} + }; struct ip6_hdr *ip6; int hdr_len; ip6 = mtod(m, struct ip6_hdr *); - ip6p.src = ip6->ip6_src; - ip6p.dst = ip6->ip6_dst; + ip6ph.ip6ph_src = ip6->ip6_src; + ip6ph.ip6ph_dst = ip6->ip6_dst; hdr_len = sizeof(struct ip6_hdr); if (ip6->ip6_nxt == IPPROTO_UDP) /* TCP over UDP */ hdr_len += sizeof(struct udphdr); - /* XXX: ext headers */ - ip6p.len = htonl(m->m_pkthdr.len - hdr_len); - ip6p.nxt = htonl(IPPROTO_TCP); - MD5Update(ctx, (char *)&ip6p, sizeof(ip6p)); + /* Append TCP segment and fixup length. */ + ip6ph.ip6ph_len = htonl(m->m_pkthdr.len - hdr_len); + ip6ph.ip6ph_nxt = IPPROTO_TCP; + MD5Update(ctx, &ip6ph, sizeof(ip6ph)); return (hdr_len); } #endif |
