]> 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)
commitae64650d80ba4221f9e901911992479500a85dca
treec90853607b25de230a8a343f38b222d66f72ec0e
parentb03e193184ce10bc9e3a6963947229789f74ec6f
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