Skip to content

Commit efa2d1b

Browse files
image-dragonKernel Patches Daemon
authored andcommitted
selftests/bpf: test get_func_ip for fsession
As the layout of the stack changed for fsession, we'd better test bpf_get_func_ip() for it. Signed-off-by: Menglong Dong <[email protected]>
1 parent c88fb2e commit efa2d1b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ static void test_function_entry(void)
4646
ASSERT_EQ(skel->bss->test5_result, 1, "test5_result");
4747
ASSERT_EQ(skel->bss->test7_result, 1, "test7_result");
4848
ASSERT_EQ(skel->bss->test8_result, 1, "test8_result");
49+
ASSERT_EQ(skel->bss->test9_result1, 1, "test9_result1");
50+
ASSERT_EQ(skel->bss->test9_result2, 1, "test9_result2");
4951

5052
cleanup:
5153
get_func_ip_test__destroy(skel);

tools/testing/selftests/bpf/progs/get_func_ip_test.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@ int BPF_URETPROBE(test8, int ret)
103103
test8_result = (const void *) addr == (const void *) uprobe_trigger;
104104
return 0;
105105
}
106+
107+
__u64 test9_result1 = 0;
108+
__u64 test9_result2 = 0;
109+
SEC("fsession/bpf_fentry_test1")
110+
int BPF_PROG(test9, int a)
111+
{
112+
__u64 addr = bpf_get_func_ip(ctx);
113+
114+
if (bpf_tracing_is_exit(ctx))
115+
test9_result1 = (const void *) addr == &bpf_fentry_test1;
116+
else
117+
test9_result2 = (const void *) addr == &bpf_fentry_test1;
118+
return 0;
119+
}

0 commit comments

Comments
 (0)