diff options
| author | Eduard Zingerman <[email protected]> | 2024-03-06 12:45:22 +0200 | 
|---|---|---|
| committer | Andrii Nakryiko <[email protected]> | 2024-03-06 15:18:15 -0800 | 
| commit | fe9d049c3da06373a1a35914b7f695509e4cb1fe (patch) | |
| tree | 6c12581c804da865f4d0f7bf2b224e1d0543f90a /tools/testing/selftests/bpf/prog_tests/struct_ops_autocreate.c | |
| parent | 1863acccdf936c6917398165ca97e252d02fa6dd (diff) | |
libbpf: Sync progs autoload with maps autocreate for struct_ops maps
Automatically select which struct_ops programs to load depending on
which struct_ops maps are selected for automatic creation.
E.g. for the BPF code below:
    SEC("struct_ops/test_1") int BPF_PROG(foo) { ... }
    SEC("struct_ops/test_2") int BPF_PROG(bar) { ... }
    SEC(".struct_ops.link")
    struct test_ops___v1 A = {
        .foo = (void *)foo
    };
    SEC(".struct_ops.link")
    struct test_ops___v2 B = {
        .foo = (void *)foo,
        .bar = (void *)bar,
    };
And the following libbpf API calls:
    bpf_map__set_autocreate(skel->maps.A, true);
    bpf_map__set_autocreate(skel->maps.B, false);
The autoload would be enabled for program 'foo' and disabled for
program 'bar'.
During load, for each struct_ops program P, referenced from some
struct_ops map M:
- set P.autoload = true if M.autocreate is true for some M;
- set P.autoload = false if M.autocreate is false for all M;
- don't change P.autoload, if P is not referenced from any map.
Do this after bpf_object__init_kern_struct_ops_maps()
to make sure that shadow vars assignment is done.
Signed-off-by: Eduard Zingerman <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/struct_ops_autocreate.c')
0 files changed, 0 insertions, 0 deletions