summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_trace_ext.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2020-09-29 15:45:56 +0300
committerAlexei Starovoitov <ast@kernel.org>2020-09-29 23:09:24 +0300
commit17d3f386757609223aa02342d29526daa67efafc (patch)
tree4eba22b7e92439c1832a044eeeddd4e8fc8a0c7f /tools/testing/selftests/bpf/progs/test_trace_ext.c
parentf6429476c2012afade24741cc08890371d2842b4 (diff)
downloadlinux-17d3f386757609223aa02342d29526daa67efafc.tar.xz
selftests/bpf: Adding test for arg dereference in extension trace
Adding test that setup following program: SEC("classifier/test_pkt_md_access") int test_pkt_md_access(struct __sk_buff *skb) with its extension: SEC("freplace/test_pkt_md_access") int test_pkt_md_access_new(struct __sk_buff *skb) and tracing that extension with: SEC("fentry/test_pkt_md_access_new") int BPF_PROG(fentry, struct sk_buff *skb) The test verifies that the tracing program can dereference skb argument properly. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/160138355603.48470.9072073357530773228.stgit@toke.dk
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_trace_ext.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_trace_ext.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_trace_ext.c b/tools/testing/selftests/bpf/progs/test_trace_ext.c
new file mode 100644
index 000000000000..d19a634d0e78
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_trace_ext.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Facebook
+#include <linux/bpf.h>
+#include <stdbool.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_endian.h>
+#include <bpf/bpf_tracing.h>
+
+__u64 ext_called = 0;
+
+SEC("freplace/test_pkt_md_access")
+int test_pkt_md_access_new(struct __sk_buff *skb)
+{
+ ext_called = skb->len;
+ return 0;
+}
+
+char _license[] SEC("license") = "GPL";