commit | 7c6d34a2c94b972bf1ed8f68e03fe1135d7efe38 | [log] [tgz] |
---|---|---|
author | Andrii Nakryiko <andrii@kernel.org> | Mon Aug 16 22:41:57 2021 -0700 |
committer | Andrii Nakryiko <andrii.nakryiko@gmail.com> | Tue Aug 17 08:18:57 2021 -0700 |
tree | 41a4dc616231441ce67236a68ec9a2838103c722 | |
parent | a69c52bb11158bcdff89c1b034111e61eb737c9d [diff] |
sync: latest libbpf changes from kernel Syncing latest libbpf commits from kernel repository. Baseline bpf-next commit: 372642ea83ff1c71a5d567a704c912359eb59776 Checkpoint bpf-next commit: 3c3bd542ffbb2ac09631313ede46ae66660ae550 Baseline bpf commit: 7c4a22339e7ce7b6ed473a8e682da622c3a774ee Checkpoint bpf commit: 3776f3517ed94d40ff0e3851d7ce2ce17b63099f Andrii Nakryiko (8): bpf: Implement minimal BPF perf link bpf: Allow to specify user-provided bpf_cookie for BPF perf links bpf: Add bpf_get_attach_cookie() BPF helper to access bpf_cookie value libbpf: Remove unused bpf_link's destroy operation, but add dealloc libbpf: Use BPF perf link when supported by kernel libbpf: Add bpf_cookie support to bpf_link_create() API libbpf: Add bpf_cookie to perf_event, kprobe, uprobe, and tp attach APIs libbpf: Add uprobe ref counter offset support for USDT semaphores Hangbin Liu (1): bonding: add new option lacp_active Hao Luo (1): libbpf: Support weak typed ksyms. Randy Dunlap (1): libbpf, doc: Eliminate warnings in libbpf_naming_convention Robin Gögge (1): libbpf: Fix probe for BPF_PROG_TYPE_CGROUP_SOCKOPT grantseltzer (1): bpf: Reconfigure libbpf docs to remove unversioned API docs/libbpf_api.rst | 27 ---- docs/libbpf_naming_convention.rst | 4 +- include/uapi/linux/bpf.h | 25 ++++ include/uapi/linux/if_link.h | 1 + src/bpf.c | 32 ++++- src/bpf.h | 8 +- src/libbpf.c | 229 +++++++++++++++++++++++------- src/libbpf.h | 75 ++++++++-- src/libbpf.map | 3 + src/libbpf_internal.h | 32 +++-- src/libbpf_probes.c | 4 +- 11 files changed, 332 insertions(+), 108 deletions(-) delete mode 100644 docs/libbpf_api.rst -- 2.30.2
This is a mirror of bpf-next Linux source tree's tools/lib/bpf
directory plus its supporting header files.
All the gory details of syncing can be found in scripts/sync-kernel.sh
script.
Some header files in this repo (include/linux/*.h
) are reduced versions of their counterpart files at bpf-next's tools/include/linux/*.h
to make compilation successful.
Please check out libbpf-bootstrap and the companion blog post for the examples of building BPF applications with libbpf. libbpf-tools are also a good source of the real-world libbpf-based tracing tools.
All general BPF questions, including kernel functionality, libbpf APIs and their application, should be sent to bpf@vger.kernel.org mailing list. You can subscribe to it here and search its archive here. Please search the archive before asking new questions. It very well might be that this was already addressed or answered before.
bpf@vger.kernel.org is monitored by many more people and they will happily try to help you with whatever issue you have. This repository's PRs and issues should be opened only for dealing with issues pertaining to specific way this libbpf mirror repo is set up and organized.
libelf is an internal dependency of libbpf and thus it is required to link against and must be installed on the system for applications to work. pkg-config is used by default to find libelf, and the program called can be overridden with PKG_CONFIG
.
If using pkg-config
at build time is not desired, it can be disabled by setting NO_PKG_CONFIG=1
when calling make.
To build both static libbpf.a and shared libbpf.so:
$ cd src
$ make
To build only static libbpf.a library in directory build/ and install them together with libbpf headers in a staging directory root/:
$ cd src $ mkdir build root $ BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=root make install
To build both static libbpf.a and shared libbpf.so against a custom libelf dependency installed in /build/root/ and install them together with libbpf headers in a build directory /build/root/:
$ cd src $ PKG_CONFIG_PATH=/build/root/lib64/pkgconfig DESTDIR=/build/root make install
Distributions packaging libbpf from this mirror:
Benefits of packaging from the mirror over packaging from kernel sources:
Package dependencies of libbpf, package names may vary across distros:
Libbpf supports building BPF CO-RE-enabled applications, which, in contrast to BCC, do not require Clang/LLVM runtime being deployed to target servers and doesn't rely on kernel-devel headers being available.
It does rely on kernel to be built with BTF type information, though. Some major Linux distributions come with kernel BTF already built in:
If your kernel doesn‘t come with BTF built-in, you’ll need to build custom kernel. You'll need:
pahole
1.16+ tool (part of dwarves
package), which performs DWARF to BTF conversion;CONFIG_DEBUG_INFO_BTF=y
option;/sys/kernel/btf/vmlinux
file:$ ls -la /sys/kernel/btf/vmlinux -r--r--r--. 1 root root 3541561 Jun 2 18:16 /sys/kernel/btf/vmlinux
To develop and build BPF programs, you'll need Clang/LLVM 10+. The following distributions have Clang/LLVM 10+ packaged by default:
Otherwise, please make sure to update it on your system.
The following resources are useful to understand what BPF CO-RE is and how to use it:
This work is dual-licensed under BSD 2-clause license and GNU LGPL v2.1 license. You can choose between one of them if you use this work.
SPDX-License-Identifier: BSD-2-Clause OR LGPL-2.1