Important updates towards Libbpf 1.0
- a first big batch of deprecated APIs; compiler will let you know or grep for "LIBBPF_DEPRECATED". Please also double-check https://github.com/libbpf/libbpf/wiki/Libbpf-1.0-migration-guide.
- documentation for a bunch of APIs added, available on https://libbpf.readthedocs.io/en/latest/api.html;
- libbpf version APIs added: compile-time
LIBBPF_MAJOR_VERSION
/LIBBPF_MINOR_VERSION
and runtimelibbpf_major_version()
/libbpf_minor_version()
/libbpf_version_string()
; - stricter logic for
SEC()
definition handling (opt-in until libbpf v1.0); see https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#stricter-and-more-uniform-bpf-program-section-name-sec-handling for details. - function name will be used when pinning if
LIBBPF_STRICT_SEC_NAME
strict mode flag is specified;
New features and APIs:
- support custom
.rodata.*
and.data.*
data sections; bpf_program__attach_kprobe()
andbpf_program__attach_uprobe()
supports older kernels now (don't forget aboutbpf_link__destroy()
when you are done!);BPF_MAP_TYPE_PROG_ARRAY
can be initialized statically with syntax similar to map-in-map initialization (see 472c072 for an example);- libbpf-less "light" skeleton gained new capabilities and got a bunch of fixes;
- BTF support for
BTF_KIND_DECL_TAG
andBTF_KIND_TYPE_TAG
; - new
bpf_prog_load()
andbpf_map_create()
APIs supersede a whole zoo of to-be-deprecated APIs; - support for writable raw tracepoints (
SEC("raw_tp.w/...")
) added; btf__add_btf()
API for appending entire contents of BTF to another BTF object;bpf_program__insns()
andbpf_program__insn_cnt()
to access underlying BPF assembly instructions; can be used for inspection or BPF program cloning.- a bunch of older APIs (
perf_buffer__new()
,btf__dedup()
,btf_dump__new()
, etc) were modernized to use OPTS infrastructure.
BPF-side APIs and features:
- unstable BPF helpers (kernel function calls) support for kernel modules;
bpf_trace_vprintk()
helper and correspondingbpf_printk()
macro enhancements. Note,bpf_printk()
will now attempt to use static global functions, so on very old kernels this might break existing programs. Please#define BPF_NO_GLOBAL_DATA
before#include <bpf/bpf_helpers.h>
if that's the case for you.bpf_get_branch_snapshot()
helper;bpf_skc_to_unix_sock()
helper;bpf_find_vma()
helper;SEC("tc")
added as a replacement forSEC("classifier")
.
Bug fixes and compatibility improvements:
- libbpf now guarantees that all FDs for BPF programs, maps, BTFs, and links are strictly greater than 0, which is important for some BPF UAPIs;
- no need to use
__uint(key_size, ...)
for special BPF maps (e.g.,BPF_MAP_PERF_EVENT_ARRAY
). Libbpf automatically downgrades__type(key, int)
into key_size, if a map doesn't support BTF types for keys and values; - endianness fixes in
BPF_CORE_READ_BITFIELD_PROBED()
macro; btf_dump__dump_type_data()
improvements for handling unaligned data;- various fixes and improvements found though fuzzing and sanitizers.
Full Changelog: v0.5.0...v0.6.0