1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2020 Google LLC.
8 #include <bpf/bpf_helpers.h>
9 #include <bpf/bpf_tracing.h>
11 char _license[] SEC("license") = "GPL";
13 static int sequence = 0;
14 __s32 input_retval = 0;
16 __u64 fentry_result = 0;
17 SEC("fentry/bpf_modify_return_test")
18 int BPF_PROG(fentry_test, int a, __u64 b)
21 fentry_result = (sequence == 1);
25 __u64 fmod_ret_result = 0;
26 SEC("fmod_ret/bpf_modify_return_test")
27 int BPF_PROG(fmod_ret_test, int a, int *b, int ret)
30 /* This is the first fmod_ret program, the ret passed should be 0 */
31 fmod_ret_result = (sequence == 2 && ret == 0);
35 __u64 fexit_result = 0;
36 SEC("fexit/bpf_modify_return_test")
37 int BPF_PROG(fexit_test, int a, __u64 b, int ret)
40 /* If the input_reval is non-zero a successful modification should have
44 fexit_result = (sequence == 3 && ret == input_retval);
46 fexit_result = (sequence == 3 && ret == 4);
53 __u64 fentry_result2 = 0;
54 SEC("fentry/bpf_modify_return_test2")
55 int BPF_PROG(fentry_test2, int a, int *b, short c, int d, void *e, char f,
59 fentry_result2 = (sequence2 == 1);
63 __u64 fmod_ret_result2 = 0;
64 SEC("fmod_ret/bpf_modify_return_test2")
65 int BPF_PROG(fmod_ret_test2, int a, int *b, short c, int d, void *e, char f,
69 /* This is the first fmod_ret program, the ret passed should be 0 */
70 fmod_ret_result2 = (sequence2 == 2 && ret == 0);
74 __u64 fexit_result2 = 0;
75 SEC("fexit/bpf_modify_return_test2")
76 int BPF_PROG(fexit_test2, int a, int *b, short c, int d, void *e, char f,
80 /* If the input_reval is non-zero a successful modification should have
84 fexit_result2 = (sequence2 == 3 && ret == input_retval);
86 fexit_result2 = (sequence2 == 3 && ret == 29);