summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf_jitter.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-11-20 18:49:20 +0000
committerjkim <jkim@FreeBSD.org>2009-11-20 18:49:20 +0000
commit052bc52af74a5ae4eb6c288f7377bef9d10902cf (patch)
treebe30a4b8f4550e5c133425f045691a115092525c /sys/net/bpf_jitter.c
parentca5edf0fbf82952a5abaa900be8d00c8562ca803 (diff)
downloadFreeBSD-src-052bc52af74a5ae4eb6c288f7377bef9d10902cf.zip
FreeBSD-src-052bc52af74a5ae4eb6c288f7377bef9d10902cf.tar.gz
- Allocate scratch memory on stack instead of pre-allocating it with
the filter as we do from bpf_filter()[1]. - Revert experimental use of contigmalloc(9)/contigfree(9). It has no performance benefit over malloc(9)/free(9)[2]. Requested by: rwatson[1] Pointed out by: rwatson, jhb, alc[2]
Diffstat (limited to 'sys/net/bpf_jitter.c')
-rw-r--r--sys/net/bpf_jitter.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/net/bpf_jitter.c b/sys/net/bpf_jitter.c
index 112b873..a72d2d4 100644
--- a/sys/net/bpf_jitter.c
+++ b/sys/net/bpf_jitter.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/bpf_jitter.h>
-bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, size_t *, int *);
+bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, size_t *);
static u_int bpf_jit_accept_all(u_char *, u_int, u_int);
@@ -70,7 +70,7 @@ bpf_jitter(struct bpf_insn *fp, int nins)
/* Allocate the filter structure */
filter = (struct bpf_jit_filter *)malloc(sizeof(*filter),
- M_BPFJIT, M_NOWAIT | M_ZERO);
+ M_BPFJIT, M_NOWAIT);
if (filter == NULL)
return (NULL);
@@ -81,8 +81,7 @@ bpf_jitter(struct bpf_insn *fp, int nins)
}
/* Create the binary */
- if ((filter->func = bpf_jit_compile(fp, nins, &filter->size,
- filter->mem)) == NULL) {
+ if ((filter->func = bpf_jit_compile(fp, nins, &filter->size)) == NULL) {
free(filter, M_BPFJIT);
return (NULL);
}
@@ -95,7 +94,7 @@ bpf_destroy_jit_filter(bpf_jit_filter *filter)
{
if (filter->func != bpf_jit_accept_all)
- contigfree(filter->func, filter->size, M_BPFJIT);
+ free(filter->func, M_BPFJIT);
free(filter, M_BPFJIT);
}
#else
@@ -108,7 +107,6 @@ bpf_jitter(struct bpf_insn *fp, int nins)
filter = (struct bpf_jit_filter *)malloc(sizeof(*filter));
if (filter == NULL)
return (NULL);
- memset(filter, 0, sizeof(*filter));
/* No filter means accept all */
if (fp == NULL || nins == 0) {
@@ -117,8 +115,7 @@ bpf_jitter(struct bpf_insn *fp, int nins)
}
/* Create the binary */
- if ((filter->func = bpf_jit_compile(fp, nins, &filter->size,
- filter->mem)) == NULL) {
+ if ((filter->func = bpf_jit_compile(fp, nins, &filter->size)) == NULL) {
free(filter);
return (NULL);
}
OpenPOWER on IntegriCloud