1 // SPDX-License-Identifier: GPL-2.0 2 #include "vmlinux.h" 3 #include <bpf/bpf_helpers.h> 4 #include <bpf/bpf_tracing.h> 5 #include <errno.h> 6 7 char _license[] SEC("license") = "GPL"; 8 9 __u64 test1_result = 0; 10 11 SEC("fsession/bpf_fentry_test1") 12 int BPF_PROG(test1) 13 { 14 __u64 cnt = bpf_get_func_arg_cnt(ctx); 15 __u64 a = 0, z = 0, ret = 0; 16 __s64 err; 17 18 test1_result = cnt == 1; 19 20 /* valid arguments */ 21 err = bpf_get_func_arg(ctx, 0, &a); 22 test1_result &= err == 0 && ((int) a == 1); 23 24 /* not valid argument */ 25 err = bpf_get_func_arg(ctx, 1, &z); 26 test1_result &= err == -EINVAL; 27 28 if (bpf_session_is_return(ctx)) { 29 err = bpf_get_func_ret(ctx, &ret); 30 test1_result &= err == 0 && ret == 2; 31 } else { 32 err = bpf_get_func_ret(ctx, &ret); 33 test1_result &= err == 0 && ret == 0; 34 } 35 36 return 0; 37 } 38