Skip to content

Commit ecdaa04

Browse files
author
Menglong Dong
committed
selftests/bpf: add session cookie testcase for fsession
Test the session cookie for fsession. Multiple fsession BPF progs is attached to bpf_fentry_test1() and session cookie is read and write in this testcase. Signed-off-by: Menglong Dong <[email protected]>
1 parent a28cd9a commit ecdaa04

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,44 @@ int BPF_PROG(test10, int a)
187187
test10_entry_result = (const void *) addr == &bpf_fentry_test1;
188188
return 0;
189189
}
190+
191+
__u64 test11_entry_ok = 0;
192+
__u64 test11_exit_ok = 0;
193+
SEC("fsession/bpf_fentry_test1")
194+
int BPF_PROG(test11, int a)
195+
{
196+
__u64 *cookie = bpf_fsession_cookie(ctx);
197+
198+
if (!bpf_tracing_is_exit(ctx)) {
199+
if (cookie) {
200+
*cookie = 0xAAAABBBBCCCCDDDDull;
201+
test11_entry_ok = *cookie == 0xAAAABBBBCCCCDDDDull;
202+
}
203+
return 0;
204+
}
205+
206+
if (cookie)
207+
test11_exit_ok = *cookie == 0xAAAABBBBCCCCDDDDull;
208+
return 0;
209+
}
210+
211+
__u64 test12_entry_ok = 0;
212+
__u64 test12_exit_ok = 0;
213+
214+
SEC("fsession/bpf_fentry_test1")
215+
int BPF_PROG(test12, int a)
216+
{
217+
__u64 *cookie = bpf_fsession_cookie(ctx);
218+
219+
if (!bpf_tracing_is_exit(ctx)) {
220+
if (cookie) {
221+
*cookie = 0x1111222233334444ull;
222+
test12_entry_ok = *cookie == 0x1111222233334444ull;
223+
}
224+
return 0;
225+
}
226+
227+
if (cookie)
228+
test12_exit_ok = *cookie == 0x1111222233334444ull;
229+
return 0;
230+
}

0 commit comments

Comments
 (0)