]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Handle missing BPF_OBJ_GET_INFO_BY_FD gracefully in perf_buffer
authorAndrii Nakryiko <andriin@fb.com>
Wed, 8 Jul 2020 01:53:17 +0000 (18:53 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 8 Jul 2020 22:44:45 +0000 (00:44 +0200)
commit43f6d9f223bc867f69461ec5a535ee85bfa0da77
treec90853607b25de230a8a343f38b222d66f72ec0e
parenteb1c980e3919e4d4cdf05f34f48ab3adae3d9c0d
libbpf: Handle missing BPF_OBJ_GET_INFO_BY_FD gracefully in perf_buffer

perf_buffer__new() is relying on BPF_OBJ_GET_INFO_BY_FD availability for few
sanity checks. OBJ_GET_INFO for maps is actually much more recent feature than
perf_buffer support itself, so this causes unnecessary problems on old kernels
before BPF_OBJ_GET_INFO_BY_FD was added.

This patch makes those sanity checks optional and just assumes best if command
is not supported. If user specified something incorrectly (e.g., wrong map
type), kernel will reject it later anyway, except user won't get a nice
explanation as to why it failed. This seems like a good trade off for
supporting perf_buffer on old kernels.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200708015318.3827358-6-andriin@fb.com
tools/lib/bpf/libbpf.c