selftests/bpf: test bpf_get_func_* for fsession

Test following bpf helper for fsession:
  bpf_get_func_arg()
  bpf_get_func_arg_cnt()
  bpf_get_func_ret()
  bpf_get_func_ip()

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Link: https://lore.kernel.org/r/20260124062008.8657-12-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Menglong Dong
2026-01-24 14:20:06 +08:00
committed by Alexei Starovoitov
parent f7afef5617
commit a5533a6eaa
4 changed files with 65 additions and 1 deletions

View File

@@ -103,3 +103,26 @@ int BPF_URETPROBE(test8, int ret)
test8_result = (const void *) addr == (const void *) uprobe_trigger;
return 0;
}
__u64 test9_entry_result = 0;
__u64 test9_exit_result = 0;
#ifdef __TARGET_ARCH_x86
SEC("fsession/bpf_fentry_test1")
int BPF_PROG(test9, int a)
{
__u64 addr = bpf_get_func_ip(ctx);
if (bpf_session_is_return(ctx))
test9_exit_result = (const void *) addr == &bpf_fentry_test1;
else
test9_entry_result = (const void *) addr == &bpf_fentry_test1;
return 0;
}
#else
SEC("fentry/bpf_fentry_test1")
int BPF_PROG(test9, int a)
{
test9_entry_result = test9_exit_result = 1;
return 0;
}
#endif