diff options
author | Andrii Nakryiko <[email protected]> | 2024-04-27 20:09:53 -0700 |
---|---|---|
committer | Martin KaFai Lau <[email protected]> | 2024-04-29 16:46:06 -0700 |
commit | f973fccd43d34b096077d5d21d051ef75b22a7ea (patch) | |
tree | 9cd7d6ace7c93aedc960a429e91ed40d45e8bcf4 /tools/lib/bpf | |
parent | cfd3bfe9507b4aa39f7e86772e60b50b799e490e (diff) |
libbpf: handle nulled-out program in struct_ops correctly
If struct_ops has one of program callbacks set declaratively and host
kernel is old and doesn't support this callback, libbpf will allow to
load such struct_ops as long as that callback was explicitly nulled-out
(presumably through skeleton). This is all working correctly, except we
won't reset corresponding program slot to NULL before bailing out, which
will lead to libbpf not detecting that BPF program has to be not
auto-loaded. Fix this by unconditionally resetting corresponding program
slot to NULL.
Fixes: c911fc61a7ce ("libbpf: Skip zeroed or null fields if not found in the kernel type.")
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'tools/lib/bpf')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 97eb6e5dd7c8..898d5d34ecea 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -1148,6 +1148,7 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map) * presented in the kernel BTF. */ if (libbpf_is_mem_zeroed(mdata, msize)) { + st_ops->progs[i] = NULL; pr_info("struct_ops %s: member %s not found in kernel, skipping it as it's set to zero\n", map->name, mname); continue; |