From eef3abf99143fa19c5abedb6940f599a656d5135 Mon Sep 17 00:00:00 2001
From: marta <marta@8c455092-636d-4788-adf5-e71def0336e8>
Date: Thu, 23 Jul 2009 00:26:19 +0000
Subject: [PATCH] Free mtags for dummynet mbuf. Enable the deallocation code in
 m_freem().

---
 dummynet/include/sys/mbuf.h | 7 ++++---
 dummynet/ipfw2_mod.c        | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/dummynet/include/sys/mbuf.h b/dummynet/include/sys/mbuf.h
index e4e7591..a7f95a1 100644
--- a/dummynet/include/sys/mbuf.h
+++ b/dummynet/include/sys/mbuf.h
@@ -143,15 +143,16 @@ m_tag_locate(struct mbuf *m, u_int32_t n, int x, struct m_tag *t)
 static __inline void
 m_freem(struct mbuf *m)
 {
-#if 0
 	struct m_tag *t;
 
+	/* free the m_tag chain */
 	while ( (t = SLIST_FIRST(&m->m_pkthdr.tags) ) ) {
 		SLIST_REMOVE_HEAD(&m->m_pkthdr.tags, m_tag_link);
 		free(t, 0);
 	}
-#endif
-	free(m, 0);
+
+	/* free the mbuf */
+	free(m, M_IPFW);
 };
 
 /* we cannot pullup */
diff --git a/dummynet/ipfw2_mod.c b/dummynet/ipfw2_mod.c
index ff5a92f..0da1904 100644
--- a/dummynet/ipfw2_mod.c
+++ b/dummynet/ipfw2_mod.c
@@ -348,7 +348,7 @@ ipfw2_queue_handler(QH_ARGS)
 
 	if (m != NULL) {	/* Accept. reinject and free the mbuf */
 		REINJECT(info, NF_STOP);
-		free(m, M_IPFW);
+		m_freem(m);
 	} else if (ret == 0) {
 		/* dummynet has kept the packet, will reinject later. */
 	} else {
@@ -377,7 +377,7 @@ netisr_dispatch(int num, struct mbuf *m)
 	struct nf_queue_entry *info = m->queue_entry;
 	struct sk_buff *skb = m->m_skb;	/* always used */
 
-	free(m, M_IPFW);
+	m_freem(m);
 	KASSERT((info != NULL), ("%s info null!\n", __FUNCTION__));
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)	// XXX above 2.6.x ?
 	__net_timestamp(skb);	/* update timestamp */
-- 
2.47.0