Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 37 lines 785 B view raw
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 7char _license[] SEC("license") = "GPL"; 8 9__u64 test1_result = 0; 10 11SEC("fsession/bpf_fentry_test1") 12int 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}