diff options
author | Kristof Provost <kp@FreeBSD.org> | 2024-11-21 14:53:28 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2024-12-17 10:07:16 +0000 |
commit | 6c5c91a039c77244dac38f638a8e2323ae78ff3d (patch) | |
tree | 18ff4c656139739908dec746128c2330ce98225b | |
parent | b717c67686c090ee0f0034dc33a860f23c10f7fe (diff) |
pf: update pd->tot_len after reassembly
Ensure that the packet length we track in struct pf_pdesc matches the
reassembled packet size.
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D47803
-rw-r--r-- | sys/netpfil/pf/pf_norm.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 350392623123..cea6f9e72638 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1198,6 +1198,7 @@ pf_normalize_ip(struct mbuf **m0, u_short *reason, return (PF_DROP); h = mtod(pd->m, struct ip *); + pd->tot_len = htons(h->ip_len); no_fragment: /* At this point, only IP_DF is allowed in ip_off */ @@ -1228,6 +1229,7 @@ pf_normalize_ip6(struct mbuf **m0, int off, u_short *reason, struct pf_pdesc *pd) { struct pf_krule *r; + struct ip6_hdr *h; struct ip6_frag frag; bool scrub_compat; @@ -1294,6 +1296,8 @@ pf_normalize_ip6(struct mbuf **m0, int off, u_short *reason, pd->m = *m0; if (pd->m == NULL) return (PF_DROP); + h = mtod(pd->m, struct ip6_hdr *); + pd->tot_len = ntohs(h->ip6_plen) + sizeof(struct ip6_hdr); } return (PF_PASS); |