diff options
author | 2024-01-24 14:44:18 -0800 | |
---|---|---|
committer | 2024-01-24 16:19:39 -0800 | |
commit | c9f115564561af63db662791e9a35fcf1dfefd2a (patch) | |
tree | 6806e7bb3c8becfd5478b199b0aaa4d8543515d0 /tools/testing/selftests/bpf/prog_tests/libbpf_str.c | |
parent | selftests/bpf: Wait for the netstamp_needed_key static key to be turned on (diff) | |
download | wireguard-linux-c9f115564561af63db662791e9a35fcf1dfefd2a.tar.xz wireguard-linux-c9f115564561af63db662791e9a35fcf1dfefd2a.zip |
libbpf: Ensure undefined bpf_attr field stays 0
The commit 9e926acda0c2 ("libbpf: Find correct module BTFs for struct_ops maps and progs.")
sets a newly added field (value_type_btf_obj_fd) to -1 in libbpf when
the caller of the libbpf's bpf_map_create did not define this field by
passing a NULL "opts" or passing in a "opts" that does not cover this
new field. OPT_HAS(opts, field) is used to decide if the field is
defined or not:
((opts) && opts->sz >= offsetofend(typeof(*(opts)), field))
Once OPTS_HAS decided the field is not defined, that field should
be set to 0. For this particular new field (value_type_btf_obj_fd),
its corresponding map_flags "BPF_F_VTYPE_BTF_OBJ_FD" is not set.
Thus, the kernel does not treat it as an fd field.
Fixes: 9e926acda0c2 ("libbpf: Find correct module BTFs for struct_ops maps and progs.")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240124224418.2905133-1-martin.lau@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/libbpf_str.c')
0 files changed, 0 insertions, 0 deletions