diff options
Diffstat (limited to 'tools/testing/selftests/bpf/progs/fentry_kprobe_shared.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/fentry_kprobe_shared.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/fentry_kprobe_shared.c b/tools/testing/selftests/bpf/progs/fentry_kprobe_shared.c new file mode 100644 index 000000000..3d16773aa --- /dev/null +++ b/tools/testing/selftests/bpf/progs/fentry_kprobe_shared.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +char _license[] SEC("license") = "GPL"; + +int pid; +int fentry1_hits; +int fentry2_hits; +int fexit_hits; +int kprobe_hits; + +static bool from_test(int a) +{ + return (bpf_get_current_pid_tgid() >> 32) == pid && a == 1; +} + +SEC("fentry/bpf_fentry_test1") +int BPF_PROG(fentry1, int a) +{ + if (from_test(a)) + fentry1_hits++; + return 0; +} + +SEC("fentry/bpf_fentry_test1") +int BPF_PROG(fentry2, int a) +{ + if (from_test(a)) + fentry2_hits++; + return 0; +} + +SEC("fexit/bpf_fentry_test1") +int BPF_PROG(fexit1, int a, int ret) +{ + if (from_test(a) && ret == 2) + fexit_hits++; + return 0; +} + +SEC("kprobe/bpf_fentry_test1") +int BPF_KPROBE(kprobe1, int a) +{ + if (from_test(a)) + kprobe_hits++; + return 0; +} |
