svn commit: r196150 - head/sys/net

Jung-uk Kim jkim at FreeBSD.org
Wed Aug 12 17:28:54 UTC 2009


Author: jkim
Date: Wed Aug 12 17:28:53 2009
New Revision: 196150
URL: http://svn.freebsd.org/changeset/base/196150

Log:
  Always embed pointer to BPF JIT function in BPF descriptor
  to avoid inconsistency when opt_bpf.h is not included.
  
  Reviewed by:	rwatson
  Approved by:	re (rwatson)

Modified:
  head/sys/net/bpf.c
  head/sys/net/bpf_buffer.c
  head/sys/net/bpf_zerocopy.c
  head/sys/net/bpfdesc.h

Modified: head/sys/net/bpf.c
==============================================================================
--- head/sys/net/bpf.c	Wed Aug 12 16:27:51 2009	(r196149)
+++ head/sys/net/bpf.c	Wed Aug 12 17:28:53 2009	(r196150)
@@ -1585,6 +1585,9 @@ void
 bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen)
 {
 	struct bpf_d *d;
+#ifdef BPF_JITTER
+	bpf_jit_filter *bf;
+#endif
 	u_int slen;
 	int gottime;
 	struct timeval tv;
@@ -1601,8 +1604,9 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, 
 		 * the interface pointers on the mbuf to figure it out.
 		 */
 #ifdef BPF_JITTER
-		if (bpf_jitter_enable != 0 && d->bd_bfilter != NULL)
-			slen = (*(d->bd_bfilter->func))(pkt, pktlen, pktlen);
+		bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL;
+		if (bf != NULL)
+			slen = (*(bf->func))(pkt, pktlen, pktlen);
 		else
 #endif
 		slen = bpf_filter(d->bd_rfilter, pkt, pktlen, pktlen);
@@ -1634,6 +1638,9 @@ void
 bpf_mtap(struct bpf_if *bp, struct mbuf *m)
 {
 	struct bpf_d *d;
+#ifdef BPF_JITTER
+	bpf_jit_filter *bf;
+#endif
 	u_int pktlen, slen;
 	int gottime;
 	struct timeval tv;
@@ -1655,11 +1662,10 @@ bpf_mtap(struct bpf_if *bp, struct mbuf 
 		BPFD_LOCK(d);
 		++d->bd_rcount;
 #ifdef BPF_JITTER
+		bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL;
 		/* XXX We cannot handle multiple mbufs. */
-		if (bpf_jitter_enable != 0 && d->bd_bfilter != NULL &&
-		    m->m_next == NULL)
-			slen = (*(d->bd_bfilter->func))(mtod(m, u_char *),
-			    pktlen, pktlen);
+		if (bf != NULL && m->m_next == NULL)
+			slen = (*(bf->func))(mtod(m, u_char *), pktlen, pktlen);
 		else
 #endif
 		slen = bpf_filter(d->bd_rfilter, (u_char *)m, pktlen, 0);

Modified: head/sys/net/bpf_buffer.c
==============================================================================
--- head/sys/net/bpf_buffer.c	Wed Aug 12 16:27:51 2009	(r196149)
+++ head/sys/net/bpf_buffer.c	Wed Aug 12 17:28:53 2009	(r196150)
@@ -77,7 +77,6 @@ __FBSDID("$FreeBSD$");
 #include <net/if.h>
 #include <net/bpf.h>
 #include <net/bpf_buffer.h>
-#include <net/bpf_jitter.h>
 #include <net/bpfdesc.h>
 
 /*

Modified: head/sys/net/bpf_zerocopy.c
==============================================================================
--- head/sys/net/bpf_zerocopy.c	Wed Aug 12 16:27:51 2009	(r196149)
+++ head/sys/net/bpf_zerocopy.c	Wed Aug 12 17:28:53 2009	(r196150)
@@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
 
 #include <net/if.h>
 #include <net/bpf.h>
-#include <net/bpf_jitter.h>
 #include <net/bpf_zerocopy.h>
 #include <net/bpfdesc.h>
 

Modified: head/sys/net/bpfdesc.h
==============================================================================
--- head/sys/net/bpfdesc.h	Wed Aug 12 16:27:51 2009	(r196149)
+++ head/sys/net/bpfdesc.h	Wed Aug 12 17:28:53 2009	(r196150)
@@ -72,9 +72,7 @@ struct bpf_d {
 	u_long		bd_rtout;	/* Read timeout in 'ticks' */
 	struct bpf_insn *bd_rfilter; 	/* read filter code */
 	struct bpf_insn *bd_wfilter;	/* write filter code */
-#ifdef BPF_JITTER
-	bpf_jit_filter	*bd_bfilter;	/* binary filter code */
-#endif
+	void		*bd_bfilter;	/* binary filter code */
 	u_int64_t	bd_rcount;	/* number of packets received */
 	u_int64_t	bd_dcount;	/* number of packets dropped */
 


More information about the svn-src-all mailing list