git: 481374d5f7b0 - main - pf: remove pf_remove_fragment()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Jan 2025 10:37:52 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=481374d5f7b056cd6fbf344238beb70fdae1eabe commit 481374d5f7b056cd6fbf344238beb70fdae1eabe Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-01-07 14:46:05 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-01-14 08:54:18 +0000 pf: remove pf_remove_fragment() Instead of having two functions pf_free_fragment() and pf_remove_fragment() doing more or less the same, merge them into one. Just remove fragment entries from the queue in pf_join_fragment() before they are freed. Then pf_remove_fragment() is not needed anymore. ok henning@ Obtained from: OpenBSD, bluhm <bluhm@openbsd.org>, dc8c96a470 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_norm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 4adace4c92cf..5b34e825203b 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -130,7 +130,6 @@ static RB_GENERATE(pf_frag_tree, pf_fragment, fr_entry, pf_frag_compare); static void pf_flush_fragments(void); static void pf_free_fragment(struct pf_fragment *); -static void pf_remove_fragment(struct pf_fragment *); static struct pf_frent *pf_create_fragment(u_short *); static int pf_frent_holes(struct pf_frent *frent); @@ -273,7 +272,10 @@ pf_flush_fragments(void) } } -/* Frees the fragments and all associated entries */ +/* + * Remove a fragment from the fragment queue, free its fragment entries, + * and free the fragment itself. + */ static void pf_free_fragment(struct pf_fragment *frag) { @@ -281,16 +283,18 @@ pf_free_fragment(struct pf_fragment *frag) PF_FRAG_ASSERT(); - /* Free all fragments */ - for (frent = TAILQ_FIRST(&frag->fr_queue); frent; - frent = TAILQ_FIRST(&frag->fr_queue)) { + RB_REMOVE(pf_frag_tree, &V_pf_frag_tree, frag); + TAILQ_REMOVE(&V_pf_fragqueue, frag, frag_next); + + /* Free all fragment entries */ + while ((frent = TAILQ_FIRST(&frag->fr_queue)) != NULL) { TAILQ_REMOVE(&frag->fr_queue, frent, fr_next); m_freem(frent->fe_m); uma_zfree(V_pf_frent_z, frent); } - pf_remove_fragment(frag); + uma_zfree(V_pf_frag_z, frag); } static struct pf_fragment * @@ -708,16 +712,16 @@ static struct mbuf * pf_join_fragment(struct pf_fragment *frag) { struct mbuf *m, *m2; - struct pf_frent *frent, *next; + struct pf_frent *frent; frent = TAILQ_FIRST(&frag->fr_queue); - next = TAILQ_NEXT(frent, fr_next); + TAILQ_REMOVE(&frag->fr_queue, frent, fr_next); m = frent->fe_m; m_adj(m, (frent->fe_hdrlen + frent->fe_len) - m->m_pkthdr.len); uma_zfree(V_pf_frent_z, frent); - for (frent = next; frent != NULL; frent = next) { - next = TAILQ_NEXT(frent, fr_next); + while ((frent = TAILQ_FIRST(&frag->fr_queue)) != NULL) { + TAILQ_REMOVE(&frag->fr_queue, frent, fr_next); m2 = frent->fe_m; /* Strip off ip header. */ @@ -730,7 +734,7 @@ pf_join_fragment(struct pf_fragment *frag) } /* Remove from fragment queue. */ - pf_remove_fragment(frag); + pf_free_fragment(frag); return (m); }