PERFORCE change 66080 for review

Sam Leffler sam at FreeBSD.org
Mon Nov 29 17:12:48 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=66080

Change 66080 by sam at sam_ebb on 2004/11/30 01:12:35

	save mbuf guard word hack

Affected files ...

.. //depot/projects/wifi/sys/conf/options#5 edit
.. //depot/projects/wifi/sys/kern/kern_mbuf.c#2 edit
.. //depot/projects/wifi/sys/sys/mbuf.h#3 edit

Differences ...

==== //depot/projects/wifi/sys/conf/options#5 (text+ko) ====

@@ -491,6 +491,7 @@
 INVARIANT_SUPPORT	opt_global.h
 INVARIANTS		opt_global.h
 LOOKUP_SHARED		opt_global.h
+MBUF_GUARD		opt_global.h
 MCLSHIFT		opt_global.h
 MUTEX_DEBUG		opt_global.h
 MUTEX_NOINLINE		opt_global.h

==== //depot/projects/wifi/sys/kern/kern_mbuf.c#2 (text+ko) ====

@@ -216,6 +216,9 @@
 #endif
 	} else
 		m->m_data = m->m_dat;
+#ifdef MBUF_GUARD
+	*(uint32_t *)(m+1) = MBUF_GUARDWORD;
+#endif
 	mbstat.m_mbufs += 1;	/* XXX */
 	return (0);
 }
@@ -229,6 +232,7 @@
 	struct mbuf *m;
 
 	m = (struct mbuf *)mem;
+	MBUF_GUARDCHECK(m);
 	if ((m->m_flags & M_PKTHDR) != 0)
 		m_tag_delete_chain(m, NULL);
 	mbstat.m_mbufs -= 1;	/* XXX */
@@ -241,6 +245,7 @@
 	struct mbuf *m;
 
 	m = (struct mbuf *)mem;
+	MBUF_GUARDCHECK(m);
 	if ((m->m_flags & M_PKTHDR) != 0)
 		m_tag_delete_chain(m, NULL);
 	mbstat.m_mbufs -= 1;	/* XXX */
@@ -354,6 +359,9 @@
 			return (error);
 #endif
 	}
+#ifdef MBUF_GUARD
+	*(uint32_t *)(m+1) = MBUF_GUARDWORD;
+#endif
 	mbstat.m_mbufs += 1;	/* XXX */
 	mbstat.m_mclusts += 1;	/* XXX */
 	return (0);

==== //depot/projects/wifi/sys/sys/mbuf.h#3 (text+ko) ====

@@ -52,7 +52,16 @@
  * to allocate a separate buffer externally and attach it to the mbuf in
  * a way similar to that of mbuf clusters.
  */
+#ifdef MBUF_GUARD
+#define	MLEN		(MSIZE - sizeof(struct m_hdr) - sizeof(uint32_t))
+#define	MBUF_GUARDWORD	0x99118822
+#define	MBUF_GUARDCHECK(m) do { \
+	KASSERT(*(uint32_t *)(m+1) == MBUF_GUARDWORD, \
+		("mbuf guardword clobbered, found 0x%x", *(uint32_t *)(m+1))); \
+} while (0)
+#else
 #define	MLEN		(MSIZE - sizeof(struct m_hdr))	/* normal data len */
+#endif
 #define	MHLEN		(MLEN - sizeof(struct pkthdr))	/* data len w/pkthdr */
 #define	MINCLSIZE	(MHLEN + 1)	/* smallest amount to put in cluster */
 #define	M_MAXCOMPRESS	(MHLEN / 2)	/* max amount to copy for compression */


More information about the p4-projects mailing list