]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Test BPF_PROG_ASSOC_STRUCT_OPS command
authorAmery Hung <ameryhung@gmail.com>
Wed, 3 Dec 2025 23:37:46 +0000 (15:37 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Sat, 6 Dec 2025 00:17:58 +0000 (16:17 -0800)
commit33a165f9c2c1b9ddceaaccc356ce841baf1a08a2
treebfac266d7e2ae0f5686e1b51b1a57a716ac9d3d2
parent87cd177b149a5d86103736994307c25999e0be4b
selftests/bpf: Test BPF_PROG_ASSOC_STRUCT_OPS command

Test BPF_PROG_ASSOC_STRUCT_OPS command that associates a BPF program
with a struct_ops. The test follows the same logic in commit
ba7000f1c360 ("selftests/bpf: Test multi_st_ops and calling kfuncs from
different programs"), but instead of using map id to identify a specific
struct_ops, this test uses the new BPF command to associate a struct_ops
with a program.

The test consists of two sets of almost identical struct_ops maps and BPF
programs associated with the map. Their only difference is the unique
value returned by bpf_testmod_multi_st_ops::test_1().

The test first loads the programs and associates them with struct_ops
maps. Then, it exercises the BPF programs. They will in turn call kfunc
bpf_kfunc_multi_st_ops_test_1_prog_arg() to trigger test_1() of the
associated struct_ops map, and then check if the right unique value is
returned.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20251203233748.668365-5-ameryhung@gmail.com
tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_assoc.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h