xref: /linux/tools/testing/selftests/bpf/progs/get_func_ip_fsession_test.c (revision 0fc8f6200d2313278fbf4539bbab74677c685531)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "vmlinux.h"
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
5 
6 char _license[] SEC("license") = "GPL";
7 
8 __u64 test1_entry_result = 0;
9 __u64 test1_exit_result = 0;
10 
11 SEC("fsession/bpf_fentry_test1")
12 int BPF_PROG(test1, int a)
13 {
14 	__u64 addr = bpf_get_func_ip(ctx);
15 
16 	if (bpf_session_is_return(ctx))
17 		test1_exit_result = (const void *) addr == &bpf_fentry_test1;
18 	else
19 		test1_entry_result = (const void *) addr == &bpf_fentry_test1;
20 	return 0;
21 }
22