git: f8e994296328 - main - pf: remove ip(6) header argument from pf_reassemble(6)()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 27 Sep 2024 22:17:15 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8e99429632822cf22a7a0999c00a4a9db1f3702

commit f8e99429632822cf22a7a0999c00a4a9db1f3702
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-09-11 15:21:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-09-27 20:13:23 +0000

    pf: remove ip(6) header argument from pf_reassemble(6)()
    
    Instead of passing the ip header and mbuf to pf_reassemble(), lookup
    the header address in the mbuf.
    ok henning@
    
    Reviewed by:    zlei
    Obtained from:  OpenBSD, bluhm <bluhm@openbsd.org>, 074ee1f915
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D46652
---
 sys/netpfil/pf/pf_norm.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c
index c4cc482c62f0..d1a1e84db9dc 100644
--- a/sys/netpfil/pf/pf_norm.c
+++ b/sys/netpfil/pf/pf_norm.c
@@ -151,10 +151,10 @@ static struct pf_fragment *pf_fillup_fragment(struct pf_fragment_cmp *,
 		    struct pf_frent *, u_short *);
 static struct mbuf *pf_join_fragment(struct pf_fragment *);
 #ifdef INET
-static int	pf_reassemble(struct mbuf **, struct ip *, int, u_short *);
+static int	pf_reassemble(struct mbuf **, int, u_short *);
 #endif	/* INET */
 #ifdef INET6
-static int	pf_reassemble6(struct mbuf **, struct ip6_hdr *,
+static int	pf_reassemble6(struct mbuf **,
 		    struct ip6_frag *, uint16_t, uint16_t, u_short *);
 #endif	/* INET6 */
 
@@ -741,9 +741,10 @@ pf_join_fragment(struct pf_fragment *frag)
 
 #ifdef INET
 static int
-pf_reassemble(struct mbuf **m0, struct ip *ip, int dir, u_short *reason)
+pf_reassemble(struct mbuf **m0, int dir, u_short *reason)
 {
 	struct mbuf		*m = *m0;
+	struct ip		*ip = mtod(m, struct ip *);
 	struct pf_frent		*frent;
 	struct pf_fragment	*frag;
 	struct pf_fragment_cmp	key;
@@ -814,10 +815,11 @@ pf_reassemble(struct mbuf **m0, struct ip *ip, int dir, u_short *reason)
 
 #ifdef INET6
 static int
-pf_reassemble6(struct mbuf **m0, struct ip6_hdr *ip6, struct ip6_frag *fraghdr,
+pf_reassemble6(struct mbuf **m0, struct ip6_frag *fraghdr,
     uint16_t hdrlen, uint16_t extoff, u_short *reason)
 {
 	struct mbuf		*m = *m0;
+	struct ip6_hdr		*ip6 = mtod(m, struct ip6_hdr *);
 	struct pf_frent		*frent;
 	struct pf_fragment	*frag;
 	struct pf_fragment_cmp	 key;
@@ -1170,7 +1172,7 @@ pf_normalize_ip(struct mbuf **m0, struct pfi_kkif *kif, u_short *reason,
 		 * Might return a completely reassembled mbuf, or NULL */
 		PF_FRAG_LOCK();
 		DPFPRINTF(("reass frag %d @ %d-%d\n", h->ip_id, fragoff, max));
-		verdict = pf_reassemble(m0, h, pd->dir, reason);
+		verdict = pf_reassemble(m0, pd->dir, reason);
 		PF_FRAG_UNLOCK();
 
 		if (verdict != PF_PASS)
@@ -1360,7 +1362,7 @@ again:
 	off += sizeof(frag);
 
 	/* Returns PF_DROP or *m0 is NULL or completely reassembled mbuf. */
-	if (pf_reassemble6(m0, h, &frag, off, extoff, reason) != PF_PASS)
+	if (pf_reassemble6(m0, &frag, off, extoff, reason) != PF_PASS)
 		return (PF_DROP);
 	m = *m0;
 	if (m == NULL)