aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorChristian S.J. Peron <csjp@FreeBSD.org>2006-06-14 02:23:28 +0000
committerChristian S.J. Peron <csjp@FreeBSD.org>2006-06-14 02:23:28 +0000
commit7eae78a419914180f3c8bc84ecfb3a9910db784c (patch)
tree0e937f42c91cb08b5e5df6051c34c3f31da3c95c /sys/net
parent415e46824c11d12b955c0442e050387759cb2c2a (diff)
downloadsrc-7eae78a419914180f3c8bc84ecfb3a9910db784c.tar.gz
src-7eae78a419914180f3c8bc84ecfb3a9910db784c.zip
If bpf(4) has not been compiled into the kernel, initialize the bpf interface
pointer to a zeroed, statically allocated bpf_if structure. This way the LIST_EMPTY() macro will always return true. This allows us to remove the additional unconditional memory reference for each packet in the fast path. Discussed with: sam
Notes
Notes: svn path=/head/; revision=159595
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c5
-rw-r--r--sys/net/bpf.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 00a95c8ca622..532dc96e410a 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1790,6 +1790,7 @@ SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,bpf_drvinit,NULL)
* A 'better' implementation would allow the core bpf functionality
* to be loaded at runtime.
*/
+static struct bpf_if bp_null;
void
bpf_tap(bp, pkt, pktlen)
@@ -1820,6 +1821,8 @@ bpfattach(ifp, dlt, hdrlen)
struct ifnet *ifp;
u_int dlt, hdrlen;
{
+
+ bpfattach2(ifp, dlt, hdrlen, &ifp->if_bpf);
}
void
@@ -1828,6 +1831,8 @@ bpfattach2(ifp, dlt, hdrlen, driverp)
u_int dlt, hdrlen;
struct bpf_if **driverp;
{
+
+ *driverp = &bp_null;
}
void
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 0782a66f56ae..487784aa7e75 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -630,7 +630,7 @@ static __inline int
bpf_peers_present(struct bpf_if *bpf)
{
- if (bpf && !LIST_EMPTY(&bpf->bif_dlist))
+ if (!LIST_EMPTY(&bpf->bif_dlist))
return (1);
return (0);
}