Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Aug 2013 18:12:04 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r254605 - in head/sys: kern sys
Message-ID:  <201308211812.r7LIC4xv000900@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Wed Aug 21 18:12:04 2013
New Revision: 254605
URL: http://svnweb.freebsd.org/changeset/base/254605

Log:
  Revert r254520 and resurrect the M_NOFREE mbuf flag and functionality.
  
  Requested by:	np, grehan

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/uipc_mbuf.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c	Wed Aug 21 17:47:11 2013	(r254604)
+++ head/sys/kern/kern_mbuf.c	Wed Aug 21 18:12:04 2013	(r254605)
@@ -474,6 +474,7 @@ mb_dtor_mbuf(void *mem, int size, void *
 	if ((flags & MB_NOTAGS) == 0 && (m->m_flags & M_PKTHDR) != 0)
 		m_tag_delete_chain(m, NULL);
 	KASSERT((m->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__));
+	KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__));
 #ifdef INVARIANTS
 	trash_dtor(mem, size, arg);
 #endif

Modified: head/sys/kern/uipc_mbuf.c
==============================================================================
--- head/sys/kern/uipc_mbuf.c	Wed Aug 21 17:47:11 2013	(r254604)
+++ head/sys/kern/uipc_mbuf.c	Wed Aug 21 18:12:04 2013	(r254605)
@@ -278,10 +278,16 @@ m_extadd(struct mbuf *mb, caddr_t buf, u
 void
 mb_free_ext(struct mbuf *m)
 {
+	int skipmbuf;
 	
 	KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__));
 	KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__));
 
+	/*
+	 * check if the header is embedded in the cluster
+	 */
+	skipmbuf = (m->m_flags & M_NOFREE);
+
 	/* Free attached storage if this mbuf is the only reference to it. */
 	if (*(m->m_ext.ref_cnt) == 1 ||
 	    atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
@@ -322,6 +328,8 @@ mb_free_ext(struct mbuf *m)
 				("%s: unknown ext_type", __func__));
 		}
 	}
+	if (skipmbuf)
+		return;
 	
 	/*
 	 * Free this mbuf back to the mbuf zone with all m_ext
@@ -386,7 +394,7 @@ m_demote(struct mbuf *m0, int all)
 			m_freem(m->m_nextpkt);
 			m->m_nextpkt = NULL;
 		}
-		m->m_flags = m->m_flags & (M_EXT|M_RDONLY);
+		m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE);
 	}
 }
 

Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h	Wed Aug 21 17:47:11 2013	(r254604)
+++ head/sys/sys/mbuf.h	Wed Aug 21 18:12:04 2013	(r254605)
@@ -191,6 +191,7 @@ struct mbuf {
 #define	M_PROMISC	0x00000040 /* packet was not for us */
 #define	M_VLANTAG	0x00000080 /* ether_vtag is valid */
 #define	M_FLOWID	0x00000100 /* deprecated: flowid is valid */
+#define	M_NOFREE	0x00000200 /* do not free mbuf, embedded in cluster */
 
 #define	M_PROTO1	0x00001000 /* protocol-specific */
 #define	M_PROTO2	0x00002000 /* protocol-specific */
@@ -526,7 +527,7 @@ m_free(struct mbuf *m)
 
 	if (m->m_flags & M_EXT)
 		mb_free_ext(m);
-	else
+	else if ((m->m_flags & M_NOFREE) == 0)
 		uma_zfree(zone_mbuf, m);
 	return (n);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308211812.r7LIC4xv000900>