]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Test multi_st_ops and calling kfuncs from different programs
authorAmery Hung <ameryhung@gmail.com>
Wed, 6 Aug 2025 16:25:40 +0000 (09:25 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Wed, 6 Aug 2025 23:01:58 +0000 (16:01 -0700)
commitba7000f1c360f34286f48bd5e670cefbab77ce8f
treebd0accb31af9e24c738fc8a6eb259781a61bd69a
parenteeb52b6279cfebae07703f772621fb9d5972e541
selftests/bpf: Test multi_st_ops and calling kfuncs from different programs

Test multi_st_ops and demonstrate how different bpf programs can call
a kfuncs that refers to the struct_ops instance in the same source file
by id. The id is defined as a global vairable and initialized before
attaching the skeleton. Kfuncs that take the id can hide the argument
with a macro to make it almost transparent to bpf program developers.

The test involves two struct_ops returning different values from
.test_1. In syscall and tracing programs, check if the correct value is
returned by a kfunc that calls .test_1.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250806162540.681679-4-ameryhung@gmail.com
tools/testing/selftests/bpf/prog_tests/test_struct_ops_id_ops_mapping.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_id_ops_mapping1.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_id_ops_mapping2.c [new file with mode: 0644]