]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add selftests for BPF_MODIFY_RETURN
authorKP Singh <kpsingh@google.com>
Wed, 4 Mar 2020 19:18:53 +0000 (20:18 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 4 Mar 2020 21:41:06 +0000 (13:41 -0800)
commit3ee2255f81782fb2968c0c597be5658c7f9a7c9f
tree7e9836d1926fce0e65362a47474fed446ea75f8c
parent9948540194e840c08e7784aab21a6e9f9203f98d
bpf: Add selftests for BPF_MODIFY_RETURN

Test for two scenarios:

  * When the fmod_ret program returns 0, the original function should
    be called along with fentry and fexit programs.
  * When the fmod_ret program returns a non-zero value, the original
    function should not be called, no side effect should be observed and
    fentry and fexit programs should be called.

The result from the kernel function call and whether a side-effect is
observed is returned via the retval attr of the BPF_PROG_TEST_RUN (bpf)
syscall.

Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200304191853.1529-8-kpsingh@chromium.org
net/bpf/test_run.c
tools/testing/selftests/bpf/prog_tests/modify_return.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/modify_return.c [new file with mode: 0644]