From 5bb5f2c942a2bd6d39a1129427c56dc9a2221832 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 29 Jan 2001 13:26:14 +0000 Subject: [PATCH] Supply a stub bpf_validate() (always returning false - the script is not valid) if BPF is missing. The netgraph_bpf node forced bpf to be present, reflect that in the options. Stop doing a 'count bpf' - we provide stubs. Since a handful of drivers still refer to "bpf.h", provide a more accurate indication that the API is present always. (eg: netinet6) --- sys/conf/files | 5 ++++- sys/conf/options | 1 + sys/net/bpf.c | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index a149f111769c..08ba66878ef1 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -779,7 +779,10 @@ msdosfs/msdosfs_lookup.c optional msdosfs msdosfs/msdosfs_vfsops.c optional msdosfs msdosfs/msdosfs_vnops.c optional msdosfs net/bpf.c standard -net/bpf_filter.c count bpf +net/bpf_filter.c optional bpf +bpf.h standard \ + compile-with "echo '#define NBPF 1' > bpf.h" \ + no-obj no-implicit-rule before-depend net/bridge.c optional bridge net/bsd_comp.c optional ppp_bsdcomp #net/hostcache.c standard diff --git a/sys/conf/options b/sys/conf/options index 1d682e731232..717a841ac2d0 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -493,3 +493,4 @@ NDEVFSOVERFLOW opt_devfs.h # various 'device presence' options. DEV_SNP opt_snp.h DEV_MCA opt_mca.h +DEV_BPF opt_bpf.h diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 6487a8257a7f..23956f7a109a 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -40,7 +40,8 @@ * $FreeBSD$ */ -#include "bpf.h" +#include "opt_bpf.h" +#include "opt_netgraph.h" #ifndef __GNUC__ #define inline @@ -80,7 +81,7 @@ static MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); -#if NBPF > 0 +#if defined(DEV_BPF) || defined(NETGRAPH_BPF) /* * Older BSDs don't have kernel malloc. @@ -1396,7 +1397,7 @@ bpf_drvinit(unused) SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL) -#else /* !BPF */ +#else /* !DEV_BPF && !NETGRAPH_BPF */ /* * NOP stubs to allow bpf-using drivers to load and function. * @@ -1442,4 +1443,12 @@ bpf_filter(pc, p, wirelen, buflen) return -1; /* "no filter" behaviour */ } -#endif /* !BPF */ +int +bpf_validate(f, len) + const struct bpf_insn *f; + int len; +{ + return 0; /* false */ +} + +#endif /* !DEV_BPF && !NETGRAPH_BPF */