Use sys/net/bpf_jitter.c instead of rolling our own version

since it is compilable on user land now.
This commit is contained in:
Jung-uk Kim 2008-08-25 22:45:18 +00:00
parent f7402f1a67
commit 71d7a7dd88
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182182
2 changed files with 7 additions and 10 deletions

View File

@ -35,7 +35,8 @@ CFLAGS+= -DBPF_VALIDATE
.endif
.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386") && defined(BPF_JIT)
SRCS+= ${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c
SRCS+= ${SYSDIR}/net/bpf_jitter.c \
${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c
CFLAGS+= -I${SYSDIR} -DBPF_JIT_COMPILER
WARNS?= 6
.else

View File

@ -51,24 +51,20 @@ static int verbose = LOG_LEVEL;
#ifdef BPF_JIT_COMPILER
#include <string.h>
#include <net/bpf_jitter.h>
bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, int *);
static u_int
bpf_compile_and_filter(void)
{
bpf_jit_filter filter;
bpf_jit_filter *filter;
u_int ret;
/* Do not use BPF JIT compiler for an empty program */
if (nins == 0)
return (0);
/* Create the binary */
if ((filter.func = bpf_jit_compile(pc, nins, filter.mem)) == NULL) {
/* Compile the BPF filter program and generate native code. */
if ((filter = bpf_jitter(pc, nins)) == NULL) {
if (verbose > 1)
printf("Failed to allocate memory:\t");
if (verbose > 0)
@ -76,9 +72,9 @@ bpf_compile_and_filter(void)
exit(FATAL);
}
ret = (*(filter.func))(pkt, wirelen, buflen);
ret = (*(filter->func))(pkt, wirelen, buflen);
free(filter.func);
bpf_destroy_jit_filter(filter);
return (ret);
}