Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2019 Facebook */
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("fexit/bpf_fentry_test1")
0011 int BPF_PROG(test1, int a, int ret)
0012 {
0013     test1_result = a == 1 && ret == 2;
0014     return 0;
0015 }
0016 
0017 __u64 test2_result = 0;
0018 SEC("fexit/bpf_fentry_test2")
0019 int BPF_PROG(test2, int a, __u64 b, int ret)
0020 {
0021     test2_result = a == 2 && b == 3 && ret == 5;
0022     return 0;
0023 }
0024 
0025 __u64 test3_result = 0;
0026 SEC("fexit/bpf_fentry_test3")
0027 int BPF_PROG(test3, char a, int b, __u64 c, int ret)
0028 {
0029     test3_result = a == 4 && b == 5 && c == 6 && ret == 15;
0030     return 0;
0031 }
0032 
0033 __u64 test4_result = 0;
0034 SEC("fexit/bpf_fentry_test4")
0035 int BPF_PROG(test4, void *a, char b, int c, __u64 d, int ret)
0036 {
0037     test4_result = a == (void *)7 && b == 8 && c == 9 && d == 10 &&
0038         ret == 34;
0039     return 0;
0040 }
0041 
0042 __u64 test5_result = 0;
0043 SEC("fexit/bpf_fentry_test5")
0044 int BPF_PROG(test5, __u64 a, void *b, short c, int d, __u64 e, int ret)
0045 {
0046     test5_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
0047         e == 15 && ret == 65;
0048     return 0;
0049 }
0050 
0051 __u64 test6_result = 0;
0052 SEC("fexit/bpf_fentry_test6")
0053 int BPF_PROG(test6, __u64 a, void *b, short c, int d, void *e, __u64 f, int ret)
0054 {
0055     test6_result = a == 16 && b == (void *)17 && c == 18 && d == 19 &&
0056         e == (void *)20 && f == 21 && ret == 111;
0057     return 0;
0058 }
0059 
0060 struct bpf_fentry_test_t {
0061     struct bpf_fentry_test *a;
0062 };
0063 
0064 __u64 test7_result = 0;
0065 SEC("fexit/bpf_fentry_test7")
0066 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
0067 {
0068     if (!arg)
0069         test7_result = 1;
0070     return 0;
0071 }
0072 
0073 __u64 test8_result = 0;
0074 SEC("fexit/bpf_fentry_test8")
0075 int BPF_PROG(test8, struct bpf_fentry_test_t *arg)
0076 {
0077     if (!arg->a)
0078         test8_result = 1;
0079     return 0;
0080 }