aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2014-07-30 23:34:16 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-02 18:03:58 -0400
commit7ae457c1e5b45a1b826fad9d62b32191d2bdcfdb (patch)
treedcb1aba57530e6c9426a81758173ca146ffafcaf /arch/x86
parent8fb575ca396bc31d9fa99c26336e2432b41d1bfc (diff)
net: filter: split 'struct sk_filter' into socket and bpf parts
clean up names related to socket filtering and bpf in the following way: - everything that deals with sockets keeps 'sk_*' prefix - everything that is pure BPF is changed to 'bpf_*' prefix split 'struct sk_filter' into struct sk_filter { atomic_t refcnt; struct rcu_head rcu; struct bpf_prog *prog; }; and struct bpf_prog { u32 jited:1, len:31; struct sock_fprog_kern *orig_prog; unsigned int (*bpf_func)(const struct sk_buff *skb, const struct bpf_insn *filter); union { struct sock_filter insns[0]; struct bpf_insn insnsi[0]; struct work_struct work; }; }; so that 'struct bpf_prog' can be used independent of sockets and cleans up 'unattached' bpf use cases split SK_RUN_FILTER macro into: SK_RUN_FILTER to be used with 'struct sk_filter *' and BPF_PROG_RUN to be used with 'struct bpf_prog *' __sk_filter_release(struct sk_filter *) gains __bpf_prog_release(struct bpf_prog *) helper function also perform related renames for the functions that work with 'struct bpf_prog *', since they're on the same lines: sk_filter_size -> bpf_prog_size sk_filter_select_runtime -> bpf_prog_select_runtime sk_filter_free -> bpf_prog_free sk_unattached_filter_create -> bpf_prog_create sk_unattached_filter_destroy -> bpf_prog_destroy sk_store_orig_filter -> bpf_prog_store_orig_filter sk_release_orig_filter -> bpf_release_orig_filter __sk_migrate_filter -> bpf_migrate_filter __sk_prepare_filter -> bpf_prepare_filter API for attaching classic BPF to a socket stays the same: sk_attach_filter(prog, struct sock *)/sk_detach_filter(struct sock *) and SK_RUN_FILTER(struct sk_filter *, ctx) to execute a program which is used by sockets, tun, af_packet API for 'unattached' BPF programs becomes: bpf_prog_create(struct bpf_prog **)/bpf_prog_destroy(struct bpf_prog *) and BPF_PROG_RUN(struct bpf_prog *, ctx) to execute a program which is used by isdn, ppp, team, seccomp, ptp, xt_bpf, cls_bpf, test_bpf Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/net/bpf_jit_comp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index e2ecc1380b3d..5c8cb8043c5a 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -211,7 +211,7 @@ struct jit_context {
211 bool seen_ld_abs; 211 bool seen_ld_abs;
212}; 212};
213 213
214static int do_jit(struct sk_filter *bpf_prog, int *addrs, u8 *image, 214static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
215 int oldproglen, struct jit_context *ctx) 215 int oldproglen, struct jit_context *ctx)
216{ 216{
217 struct bpf_insn *insn = bpf_prog->insnsi; 217 struct bpf_insn *insn = bpf_prog->insnsi;
@@ -841,7 +841,7 @@ common_load: ctx->seen_ld_abs = true;
841 /* By design x64 JIT should support all BPF instructions 841 /* By design x64 JIT should support all BPF instructions
842 * This error will be seen if new instruction was added 842 * This error will be seen if new instruction was added
843 * to interpreter, but not to JIT 843 * to interpreter, but not to JIT
844 * or if there is junk in sk_filter 844 * or if there is junk in bpf_prog
845 */ 845 */
846 pr_err("bpf_jit: unknown opcode %02x\n", insn->code); 846 pr_err("bpf_jit: unknown opcode %02x\n", insn->code);
847 return -EINVAL; 847 return -EINVAL;
@@ -862,11 +862,11 @@ common_load: ctx->seen_ld_abs = true;
862 return proglen; 862 return proglen;
863} 863}
864 864
865void bpf_jit_compile(struct sk_filter *prog) 865void bpf_jit_compile(struct bpf_prog *prog)
866{ 866{
867} 867}
868 868
869void bpf_int_jit_compile(struct sk_filter *prog) 869void bpf_int_jit_compile(struct bpf_prog *prog)
870{ 870{
871 struct bpf_binary_header *header = NULL; 871 struct bpf_binary_header *header = NULL;
872 int proglen, oldproglen = 0; 872 int proglen, oldproglen = 0;
@@ -932,7 +932,7 @@ out:
932 932
933static void bpf_jit_free_deferred(struct work_struct *work) 933static void bpf_jit_free_deferred(struct work_struct *work)
934{ 934{
935 struct sk_filter *fp = container_of(work, struct sk_filter, work); 935 struct bpf_prog *fp = container_of(work, struct bpf_prog, work);
936 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK; 936 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
937 struct bpf_binary_header *header = (void *)addr; 937 struct bpf_binary_header *header = (void *)addr;
938 938
@@ -941,7 +941,7 @@ static void bpf_jit_free_deferred(struct work_struct *work)
941 kfree(fp); 941 kfree(fp);
942} 942}
943 943
944void bpf_jit_free(struct sk_filter *fp) 944void bpf_jit_free(struct bpf_prog *fp)
945{ 945{
946 if (fp->jited) { 946 if (fp->jited) {
947 INIT_WORK(&fp->work, bpf_jit_free_deferred); 947 INIT_WORK(&fp->work, bpf_jit_free_deferred);