1. 13 4月, 2019 5 次提交
  2. 12 4月, 2019 32 次提交
  3. 11 4月, 2019 3 次提交
    • S
      selftests: bpf: add selftest for __sk_buff context in BPF_PROG_TEST_RUN · 3daf8e70
      Stanislav Fomichev 提交于
      Simple test that sets cb to {1,2,3,4,5} and priority to 6, runs bpf
      program that fails if cb is not what we expect and increments cb[i] and
      priority. When the test finishes, we check that cb is now {2,3,4,5,6}
      and priority is 7.
      
      We also test the sanity checks:
      * ctx_in is provided, but ctx_size_in is zero (same for
        ctx_out/ctx_size_out)
      * unexpected non-zero fields in __sk_buff return EINVAL
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      3daf8e70
    • S
      libbpf: add support for ctx_{size, }_{in, out} in BPF_PROG_TEST_RUN · 5e903c65
      Stanislav Fomichev 提交于
      Support recently introduced input/output context for test runs.
      We extend only bpf_prog_test_run_xattr. bpf_prog_test_run is
      unextendable and left as is.
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      5e903c65
    • S
      bpf: support input __sk_buff context in BPF_PROG_TEST_RUN · b0b9395d
      Stanislav Fomichev 提交于
      Add new set of arguments to bpf_attr for BPF_PROG_TEST_RUN:
      * ctx_in/ctx_size_in - input context
      * ctx_out/ctx_size_out - output context
      
      The intended use case is to pass some meta data to the test runs that
      operate on skb (this has being brought up on recent LPC).
      
      For programs that use bpf_prog_test_run_skb, support __sk_buff input and
      output. Initially, from input __sk_buff, copy _only_ cb and priority into
      skb, all other non-zero fields are prohibited (with EINVAL).
      If the user has set ctx_out/ctx_size_out, copy the potentially modified
      __sk_buff back to the userspace.
      
      We require all fields of input __sk_buff except the ones we explicitly
      support to be set to zero. The expectation is that in the future we might
      add support for more fields and we want to fail explicitly if the user
      runs the program on the kernel where we don't yet support them.
      
      The API is intentionally vague (i.e. we don't explicitly add __sk_buff
      to bpf_attr, but ctx_in) to potentially let other test_run types use
      this interface in the future (this can be xdp_md for xdp types for
      example).
      
      v4:
        * don't copy more than allowed in bpf_ctx_init [Martin]
      
      v3:
        * handle case where ctx_in is NULL, but ctx_out is not [Martin]
        * convert size==0 checks to ptr==NULL checks and add some extra ptr
          checks [Martin]
      
      v2:
        * Addressed comments from Martin Lau
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      b0b9395d