aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/test_pkt_access.c
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2020-01-20 16:53:48 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2020-01-22 23:04:53 +0100
commit7805fe843964f81f98592bf580b9cd736ac4ad4c (patch)
tree99bc088a4cd4e27b6c5befcbae2ade0ea72a7f1d /tools/testing/selftests/bpf/progs/test_pkt_access.c
parentlibbpf: Add support for program extensions (diff)
downloadlinux-dev-7805fe843964f81f98592bf580b9cd736ac4ad4c.tar.xz
linux-dev-7805fe843964f81f98592bf580b9cd736ac4ad4c.zip
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
Diffstat (limited to '')
-rw-r--r--tools/testing/selftests/bpf/progs/test_pkt_access.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_pkt_access.c b/tools/testing/selftests/bpf/progs/test_pkt_access.c
index 7c9fcfd2b463..e72eba4a93d2 100644
--- a/tools/testing/selftests/bpf/progs/test_pkt_access.c
+++ b/tools/testing/selftests/bpf/progs/test_pkt_access.c
@@ -57,12 +57,18 @@ int get_skb_len(struct __sk_buff *skb)
return skb->len;
}
+__attribute__ ((noinline))
+int get_constant(long val)
+{
+ return val - 122;
+}
+
int get_skb_ifindex(int, struct __sk_buff *skb, int);
__attribute__ ((noinline))
int test_pkt_access_subprog3(int val, struct __sk_buff *skb)
{
- return get_skb_len(skb) * get_skb_ifindex(val, skb, 1);
+ return get_skb_len(skb) * get_skb_ifindex(val, skb, get_constant(123));
}
__attribute__ ((noinline))