0001
0002
0003 #include <linux/bpf.h>
0004 #include <bpf/bpf_helpers.h>
0005 #include <bpf/bpf_tracing.h>
0006
0007 char _license[] SEC("license") = "GPL";
0008
0009 __u64 test1_result = 0;
0010 SEC("fentry/bpf_fentry_test1")
0011 int BPF_PROG(test1, int a)
0012 {
0013 test1_result = a == 1;
0014 return 0;
0015 }
0016
0017 __u64 test2_result = 0;
0018 SEC("fentry/bpf_fentry_test2")
0019 int BPF_PROG(test2, int a, __u64 b)
0020 {
0021 test2_result = a == 2 && b == 3;
0022 return 0;
0023 }
0024
0025 __u64 test3_result = 0;
0026 SEC("fentry/bpf_fentry_test3")
0027 int BPF_PROG(test3, char a, int b, __u64 c)
0028 {
0029 test3_result = a == 4 && b == 5 && c == 6;
0030 return 0;
0031 }
0032
0033 __u64 test4_result = 0;
0034 SEC("fentry/bpf_fentry_test4")
0035 int BPF_PROG(test4, void *a, char b, int c, __u64 d)
0036 {
0037 test4_result = a == (void *)7 && b == 8 && c == 9 && d == 10;
0038 return 0;
0039 }
0040
0041 __u64 test5_result = 0;
0042 SEC("fentry/bpf_fentry_test5")
0043 int BPF_PROG(test5, __u64 a, void *b, short c, int d, __u64 e)
0044 {
0045 test5_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
0046 e == 15;
0047 return 0;
0048 }
0049
0050 __u64 test6_result = 0;
0051 SEC("fentry/bpf_fentry_test6")
0052 int BPF_PROG(test6, __u64 a, void *b, short c, int d, void * e, __u64 f)
0053 {
0054 test6_result = a == 16 && b == (void *)17 && c == 18 && d == 19 &&
0055 e == (void *)20 && f == 21;
0056 return 0;
0057 }
0058
0059 struct bpf_fentry_test_t {
0060 struct bpf_fentry_test_t *a;
0061 };
0062
0063 __u64 test7_result = 0;
0064 SEC("fentry/bpf_fentry_test7")
0065 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
0066 {
0067 if (!arg)
0068 test7_result = 1;
0069 return 0;
0070 }
0071
0072 __u64 test8_result = 0;
0073 SEC("fentry/bpf_fentry_test8")
0074 int BPF_PROG(test8, struct bpf_fentry_test_t *arg)
0075 {
0076 if (arg->a == 0)
0077 test8_result = 1;
0078 return 0;
0079 }