diff options
author | jkim <jkim@FreeBSD.org> | 2009-11-18 23:40:19 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2009-11-18 23:40:19 +0000 |
commit | 8e75a7257b6388ab8a5e0e06409511e0d964a863 (patch) | |
tree | b9804425527a596e571e08317ca60dd1863d5347 /sys/net/bpf_jitter.c | |
parent | efc247aeb32656ef1e27f5c3451d1fa4b1408294 (diff) | |
download | FreeBSD-src-8e75a7257b6388ab8a5e0e06409511e0d964a863.zip FreeBSD-src-8e75a7257b6388ab8a5e0e06409511e0d964a863.tar.gz |
- Change internal function bpf_jit_compile() to return allocated size of
the generated binary and remove page size limitation for userland.
- Use contigmalloc(9)/contigfree(9) instead of malloc(9)/free(9) to make
sure the generated binary aligns properly and make it physically contiguous.
Diffstat (limited to 'sys/net/bpf_jitter.c')
-rw-r--r-- | sys/net/bpf_jitter.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/net/bpf_jitter.c b/sys/net/bpf_jitter.c index 97f96a8..112b873 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, int *); +bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, size_t *, int *); static u_int bpf_jit_accept_all(u_char *, u_int, u_int); @@ -81,7 +81,8 @@ bpf_jitter(struct bpf_insn *fp, int nins) } /* Create the binary */ - if ((filter->func = bpf_jit_compile(fp, nins, filter->mem)) == NULL) { + if ((filter->func = bpf_jit_compile(fp, nins, &filter->size, + filter->mem)) == NULL) { free(filter, M_BPFJIT); return (NULL); } @@ -94,7 +95,7 @@ bpf_destroy_jit_filter(bpf_jit_filter *filter) { if (filter->func != bpf_jit_accept_all) - free(filter->func, M_BPFJIT); + contigfree(filter->func, filter->size, M_BPFJIT); free(filter, M_BPFJIT); } #else @@ -116,7 +117,8 @@ bpf_jitter(struct bpf_insn *fp, int nins) } /* Create the binary */ - if ((filter->func = bpf_jit_compile(fp, nins, filter->mem)) == NULL) { + if ((filter->func = bpf_jit_compile(fp, nins, &filter->size, + filter->mem)) == NULL) { free(filter); return (NULL); } @@ -129,7 +131,7 @@ bpf_destroy_jit_filter(bpf_jit_filter *filter) { if (filter->func != bpf_jit_accept_all) - munmap(filter->func, BPF_JIT_MAXSIZE); + munmap(filter->func, filter->size); free(filter); } #endif |