]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Streamline bpf_attr and perf_event_attr initialization
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 16 Aug 2022 00:19:27 +0000 (17:19 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 17 Aug 2022 20:42:10 +0000 (22:42 +0200)
commit67ea1d7c65d226010f10014d1e4a7262310158ef
tree767299922c7899e6a698bd46f63bcf09c175103c
parentd2c41681f2ccf20e91753bdfe25835f9883b9c7b
libbpf: Streamline bpf_attr and perf_event_attr initialization

Make sure that entire libbpf code base is initializing bpf_attr and
perf_event_attr with memset(0). Also for bpf_attr make sure we
clear and pass to kernel only relevant parts of bpf_attr. bpf_attr is
a huge union of independent sub-command attributes, so there is no need
to clear and pass entire union bpf_attr, which over time grows quite
a lot and for most commands this growth is completely irrelevant.

Few cases where we were relying on compiler initialization of BPF UAPI
structs (like bpf_prog_info, bpf_map_info, etc) with `= {};` were
switched to memset(0) pattern for future-proofing.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/bpf/20220816001929.369487-3-andrii@kernel.org
tools/lib/bpf/bpf.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/netlink.c
tools/lib/bpf/skel_internal.h