Skip to content

Commit 834f2ad

Browse files
author
Menglong Dong
committed
selftests/bpf: add testcase for mixing fsession, fentry and fexit
Test the fsession when it is used together with fentry, fexit. Signed-off-by: Menglong Dong <[email protected]>
1 parent ecdaa04 commit 834f2ad

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,41 @@ 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, __u64 a, void *b, short c, int d, __u64 e, int ret)
237+
{
238+
__u64 *cookie = bpf_fsession_cookie(ctx);
239+
240+
if (!bpf_tracing_is_exit(ctx)) {
241+
test13_entry_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
242+
e == 15 && ret == 0;
243+
*cookie = 0x123456ULL;
244+
return 0;
245+
}
246+
247+
test13_exit_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
248+
e == 15 && ret == 65 && *cookie == 0x123456ULL;
249+
return 0;
250+
}
251+
252+
__u64 test14_result = 0;
253+
SEC("fexit/bpf_fentry_test1")
254+
int BPF_PROG(test14, __u64 a, void *b, short c, int d, __u64 e, int ret)
255+
{
256+
test14_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
257+
e == 15 && ret == 65;
258+
return 0;
259+
}
260+
261+
__u64 test15_result = 0;
262+
SEC("fentry/bpf_fentry_test1")
263+
int BPF_PROG(test15, __u64 a, void *b, short c, int d, __u64 e)
264+
{
265+
test15_result = a == 11 && b == (void *)12 && c == 13 && d == 14 &&
266+
e == 15;
267+
return 0;
268+
}

0 commit comments

Comments
 (0)