From: Xi Wang <xi.wang@gmail.com>
To: Daniel Borkmann <dborkman@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Russell King <linux@arm.linux.org.uk>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Eric Dumazet <edumazet@google.com>,
Will Drewry <wad@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Xi Wang <xi.wang@gmail.com>
Subject: [RFC PATCH net-next 5/6] sparc: bpf_jit_comp: refactor the BPF JIT interface
Date: Fri, 26 Apr 2013 03:51:45 -0400 [thread overview]
Message-ID: <1366962706-24204-6-git-send-email-xi.wang@gmail.com> (raw)
In-Reply-To: <1366962706-24204-1-git-send-email-xi.wang@gmail.com>
Implement the refactored bpf_jit_compile() and bpf_jit_free().
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
arch/sparc/net/bpf_jit_comp.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index d36a85e..15e6513 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -354,21 +354,21 @@ do { *prog++ = BR_OPC | WDISP22(OFF); \
* emit_jump() calls with adjusted offsets.
*/
-void bpf_jit_compile(struct sk_filter *fp)
+bpf_func_t bpf_jit_compile(struct sock_filter *filter, unsigned int flen)
{
unsigned int cleanup_addr, proglen, oldproglen = 0;
u32 temp[8], *prog, *func, seen = 0, pass;
- const struct sock_filter *filter = fp->insns;
- int i, flen = fp->len, pc_ret0 = -1;
+ int i, pc_ret0 = -1;
unsigned int *addrs;
void *image;
+ bpf_func_t bpf_func = sk_run_filter;
if (!bpf_jit_enable)
- return;
+ return bpf_func;
addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
if (addrs == NULL)
- return;
+ return bpf_func;
/* Before first pass, make a rough estimation of addrs[]
* each bpf instruction is translated to less than 64 bytes
@@ -763,7 +763,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
pr_err("bpb_jit_compile fatal error\n");
kfree(addrs);
module_free(NULL, image);
- return;
+ return bpf_func;
}
memcpy(image + proglen, temp, ilen);
}
@@ -799,11 +799,11 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
if (image) {
bpf_flush_icache(image, image + proglen);
- fp->bpf_func = (void *)image;
+ bpf_func = (void *)image;
}
out:
kfree(addrs);
- return;
+ return bpf_func;
}
static void jit_free_defer(struct work_struct *arg)
@@ -814,10 +814,10 @@ static void jit_free_defer(struct work_struct *arg)
/* run from softirq, we must use a work_struct to call
* module_free() from process context
*/
-void bpf_jit_free(struct sk_filter *fp)
+void bpf_jit_free(bpf_func_t bpf_func)
{
- if (fp->bpf_func != sk_run_filter) {
- struct work_struct *work = (struct work_struct *)fp->bpf_func;
+ if (bpf_func != sk_run_filter) {
+ struct work_struct *work = (struct work_struct *)bpf_func;
INIT_WORK(work, jit_free_defer);
schedule_work(work);
--
1.8.1.2
next prev parent reply other threads:[~2013-04-26 7:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 7:51 [RFC PATCH net-next 0/6] seccomp filter JIT Xi Wang
2013-04-26 7:51 ` [RFC PATCH net-next 1/6] filter: refactor BPF JIT for seccomp filters Xi Wang
2013-04-26 15:20 ` Eric Dumazet
2013-04-26 7:51 ` [RFC PATCH net-next 2/6] x86: bpf_jit_comp: support BPF_S_ANC_SECCOMP_LD_W instruction Xi Wang
2013-04-26 14:18 ` Eric Dumazet
2013-04-26 14:50 ` Xi Wang
2013-04-26 15:11 ` Eric Dumazet
2013-04-26 15:29 ` Xi Wang
2013-04-26 15:43 ` Eric Dumazet
2013-04-26 15:57 ` Xi Wang
2013-04-26 18:48 ` David Miller
2013-04-26 16:02 ` Xi Wang
2013-04-26 16:14 ` Eric Dumazet
2013-04-26 18:25 ` Xi Wang
2013-04-26 18:40 ` Eric Dumazet
2013-04-26 15:15 ` David Laight
2013-04-26 15:27 ` Eric Dumazet
2013-04-26 15:38 ` David Laight
2013-04-26 15:46 ` Eric Dumazet
2013-04-26 7:51 ` [RFC PATCH net-next 3/6] ARM: net: bpf_jit_32: " Xi Wang
2013-04-26 7:51 ` [RFC PATCH net-next 4/6] PPC: net: bpf_jit_comp: refactor the BPF JIT interface Xi Wang
2013-04-26 7:51 ` Xi Wang [this message]
2013-04-26 7:51 ` [RFC PATCH net-next 6/6] s390/bpf,jit: " Xi Wang
2013-04-26 11:25 ` [RFC PATCH net-next 0/6] seccomp filter JIT Heiko Carstens
2013-04-26 11:46 ` Heiko Carstens
2013-04-26 12:15 ` Xi Wang
2013-04-26 11:46 ` Daniel Borkmann
2013-04-26 12:31 ` Xi Wang
2013-04-26 12:38 ` Daniel Borkmann
2013-04-29 12:18 ` Nicolas Schichan
2013-04-29 13:21 ` Nicolas Schichan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366962706-24204-6-git-send-email-xi.wang@gmail.com \
--to=xi.wang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=edumazet@google.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=wad@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).