diff options
author | Eduard Zingerman <eddyz87@gmail.com> | 2024-03-06 12:45:23 +0200 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2024-03-06 15:18:15 -0800 |
commit | 651d49f15b2a84b3bcfe950fa99c3672b9619dbd (patch) | |
tree | eea5bdf4b6fe6d7b31445339fba8e799bf8ad623 /tools/testing/selftests/bpf/progs/bad_struct_ops2.c | |
parent | fe9d049c3da06373a1a35914b7f695509e4cb1fe (diff) |
selftests/bpf: Verify struct_ops autoload/autocreate sync
Check that autocreate flags of struct_ops map cause autoload of
struct_ops corresponding programs:
- when struct_ops program is referenced only from a map for which
autocreate is set to false, that program should not be loaded;
- when struct_ops program with autoload == false is set to be used
from a map with autocreate == true using shadow var,
that program should be loaded;
- when struct_ops program is not referenced from any map object load
should fail.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240306104529.6453-10-eddyz87@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bad_struct_ops2.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/bad_struct_ops2.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bad_struct_ops2.c b/tools/testing/selftests/bpf/progs/bad_struct_ops2.c new file mode 100644 index 0000000000000..64a95f6be86d1 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bad_struct_ops2.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +char _license[] SEC("license") = "GPL"; + +/* This is an unused struct_ops program, it lacks corresponding + * struct_ops map, which provides attachment information. + * W/o additional configuration attempt to load such + * BPF object file would fail. + */ +SEC("struct_ops/foo") +void foo(void) {} |