netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andriin@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>, <ast@fb.com>,
	<daniel@iogearbox.net>
Cc: <andrii.nakryiko@gmail.com>, <kernel-team@fb.com>,
	Andrii Nakryiko <andriin@fb.com>, Matthew Lim <matthewlim@fb.com>
Subject: [PATCH bpf-next 0/6] Improve libbpf support of old kernels
Date: Tue, 7 Jul 2020 18:53:12 -0700	[thread overview]
Message-ID: <20200708015318.3827358-1-andriin@fb.com> (raw)

This patch set improves libbpf's support of old kernels, missing features like
BTF support, global variables support, etc.

Most critical one is a silent drop of CO-RE relocations if libbpf fails to
load BTF (despite sanitization efforts). This is frequently the case for
kernels that have no BTF support whatsoever. There are still useful BPF
applications that could work on such kernels and do rely on CO-RE. To that
end, this series revamps the way BTF is handled in libbpf. Failure to load BTF
into kernel doesn't prevent libbpf from using BTF in its full capability
(e.g., for CO-RE relocations) internally.

Another issue that was identified was reliance of perf_buffer__new() on
BPF_OBJ_GET_INFO_BY_FD command, which is more recent that perf_buffer support
itself. Furthermore, BPF_OBJ_GET_INFO_BY_FD is needed just for some sanity
checks to provide better user errors, so could be safely omitted if kernel
doesn't provide it.

Perf_buffer selftest was adjusted to use skeleton, instead of bpf_prog_load().
The latter uses BPF_F_TEST_RND_HI32 flag, which is a relatively recent
addition and unnecessary fails selftest in libbpf's Travis CI tests. By using
skeleton we both get a shorter selftest and it work on pretty ancient kernels,
giving better libbpf test coverage.

One new selftest was added that relies on basic CO-RE features, but otherwise
doesn't expect any recent features (like global variables) from kernel. Again,
it's good to have better coverage of old kernels in libbpf testing.

Cc: Matthew Lim <matthewlim@fb.com>

Andrii Nakryiko (6):
  libbpf: make BTF finalization strict
  libbpf: add btf__set_fd() for more control over loaded BTF FD
  libbpf: improve BTF sanitization handling
  selftests/bpf: add test relying only on CO-RE and no recent kernel
    features
  libbpf: handle missing BPF_OBJ_GET_INFO_BY_FD gracefully in
    perf_buffer
  selftests/bpf: switch perf_buffer test to tracepoint and skeleton

 tools/lib/bpf/btf.c                           |   7 +-
 tools/lib/bpf/btf.h                           |   1 +
 tools/lib/bpf/libbpf.c                        | 150 ++++++++++--------
 tools/lib/bpf/libbpf.map                      |   1 +
 .../selftests/bpf/prog_tests/core_retro.c     |  33 ++++
 .../selftests/bpf/prog_tests/perf_buffer.c    |  42 ++---
 .../selftests/bpf/progs/test_core_retro.c     |  30 ++++
 .../selftests/bpf/progs/test_perf_buffer.c    |   4 +-
 8 files changed, 167 insertions(+), 101 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/core_retro.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_core_retro.c

-- 
2.24.1


             reply	other threads:[~2020-07-08  1:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08  1:53 Andrii Nakryiko [this message]
2020-07-08  1:53 ` [PATCH bpf-next 1/6] libbpf: make BTF finalization strict Andrii Nakryiko
2020-07-08  1:53 ` [PATCH bpf-next 2/6] libbpf: add btf__set_fd() for more control over loaded BTF FD Andrii Nakryiko
2020-07-08  1:53 ` [PATCH bpf-next 3/6] libbpf: improve BTF sanitization handling Andrii Nakryiko
2020-07-08  1:53 ` [PATCH bpf-next 4/6] selftests/bpf: add test relying only on CO-RE and no recent kernel features Andrii Nakryiko
2020-07-08  1:53 ` [PATCH bpf-next 5/6] libbpf: handle missing BPF_OBJ_GET_INFO_BY_FD gracefully in perf_buffer Andrii Nakryiko
2020-07-08  1:53 ` [PATCH bpf-next 6/6] selftests/bpf: switch perf_buffer test to tracepoint and skeleton Andrii Nakryiko
2020-07-08 22:58 ` [PATCH bpf-next 0/6] Improve libbpf support of old kernels Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708015318.3827358-1-andriin@fb.com \
    --to=andriin@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=matthewlim@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).