summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2024-04-28 05:09:54 +0200
committerMartin KaFai Lau <martin.lau@kernel.org>2024-04-30 01:48:33 +0200
commit1bba3b3d373dbafae891e7cb06b8c82c8d62aba1 (patch)
treea0dbfaaf0e1970a93b7b2536632329019a219d49 /tools/testing/selftests/bpf/progs
parentlibbpf: handle nulled-out program in struct_ops correctly (diff)
downloadlinux-1bba3b3d373dbafae891e7cb06b8c82c8d62aba1.tar.xz
linux-1bba3b3d373dbafae891e7cb06b8c82c8d62aba1.zip
selftests/bpf: validate nulled-out struct_ops program is handled properly
Add a selftests validating that it's possible to have some struct_ops callback set declaratively, then disable it (by setting to NULL) programmatically. Libbpf should detect that such program should not be loaded. Otherwise, it will unnecessarily fail the loading when the host kernel does not have the type information. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20240428030954.3918764-2-andrii@kernel.org Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs')
-rw-r--r--tools/testing/selftests/bpf/progs/struct_ops_module.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/struct_ops_module.c b/tools/testing/selftests/bpf/progs/struct_ops_module.c
index 63b065dae002..40109be2b3ae 100644
--- a/tools/testing/selftests/bpf/progs/struct_ops_module.c
+++ b/tools/testing/selftests/bpf/progs/struct_ops_module.c
@@ -63,10 +63,17 @@ struct bpf_testmod_ops___zeroed {
int zeroed;
};
+SEC("?struct_ops/test_3")
+int BPF_PROG(zeroed_op)
+{
+ return 1;
+}
+
SEC(".struct_ops.link")
struct bpf_testmod_ops___zeroed testmod_zeroed = {
.test_1 = (void *)test_1,
.test_2 = (void *)test_2_v2,
+ .zeroed_op = (void *)zeroed_op,
};
struct bpf_testmod_ops___incompatible {