1. 26 8月, 2014 1 次提交
  2. 03 8月, 2014 1 次提交
    • A
      net: filter: split 'struct sk_filter' into socket and bpf parts · 7ae457c1
      Alexei Starovoitov 提交于
      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: NAlexei Starovoitov <ast@plumgrid.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7ae457c1
  3. 26 6月, 2014 15 次提交
  4. 05 6月, 2014 1 次提交
  5. 30 5月, 2014 1 次提交
    • M
      MIPS: net: Add BPF JIT · c6610de3
      Markos Chandras 提交于
      This adds initial support for BPF-JIT on MIPS
      
      Tested on mips32 LE/BE and mips64 BE/n64 using
      dhcp, ping and various tcpdump filters.
      
      Benchmarking:
      
      Assuming the remote MIPS target uses 192.168.154.181
      as its IP address, and the local host uses 192.168.154.136,
      the following results can be obtained using the following
      tcpdump filter (catches no frames) and a simple
      'time ping -f -c 1000000' command.
      
      [root@(none) ~]# tcpdump -p -n -s 0 -i eth0 net 10.0.0.0/24 -d
      (000) ldh      [12]
      (001) jeq      #0x800           jt 2	jf 8
      (002) ld       [26]
      (003) and      #0xffffff00
      (004) jeq      #0xa000000       jt 16	jf 5
      (005) ld       [30]
      (006) and      #0xffffff00
      (007) jeq      #0xa000000       jt 16	jf 17
      (008) jeq      #0x806           jt 10	jf 9
      (009) jeq      #0x8035          jt 10	jf 17
      (010) ld       [28]
      (011) and      #0xffffff00
      (012) jeq      #0xa000000       jt 16	jf 13
      (013) ld       [38]
      (014) and      #0xffffff00
      (015) jeq      #0xa000000       jt 16	jf 17
      (016) ret      #65535
      
      - BPF-JIT Disabled
      
      real    1m38.005s
      user    0m1.510s
      sys     0m6.710s
      
      - BPF-JIT Enabled
      
      real    1m35.215s
      user    0m1.200s
      sys     0m4.140s
      
      [ralf@linux-mips.org: Resolved conflict.]
      Signed-off-by: NMarkos Chandras <markos.chandras@imgtec.com>
      c6610de3