Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jul 2010 11:27:33 +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: r209845 - head/sys/netinet/ipfw
Message-ID:  <201007091127.o69BRXL7019928@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Fri Jul  9 11:27:33 2010
New Revision: 209845
URL: http://svn.freebsd.org/changeset/base/209845

Log:
  Improve last commit: use bpf_mtap2() to avoiding stack usage.
  
  Prodded by:	julian

Modified:
  head/sys/netinet/ipfw/ip_fw_log.c

Modified: head/sys/netinet/ipfw/ip_fw_log.c
==============================================================================
--- head/sys/netinet/ipfw/ip_fw_log.c	Fri Jul  9 10:57:55 2010	(r209844)
+++ head/sys/netinet/ipfw/ip_fw_log.c	Fri Jul  9 11:27:33 2010	(r209845)
@@ -152,24 +152,17 @@ ipfw_log(struct ip_fw *f, u_int hlen, st
 
 	if (V_fw_verbose == 0) {
 #ifndef WITHOUT_BPF
-		struct mbuf m0;
 
 		if (log_if == NULL || log_if->if_bpf == NULL)
 			return;
 
-		/* BPF treats the "mbuf" as read-only */
-		bzero(&m0, sizeof(struct mbuf));
-		m0.m_hdr.mh_next = m;
-		m0.m_hdr.mh_len = ETHER_HDR_LEN;
-		if (args->eh) { /* layer2, use orig hdr */
-			m0.m_hdr.mh_data = (char *)args->eh;
-		} else {
-			/* add fake header. Later we will store
-			 * more info in the header
+		if (args->eh) /* layer2, use orig hdr */
+			BPF_MTAP2(log_if, args->eh, ETHER_HDR_LEN, m);
+		else
+			/* Add fake header. Later we will store
+			 * more info in the header.
 			 */
-			m0.m_hdr.mh_data = "DDDDDDSSSSSS\x08\x00";
-		}
-		BPF_MTAP(log_if, &m0);
+			BPF_MTAP2(log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m);
 #endif /* !WITHOUT_BPF */
 		return;
 	}



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