From ae853b3a1196502c15e20f1ae8a138a8b83c9597 Mon Sep 17 00:00:00 2001 From: msmith Date: Wed, 28 Apr 1999 01:18:13 +0000 Subject: Allow loadable interface drivers with BPF support to be loaded into a kernel that doesn't have it. This is achieved by having minimal do-nothing stubs enabled when there are no bpfilter devices configured. Driver modules should be built with BPF enabled for maximum convenience (but can be built without it for maximum performance). --- sys/conf/files | 2 +- sys/modules/if_disc/Makefile | 4 ++-- sys/modules/if_ppp/Makefile | 4 ++-- sys/modules/if_sl/Makefile | 4 ++-- sys/modules/if_tun/Makefile | 4 ++-- sys/net/bpf.c | 45 +++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 51 insertions(+), 12 deletions(-) (limited to 'sys') diff --git a/sys/conf/files b/sys/conf/files index 7e427c1..bbf2f6a 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -387,7 +387,7 @@ ntfs/ntfs_vnops.c optional ntfs ntfs/ntfs_subr.c optional ntfs ntfs/ntfs_compr.c optional ntfs ntfs/ntfs_ihash.c optional ntfs -net/bpf.c optional bpfilter +net/bpf.c standard net/bpf_filter.c optional bpfilter net/bridge.c optional bridge net/bsd_comp.c optional ppp_bsdcomp diff --git a/sys/modules/if_disc/Makefile b/sys/modules/if_disc/Makefile index b95b478..a2f5323 100644 --- a/sys/modules/if_disc/Makefile +++ b/sys/modules/if_disc/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile,v 1.5 1998/02/01 18:12:13 bde Exp $ +# $Id: Makefile,v 1.6 1998/10/16 04:30:44 peter Exp $ .PATH: ${.CURDIR}/../../net KMOD= if_disc SRCS= if_disc.c bpfilter.h opt_inet.h NOMAN= -NBPFILTER?= 0 +NBPFILTER?= 1 CFLAGS+= ${PROTOS} CLEANFILES+= bpfilter.h opt_inet.h diff --git a/sys/modules/if_ppp/Makefile b/sys/modules/if_ppp/Makefile index 97c3b3c..6be6fdb 100644 --- a/sys/modules/if_ppp/Makefile +++ b/sys/modules/if_ppp/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.15 1998/10/16 04:30:44 peter Exp $ +# $Id: Makefile,v 1.16 1999/01/17 20:53:48 peter Exp $ .PATH: ${.CURDIR}/../../net KMOD= if_ppp @@ -10,7 +10,7 @@ CLEANFILES+= vnode_if.c vnode_if.h NPPP?= 2 PPP_BSDCOMP?= 1 # 0/1 PPP_DEFLATE?= 1 # 0/1 -PPP_FILTER?= 0 # 0/1 - requires bpf to be configured in kernel +PPP_FILTER?= 1 # 0/1 - requires bpf to be configured in kernel PPP_INET?= 1 # 0/1 - requires INET to be configured in kernel PPP_IPX?= 0 # 0/1 - requires IPX to be configured in kernel diff --git a/sys/modules/if_sl/Makefile b/sys/modules/if_sl/Makefile index 6d14477..9ce708a 100644 --- a/sys/modules/if_sl/Makefile +++ b/sys/modules/if_sl/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile,v 1.6 1998/02/01 18:12:14 bde Exp $ +# $Id: Makefile,v 1.7 1998/10/16 04:30:45 peter Exp $ .PATH: ${.CURDIR}/../../net KMOD= if_sl SRCS= if_sl.c slcompress.c bpfilter.h opt_inet.h sl.h NOMAN= -NBPFILTER?= 0 +NBPFILTER?= 1 NSL?= 2 PROTOS?= -DINET diff --git a/sys/modules/if_tun/Makefile b/sys/modules/if_tun/Makefile index 7fadb7f..1f33fe2 100644 --- a/sys/modules/if_tun/Makefile +++ b/sys/modules/if_tun/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.7 1998/10/16 04:30:45 peter Exp $ +# $Id: Makefile,v 1.8 1999/01/17 20:53:47 peter Exp $ .PATH: ${.CURDIR}/../../net KMOD= if_tun @@ -6,7 +6,7 @@ SRCS= if_tun.c bpfilter.h opt_devfs.h opt_inet.h tun.h vnode_if.h NOMAN= CLEANFILES+= vnode_if.h vnode_if.c -NBPFILTER?= 0 +NBPFILTER?= 1 NTUN?= 2 CFLAGS+= ${PROTOS} diff --git a/sys/net/bpf.c b/sys/net/bpf.c index a49ac6d..0c37a7a 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -37,13 +37,11 @@ * * @(#)bpf.c 8.2 (Berkeley) 3/28/94 * - * $Id: bpf.c,v 1.46 1998/12/07 21:58:36 archie Exp $ + * $Id: bpf.c,v 1.47 1999/01/27 22:42:13 dillon Exp $ */ #include "bpfilter.h" -#if NBPFILTER > 0 - #ifndef __GNUC__ #define inline #else @@ -86,6 +84,7 @@ #include #endif /*DEVFS*/ +#if NBPFILTER > 0 /* * Older BSDs don't have kernel malloc. @@ -1309,4 +1308,44 @@ bpf_drvinit(unused) SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL) +#else /* !BPFILTER */ +/* + * NOP stubs to allow bpf-using drivers to load and function. + * + * A 'better' implementation would allow the core bpf functionality + * to be loaded at runtime. + */ + +void +bpf_tap(ifp, pkt, pktlen) + struct ifnet *ifp; + register u_char *pkt; + register u_int pktlen; +{ +} + +void +bpf_mtap(ifp, m) + struct ifnet *ifp; + struct mbuf *m; +{ +} + +void +bpfattach(ifp, dlt, hdrlen) + struct ifnet *ifp; + u_int dlt, hdrlen; +{ +} + +u_int +bpf_filter(pc, p, wirelen, buflen) + register struct bpf_insn *pc; + register u_char *p; + u_int wirelen; + register u_int buflen; +{ + return -1; /* "no filter" behaviour */ +} + #endif -- cgit v1.1