summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2012-01-03 17:06:39 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2012-01-03 17:06:39 +0000
commite39023b406cea442edbed144144f59e7e6e879c3 (patch)
tree9547ff5d69a6ef13260a53ffe365c07ce38d7cfe
parent43bbcca3be0f96f983125b85cd0c7a4637f864e1 (diff)
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@
-rw-r--r--sys/net/pf_norm.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/sys/net/pf_norm.c b/sys/net/pf_norm.c
index 30b2d69b1cb..0391e82dce5 100644
--- a/sys/net/pf_norm.c
+++ b/sys/net/pf_norm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_norm.c,v 1.147 2011/11/25 12:52:10 dlg Exp $ */
+/* $OpenBSD: pf_norm.c,v 1.148 2012/01/03 17:06:38 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -115,7 +115,6 @@ RB_PROTOTYPE(pf_frag_tree, pf_fragment, fr_entry, pf_frag_compare);
RB_GENERATE(pf_frag_tree, pf_fragment, fr_entry, pf_frag_compare);
/* Private prototypes */
-void pf_remove_fragment(struct pf_fragment *);
void pf_flush_fragments(void);
void pf_free_fragment(struct pf_fragment *);
struct pf_fragment *pf_find_fragment(struct pf_fragment_cmp *,
@@ -207,16 +206,20 @@ 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.
+ */
void
pf_free_fragment(struct pf_fragment *frag)
{
struct pf_frent *frent;
- /* Free all fragments */
- for (frent = TAILQ_FIRST(&frag->fr_queue); frent;
- frent = TAILQ_FIRST(&frag->fr_queue)) {
+ RB_REMOVE(pf_frag_tree, &pf_frag_tree, frag);
+ TAILQ_REMOVE(&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);
@@ -224,7 +227,7 @@ pf_free_fragment(struct pf_fragment *frag)
pf_nfrents--;
}
- pf_remove_fragment(frag);
+ pool_put(&pf_frag_pl, frag);
}
struct pf_fragment *
@@ -243,16 +246,6 @@ pf_find_fragment(struct pf_fragment_cmp *key, struct pf_frag_tree *tree)
return (frag);
}
-/* Removes a fragment from the fragment queue and frees the fragment */
-
-void
-pf_remove_fragment(struct pf_fragment *frag)
-{
- RB_REMOVE(pf_frag_tree, &pf_frag_tree, frag);
- TAILQ_REMOVE(&pf_fragqueue, frag, frag_next);
- pool_put(&pf_frag_pl, frag);
-}
-
struct pf_frent *
pf_create_fragment(u_short *reason)
{
@@ -395,8 +388,9 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent,
/* This fragment is completely overlapped, lose it */
next = TAILQ_NEXT(after, fr_next);
- m_freem(after->fe_m);
TAILQ_REMOVE(&frag->fr_queue, after, fr_next);
+
+ m_freem(after->fe_m);
pool_put(&pf_frent_pl, after);
pf_nfrents--;
}
@@ -455,10 +449,10 @@ 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);
/* Magic from ip_input */
m = frent->fe_m;
@@ -467,8 +461,9 @@ pf_join_fragment(struct pf_fragment *frag)
m_cat(m, m2);
pool_put(&pf_frent_pl, frent);
pf_nfrents--;
- 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 */
@@ -479,7 +474,7 @@ pf_join_fragment(struct pf_fragment *frag)
}
/* Remove from fragment queue */
- pf_remove_fragment(frag);
+ pf_free_fragment(frag);
return (m);
}