commit | 3ef181370237f26dec5030f1b79ea2c2001148b6 | [log] [tgz] |
---|---|---|
author | Andrii Nakryiko <andrii@kernel.org> | Sat Mar 19 12:34:17 2022 -0700 |
committer | Andrii Nakryiko <andrii.nakryiko@gmail.com> | Sat Mar 19 23:08:50 2022 -0700 |
tree | 9bf06fc1d9ca15e296ef786171c41c069d1befed | |
parent | d580bc49d1151a18d3c7b1aeb44d88adbca9a348 [diff] |
sync: latest libbpf changes from kernel Syncing latest libbpf commits from kernel repository. Baseline bpf-next commit: c344b9fc2108eeaa347c387219886cf87e520e93 Checkpoint bpf-next commit: 9492450fd28736262dea9143ebb3afc2c131ace1 Baseline bpf commit: 18b1ab7aa76bde181bdb1ab19a87fa9523c32f21 Checkpoint bpf commit: 6bd0c76bd70447aedfeafa9e1fcc249991d6c678 Delyan Kratunov (3): libbpf: .text routines are subprograms in strict mode libbpf: Init btf_{key,value}_type_id on internal map open libbpf: Add subskeleton scaffolding Guo Zhengkui (1): libbpf: Fix array_size.cocci warning Hengqi Chen (1): bpf: Fix comment for helper bpf_current_task_under_cgroup() Jiri Olsa (5): bpf: Add multi kprobe link bpf: Add cookie support to programs attached with kprobe multi link libbpf: Add libbpf_kallsyms_parse function libbpf: Add bpf_link_create support for multi kprobes libbpf: Add bpf_program__attach_kprobe_multi_opts function Martin KaFai Lau (1): bpf: Remove BPF_SKB_DELIVERY_TIME_NONE and rename s/delivery_time_/tstamp_/ Roberto Sassu (1): bpf-lsm: Introduce new helper bpf_ima_file_hash() Toke Høiland-Jørgensen (2): bpf: Add "live packet" mode for XDP in BPF_PROG_RUN libbpf: Support batch_size option to bpf_prog_test_run lic121 (1): libbpf: Unmap rings when umem deleted include/uapi/linux/bpf.h | 72 +++++--- src/bpf.c | 13 +- src/bpf.h | 12 +- src/libbpf.c | 383 ++++++++++++++++++++++++++++++++++----- src/libbpf.h | 52 ++++++ src/libbpf.map | 3 + src/libbpf_internal.h | 5 + src/libbpf_legacy.h | 4 + src/xsk.c | 15 +- 9 files changed, 487 insertions(+), 72 deletions(-) -- 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.
See also “BPF CO-RE reference guide” for the coverage of practical aspects of building BPF CO-RE applications and “BPF CO-RE” for general introduction into BPF portability issues and BPF CO-RE origins.
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
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:
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:
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