selftests: bpf: add selftest for __sk_buff context in BPF_PROG_TEST_RUN
authorStanislav Fomichev <sdf@google.com>
Tue, 9 Apr 2019 18:49:11 +0000 (11:49 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 11 Apr 2019 08:21:41 +0000 (10:21 +0200)
commit3daf8e703ec3dcf73a27a7dcabbac152793eb114
treef754d8dd81d388e6a3747e834fcd4163f8494e88
parent5e903c656b98614698a891c6e098186272cbba14
selftests: bpf: add selftest for __sk_buff context in BPF_PROG_TEST_RUN

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: Stanislav Fomichev <sdf@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/prog_tests/skb_ctx.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_skb_ctx.c [new file with mode: 0644]