-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bpf-libbpf-old-kernel'
Andrii Nakryiko says: ==================== 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. ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
- Loading branch information
Showing
8 changed files
with
167 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Copyright (c) 2020 Facebook | ||
#define _GNU_SOURCE | ||
#include <test_progs.h> | ||
#include "test_core_retro.skel.h" | ||
|
||
void test_core_retro(void) | ||
{ | ||
int err, zero = 0, res, duration = 0; | ||
struct test_core_retro *skel; | ||
|
||
/* load program */ | ||
skel = test_core_retro__open_and_load(); | ||
if (CHECK(!skel, "skel_load", "skeleton open/load failed\n")) | ||
goto out_close; | ||
|
||
/* attach probe */ | ||
err = test_core_retro__attach(skel); | ||
if (CHECK(err, "attach_kprobe", "err %d\n", err)) | ||
goto out_close; | ||
|
||
/* trigger */ | ||
usleep(1); | ||
|
||
err = bpf_map_lookup_elem(bpf_map__fd(skel->maps.results), &zero, &res); | ||
if (CHECK(err, "map_lookup", "failed to lookup result: %d\n", errno)) | ||
goto out_close; | ||
|
||
CHECK(res != getpid(), "pid_check", "got %d != exp %d\n", res, getpid()); | ||
|
||
out_close: | ||
test_core_retro__destroy(skel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.