diff options
author | Eduard Zingerman <eddyz87@gmail.com> | 2024-03-06 12:45:17 +0200 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2024-03-06 15:18:15 -0800 |
commit | 8db052615a9780b45e26d6afabc7abefe1ba20ac (patch) | |
tree | 0be700562e5dd26252c1f41e1d3dbc45445dec06 /tools/testing/selftests/bpf/progs/struct_ops_module.c | |
parent | d9ab2f76ef5abb76190ffb42d83bdc6caede807e (diff) | |
download | linux-8db052615a9780b45e26d6afabc7abefe1ba20ac.tar.gz linux-8db052615a9780b45e26d6afabc7abefe1ba20ac.tar.bz2 linux-8db052615a9780b45e26d6afabc7abefe1ba20ac.zip |
libbpf: Honor autocreate flag for struct_ops maps
Skip load steps for struct_ops maps not marked for automatic creation.
This should allow to load bpf object in situations like below:
SEC("struct_ops/foo") int BPF_PROG(foo) { ... }
SEC("struct_ops/bar") int BPF_PROG(bar) { ... }
struct test_ops___v1 {
int (*foo)(void);
};
struct test_ops___v2 {
int (*foo)(void);
int (*does_not_exist)(void);
};
SEC(".struct_ops.link")
struct test_ops___v1 map_for_old = {
.test_1 = (void *)foo
};
SEC(".struct_ops.link")
struct test_ops___v2 map_for_new = {
.test_1 = (void *)foo,
.does_not_exist = (void *)bar
};
Suppose program is loaded on old kernel that does not have definition
for 'does_not_exist' struct_ops member. After this commit it would be
possible to load such object file after the following tweaks:
bpf_program__set_autoload(skel->progs.bar, false);
bpf_map__set_autocreate(skel->maps.map_for_new, false);
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20240306104529.6453-4-eddyz87@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/struct_ops_module.c')
0 files changed, 0 insertions, 0 deletions