]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Add tests for program extensions
authorAlexei Starovoitov <ast@kernel.org>
Tue, 21 Jan 2020 00:53:48 +0000 (16:53 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 22 Jan 2020 22:04:53 +0000 (23:04 +0100)
commit7755d7faf771c3218e634a7a4f020aa07303c440
tree99bc088a4cd4e27b6c5befcbae2ade0ea72a7f1d
parent9ed3f5ac073797075b39ec084f38df34fd2ec0b4
selftests/bpf: Add tests for program extensions

Add program extension tests that build on top of fexit_bpf2bpf tests.
Replace three global functions in previously loaded test_pkt_access.c program
with three new implementations:
int get_skb_len(struct __sk_buff *skb);
int get_constant(long val);
int get_skb_ifindex(int val, struct __sk_buff *skb, int var);
New function return the same results as original only if arguments match.

new_get_skb_ifindex() demonstrates that 'skb' argument doesn't have to be first
and only argument of BPF program. All normal skb based accesses are available.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20200121005348.2769920-4-ast@kernel.org
tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
tools/testing/selftests/bpf/progs/test_pkt_access.c