1. 03 6月, 2014 1 次提交
    • C
      net: filter: fix length calculation in BPF testsuite · e9d94504
      Chema Gonzalez 提交于
      The current probe_filter_length() (the function that calculates the
      length of a test BPF filter) behavior is to declare the end of the
      filter as soon as it finds {0, *, *, 0}. This is actually a valid
      insn ("ld #0"), so any filter with includes "BPF_STMT(BPF_LD | BPF_IMM, 0)"
      fails (its length is cut short).
      
      We are changing probe_filter_length() so as to start from the end, and
      declare the end of the filter as the first instruction which is not
      {0, *, *, 0}. This solution produces a simpler patch than the
      alternative of using an explicit end-of-filter mark. It is technically
      incorrect if your filter ends up with "ld #0", but that should not
      happen anyway.
      
      We also add a new test (LD_IMM_0) that includes ld #0 (does not work
      without this patch).
      Signed-off-by: NChema Gonzalez <chema@google.com>
      Acked-by: NDaniel Borkmann <dborkman@redhat.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e9d94504
  2. 02 6月, 2014 2 次提交
  3. 31 5月, 2014 2 次提交
  4. 24 5月, 2014 4 次提交
  5. 22 5月, 2014 1 次提交
    • A
      net: filter: cleanup invocation of internal BPF · 5fe821a9
      Alexei Starovoitov 提交于
      Kernel API for classic BPF socket filters is:
      
      sk_unattached_filter_create() - validate classic BPF, convert, JIT
      SK_RUN_FILTER() - run it
      sk_unattached_filter_destroy() - destroy socket filter
      
      Cleanup internal BPF kernel API as following:
      
      sk_filter_select_runtime() - final step of internal BPF creation.
        Try to JIT internal BPF program, if JIT is not available select interpreter
      SK_RUN_FILTER() - run it
      sk_filter_free() - free internal BPF program
      
      Disallow direct calls to BPF interpreter. Execution of the BPF program should
      be done with SK_RUN_FILTER() macro.
      
      Example of internal BPF create, run, destroy:
      
        struct sk_filter *fp;
      
        fp = kzalloc(sk_filter_size(prog_len), GFP_KERNEL);
        memcpy(fp->insni, prog, prog_len * sizeof(fp->insni[0]));
        fp->len = prog_len;
      
        sk_filter_select_runtime(fp);
      
        SK_RUN_FILTER(fp, ctx);
      
        sk_filter_free(fp);
      
      Sockets, seccomp, testsuite, tracing are using different ways to populate
      sk_filter, so first steps of program creation are not common.
      Signed-off-by: NAlexei Starovoitov <ast@plumgrid.com>
      Acked-by: NDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5fe821a9
  6. 12 5月, 2014 2 次提交
    • A
      net: filter: additional BPF tests · 9def624a
      Alexei Starovoitov 提交于
      All tests should pass with and without JIT.
      
      Example output:
      test_bpf: #0 TAX 35 16 16 PASS
      test_bpf: #1 TXA 7 7 7 PASS
      test_bpf: #2 ADD_SUB_MUL_K 10 PASS
      test_bpf: #3 DIV_KX 33 PASS
      test_bpf: #4 AND_OR_LSH_K 10 10 PASS
      test_bpf: #5 LD_IND 8 8 8 PASS
      test_bpf: #6 LD_ABS 8 8 8 PASS
      test_bpf: #7 LD_ABS_LL 13 14 PASS
      test_bpf: #8 LD_IND_LL 12 12 12 PASS
      test_bpf: #9 LD_ABS_NET 10 12 PASS
      test_bpf: #10 LD_IND_NET 11 12 12 PASS
      ...
      
      Numbers are times in nsec per filter for given input data.
      Signed-off-by: NAlexei Starovoitov <ast@plumgrid.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9def624a
    • A
      net: filter: BPF testsuite · 64a8946b
      Alexei Starovoitov 提交于
      The testsuite covers classic and internal BPF instructions.
      It is particularly useful for JIT compiler developers.
      Adds to "net" selftest target.
      
      The testsuite can be used as a set of micro-benchmarks.
      It measures execution time of each BPF program in nsec.
      
      This patch adds core framework.
      Signed-off-by: NAlexei Starovoitov <ast@plumgrid.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      64a8946b