Skip to content

Commit 7fdc286

Browse files
image-dragonKernel Patches Daemon
authored andcommitted
selftests/bpf: test fsession mixed with fentry and fexit
Test the fsession when it is used together with fentry, fexit. Signed-off-by: Menglong Dong <[email protected]>
1 parent 3d54eeb commit 7fdc286

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,37 @@ int BPF_PROG(test12, int a)
228228
test12_exit_ok = *cookie == 0x1111222233334444ull;
229229
return 0;
230230
}
231+
232+
__u64 test13_entry_result = 0;
233+
__u64 test13_exit_result = 0;
234+
235+
SEC("fsession/bpf_fentry_test1")
236+
int BPF_PROG(test13, int a, int ret)
237+
{
238+
__u64 *cookie = bpf_fsession_cookie(ctx);
239+
240+
if (!bpf_tracing_is_exit(ctx)) {
241+
test13_entry_result = a == 1 && ret == 0;
242+
*cookie = 0x123456ULL;
243+
return 0;
244+
}
245+
246+
test13_exit_result = a == 1 && ret == 2 && *cookie == 0x123456ULL;
247+
return 0;
248+
}
249+
250+
__u64 test14_result = 0;
251+
SEC("fexit/bpf_fentry_test1")
252+
int BPF_PROG(test14, int a, int ret)
253+
{
254+
test14_result = a == 1 && ret == 2;
255+
return 0;
256+
}
257+
258+
__u64 test15_result = 0;
259+
SEC("fentry/bpf_fentry_test1")
260+
int BPF_PROG(test15, int a)
261+
{
262+
test15_result = a == 1;
263+
return 0;
264+
}

0 commit comments

Comments
 (0)