Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jan 2012 12:14:26 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r230265 - head/sys/contrib/pf/net
Message-ID:  <201201171214.q0HCEQm8089958@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Tue Jan 17 12:14:26 2012
New Revision: 230265
URL: http://svn.freebsd.org/changeset/base/230265

Log:
  Allocate our mbuf with m_get2().

Modified:
  head/sys/contrib/pf/net/if_pfsync.c

Modified: head/sys/contrib/pf/net/if_pfsync.c
==============================================================================
--- head/sys/contrib/pf/net/if_pfsync.c	Tue Jan 17 12:13:36 2012	(r230264)
+++ head/sys/contrib/pf/net/if_pfsync.c	Tue Jan 17 12:14:26 2012	(r230265)
@@ -2121,9 +2121,6 @@ pfsync_sendout(void)
 #ifdef notyet
 	struct tdb *t;
 #endif
-#ifdef __FreeBSD__
-	size_t pktlen;
-#endif
 	int offset;
 	int q, count = 0;
 
@@ -2145,44 +2142,33 @@ pfsync_sendout(void)
 		return;
 	}
 
-	MGETHDR(m, M_DONTWAIT, MT_DATA);
-	if (m == NULL) {
 #ifdef __FreeBSD__
+	m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
+	if (m == NULL) {
 		sc->sc_ifp->if_oerrors++;
+		V_pfsyncstats.pfsyncs_onomem++;
+		return;
+	}
 #else
+	MGETHDR(m, M_DONTWAIT, MT_DATA);
+	if (m == NULL) {
 		sc->sc_if.if_oerrors++;
-#endif
-		V_pfsyncstats.pfsyncs_onomem++;
+		pfsyncstats.pfsyncs_onomem++;
 		pfsync_drop(sc);
 		return;
 	}
 
-#ifdef __FreeBSD__
-	pktlen = max_linkhdr + sc->sc_len;
-	if (pktlen > MHLEN) {
-		/* Find the right pool to allocate from. */
-		/* XXX: This is ugly. */
-		m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES :
-#if MJUMPAGESIZE != MCLBYTES
-			pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
-#endif
-			pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
-#else
 	if (max_linkhdr + sc->sc_len > MHLEN) {
 		MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
-#endif
 		if (!ISSET(m->m_flags, M_EXT)) {
 			m_free(m);
-#ifdef __FreeBSD__
-			sc->sc_ifp->if_oerrors++;
-#else
 			sc->sc_if.if_oerrors++;
-#endif
-			V_pfsyncstats.pfsyncs_onomem++;
+			pfsyncstats.pfsyncs_onomem++;
 			pfsync_drop(sc);
 			return;
 		}
 	}
+#endif
 	m->m_data += max_linkhdr;
 	m->m_len = m->m_pkthdr.len = sc->sc_len;
 



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