Lines Matching +full:pre +full:- +full:programs

1 .. SPDX-License-Identifier: GPL-2.0
7 libbpf is a C-based library containing a BPF loader that takes compiled BPF
9 heavy lifting of loading, verifying, and attaching BPF programs to various
13 The following are the high-level features supported by libbpf:
15 * Provides high-level and low-level APIs for user space programs to interact
16 with BPF programs. The low-level APIs wrap all the bpf system call
17 functionality, which is useful when users need more fine-grained control
18 over the interactions between user space and BPF programs.
20 The skeleton file simplifies the process for the user space programs to access
21 global variables and work with BPF programs.
22 * Provides BPF-side APIS, including BPF helper definitions, BPF maps support,
24 * Supports BPF CO-RE mechanism, enabling BPF developers to write portable
25 BPF programs that can be compiled once and run across different kernel
35 A BPF application consists of one or more BPF programs (either cooperating or
37 variables are shared between all BPF programs, which allows them to cooperate on
38 a common set of data. libbpf provides APIs that user space programs can use to
39 manipulate the BPF programs by triggering different phases of a BPF application
46 object file and discovers BPF maps, BPF programs, and global variables. After
48 (setting BPF program types, if necessary; pre-setting initial values for
52 maps, resolves various relocations, and verifies and loads BPF programs into
59 attaches BPF programs to various BPF hook points (e.g., tracepoints, kprobes,
61 phase, BPF programs perform useful work such as processing
66 libbpf detaches BPF programs and unloads them from the kernel. BPF maps are
74 simplify code for manipulating BPF programs from user space. Skeleton code
87 * ``<name>__attach()`` – attaches all auto-attachable BPF programs (it’s
89 * ``<name>__destroy()`` – detaches all BPF programs and
92 Using the skeleton code is the recommended way to work with bpf programs. Keep
99 ---------------------------------------
101 * BPF skeleton provides an interface for user space programs to work with BPF
103 into user space. The struct interface allows user space programs to initialize
104 BPF programs before the BPF load phase and fetch and update data from user
108 available maps, programs, etc. BPF skeleton provides direct access to all the
109 BPF maps and BPF programs as struct fields. This eliminates the need for
110 string-based lookups with ``bpf_object_find_map_by_name()`` and
112 code and user-space code getting out of sync.
120 libbpf provides BPF-side APIs that BPF programs can use to interact with the
127 the return value, see the `bpf-helpers
128 <https://man7.org/linux/man-pages/man7/bpf-helpers.7.html>`_ man page.
130 BPF CO-RE (Compile Once – Run Everywhere)
133 BPF programs work in the kernel space and have access to kernel memory and data
140 libbpf steps up the BPF program portability by supporting the BPF CO-RE concept.
141 BPF CO-RE brings together BTF type information, libbpf, and the compiler to
145 To make BPF programs portable libbpf relies on the BTF type information of the
146 running kernel. Kernel also exposes this self-describing authoritative BTF
158 ``vmlinux.h`` in your BPF program eliminates dependency on system-wide kernel
161 libbpf enables portability of BPF programs by looking at the BPF program’s
166 specific kernel on the host. BPF CO-RE concept thus eliminates overhead
172 ``task_struct`` using BPF CO-RE and libbf. The basic helper to read a field in a
173 CO-RE relocatable manner is ``bpf_core_read(dst, sz, src)``, which will read
177 .. code-block:: C
178 :emphasize-lines: 6
185 err = bpf_core_read(&parent_task, sizeof(void *), &task->parent);
190 /* parent_task contains the value of task->parent pointer */
204 Check out the `libbpf-bootstrap <https://github.com/libbpf/libbpf-bootstrap>`_
215 `Libbpf-rs <https://github.com/libbpf/libbpf-rs>`_ library instead of bindgen
216 bindings directly to libbpf. Libbpf-rs wraps libbpf functionality in
217 Rust-idiomatic interfaces and provides libbpf-cargo plugin to handle BPF code
218 compilation and skeleton generation. Using Libbpf-rs will make building user
236 …tps://libbpf.readthedocs.io/en/latest/libbpf_naming_convention.html#api-documentation-convention>`_