Skip to content

Commit be31582

Browse files
committed
Andrii Nakryiko says: ==================== bpf-next 2021-12-10 v2 We've added 115 non-merge commits during the last 26 day(s) which contain a total of 182 files changed, 5747 insertions(+), 2564 deletions(-). The main changes are: 1) Various samples fixes, from Alexander Lobakin. 2) BPF CO-RE support in kernel and light skeleton, from Alexei Starovoitov. 3) A batch of new unified APIs for libbpf, logging improvements, version querying, etc. Also a batch of old deprecations for old APIs and various bug fixes, in preparation for libbpf 1.0, from Andrii Nakryiko. 4) BPF documentation reorganization and improvements, from Christoph Hellwig and Dave Tucker. 5) Support for declarative initialization of BPF_MAP_TYPE_PROG_ARRAY in libbpf, from Hengqi Chen. 6) Verifier log fixes, from Hou Tao. 7) Runtime-bounded loops support with bpf_loop() helper, from Joanne Koong. 8) Extend branch record capturing to all platforms that support it, from Kajol Jain. 9) Light skeleton codegen improvements, from Kumar Kartikeya Dwivedi. 10) bpftool doc-generating script improvements, from Quentin Monnet. 11) Two libbpf v0.6 bug fixes, from Shuyi Cheng and Vincent Minet. 12) Deprecation warning fix for perf/bpf_counter, from Song Liu. 13) MAX_TAIL_CALL_CNT unification and MIPS build fix for libbpf, from Tiezhu Yang. 14) BTF_KING_TYPE_TAG follow-up fixes, from Yonghong Song. 15) Selftests fixes and improvements, from Ilya Leoshkevich, Jean-Philippe Brucker, Jiri Olsa, Maxim Mikityanskiy, Tirthendu Sarkar, Yucong Sun, and others. * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (115 commits) libbpf: Add "bool skipped" to struct bpf_map libbpf: Fix typo in btf__dedup@LIBBPF_0.0.2 definition bpftool: Switch bpf_object__load_xattr() to bpf_object__load() selftests/bpf: Remove the only use of deprecated bpf_object__load_xattr() selftests/bpf: Add test for libbpf's custom log_buf behavior selftests/bpf: Replace all uses of bpf_load_btf() with bpf_btf_load() libbpf: Deprecate bpf_object__load_xattr() libbpf: Add per-program log buffer setter and getter libbpf: Preserve kernel error code and remove kprobe prog type guessing libbpf: Improve logging around BPF program loading libbpf: Allow passing user log setting through bpf_object_open_opts libbpf: Allow passing preallocated log_buf when loading BTF into kernel libbpf: Add OPTS-based bpf_btf_load() API libbpf: Fix bpf_prog_load() log_buf logic for log_level 0 samples/bpf: Remove unneeded variable bpf: Remove redundant assignment to pointer t selftests/bpf: Fix a compilation warning perf/bpf_counter: Use bpf_map_create instead of bpf_create_map samples: bpf: Fix 'unknown warning group' build warning on Clang samples: bpf: Fix xdp_sample_user.o linking with Clang ... ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents db10415 + 229fae3 commit be31582

File tree

181 files changed

+5747
-2562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+5747
-2562
lines changed

Documentation/bpf/btf.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ BPF Type Format (BTF)
33
=====================
44

55
1. Introduction
6-
***************
6+
===============
77

88
BTF (BPF Type Format) is the metadata format which encodes the debug info
99
related to BPF program/map. The name BTF was used initially to describe data
@@ -30,7 +30,7 @@ sections are discussed in details in :ref:`BTF_Type_String`.
3030
.. _BTF_Type_String:
3131

3232
2. BTF Type and String Encoding
33-
*******************************
33+
===============================
3434

3535
The file ``include/uapi/linux/btf.h`` provides high-level definition of how
3636
types/strings are encoded.
@@ -57,13 +57,13 @@ little-endian target. The ``btf_header`` is designed to be extensible with
5757
generated.
5858

5959
2.1 String Encoding
60-
===================
60+
-------------------
6161

6262
The first string in the string section must be a null string. The rest of
6363
string table is a concatenation of other null-terminated strings.
6464

6565
2.2 Type Encoding
66-
=================
66+
-----------------
6767

6868
The type id ``0`` is reserved for ``void`` type. The type section is parsed
6969
sequentially and type id is assigned to each recognized type starting from id
@@ -504,7 +504,7 @@ valid index (starting from 0) pointing to a member or an argument.
504504
* ``type``: the type with ``btf_type_tag`` attribute
505505

506506
3. BTF Kernel API
507-
*****************
507+
=================
508508

509509
The following bpf syscall command involves BTF:
510510
* BPF_BTF_LOAD: load a blob of BTF data into kernel
@@ -547,14 +547,14 @@ The workflow typically looks like:
547547

548548

549549
3.1 BPF_BTF_LOAD
550-
================
550+
----------------
551551

552552
Load a blob of BTF data into kernel. A blob of data, described in
553553
:ref:`BTF_Type_String`, can be directly loaded into the kernel. A ``btf_fd``
554554
is returned to a userspace.
555555

556556
3.2 BPF_MAP_CREATE
557-
==================
557+
------------------
558558

559559
A map can be created with ``btf_fd`` and specified key/value type id.::
560560

@@ -581,7 +581,7 @@ automatically.
581581
.. _BPF_Prog_Load:
582582

583583
3.3 BPF_PROG_LOAD
584-
=================
584+
-----------------
585585

586586
During prog_load, func_info and line_info can be passed to kernel with proper
587587
values for the following attributes:
@@ -631,7 +631,7 @@ For line_info, the line number and column number are defined as below:
631631
#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
632632

633633
3.4 BPF_{PROG,MAP}_GET_NEXT_ID
634-
==============================
634+
------------------------------
635635

636636
In kernel, every loaded program, map or btf has a unique id. The id won't
637637
change during the lifetime of a program, map, or btf.
@@ -641,13 +641,13 @@ each command, to user space, for bpf program or maps, respectively, so an
641641
inspection tool can inspect all programs and maps.
642642

643643
3.5 BPF_{PROG,MAP}_GET_FD_BY_ID
644-
===============================
644+
-------------------------------
645645

646646
An introspection tool cannot use id to get details about program or maps.
647647
A file descriptor needs to be obtained first for reference-counting purpose.
648648

649649
3.6 BPF_OBJ_GET_INFO_BY_FD
650-
==========================
650+
--------------------------
651651

652652
Once a program/map fd is acquired, an introspection tool can get the detailed
653653
information from kernel about this fd, some of which are BTF-related. For
@@ -656,7 +656,7 @@ example, ``bpf_map_info`` returns ``btf_id`` and key/value type ids.
656656
bpf byte codes, and jited_line_info.
657657

658658
3.7 BPF_BTF_GET_FD_BY_ID
659-
========================
659+
------------------------
660660

661661
With ``btf_id`` obtained in ``bpf_map_info`` and ``bpf_prog_info``, bpf
662662
syscall command BPF_BTF_GET_FD_BY_ID can retrieve a btf fd. Then, with
@@ -668,18 +668,18 @@ tool has full btf knowledge and is able to pretty print map key/values, dump
668668
func signatures and line info, along with byte/jit codes.
669669

670670
4. ELF File Format Interface
671-
****************************
671+
============================
672672

673673
4.1 .BTF section
674-
================
674+
----------------
675675

676676
The .BTF section contains type and string data. The format of this section is
677677
same as the one describe in :ref:`BTF_Type_String`.
678678

679679
.. _BTF_Ext_Section:
680680

681681
4.2 .BTF.ext section
682-
====================
682+
--------------------
683683

684684
The .BTF.ext section encodes func_info and line_info which needs loader
685685
manipulation before loading into the kernel.
@@ -743,7 +743,7 @@ bpf_insn``. For ELF API, the ``insn_off`` is the byte offset from the
743743
beginning of section (``btf_ext_info_sec->sec_name_off``).
744744

745745
4.2 .BTF_ids section
746-
====================
746+
--------------------
747747

748748
The .BTF_ids section encodes BTF ID values that are used within the kernel.
749749

@@ -804,10 +804,10 @@ All the BTF ID lists and sets are compiled in the .BTF_ids section and
804804
resolved during the linking phase of kernel build by ``resolve_btfids`` tool.
805805

806806
5. Using BTF
807-
************
807+
============
808808

809809
5.1 bpftool map pretty print
810-
============================
810+
----------------------------
811811

812812
With BTF, the map key/value can be printed based on fields rather than simply
813813
raw bytes. This is especially valuable for large structure or if your data
@@ -849,7 +849,7 @@ bpftool is able to pretty print like below:
849849
]
850850

851851
5.2 bpftool prog dump
852-
=====================
852+
---------------------
853853

854854
The following is an example showing how func_info and line_info can help prog
855855
dump with better kernel symbol names, function prototypes and line
@@ -883,7 +883,7 @@ information.::
883883
[...]
884884

885885
5.3 Verifier Log
886-
================
886+
----------------
887887

888888
The following is an example of how line_info can help debugging verification
889889
failure.::
@@ -909,7 +909,7 @@ failure.::
909909
R2 offset is outside of the packet
910910

911911
6. BTF Generation
912-
*****************
912+
=================
913913

914914
You need latest pahole
915915

@@ -1016,6 +1016,6 @@ format.::
10161016
.long 8206 # Line 8 Col 14
10171017

10181018
7. Testing
1019-
**********
1019+
==========
10201020

10211021
Kernel bpf selftest `test_btf.c` provides extensive set of BTF-related tests.

Documentation/bpf/faq.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
================================
2+
Frequently asked questions (FAQ)
3+
================================
4+
5+
Two sets of Questions and Answers (Q&A) are maintained.
6+
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
bpf_design_QA
11+
bpf_devel_QA

Documentation/bpf/helpers.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Helper functions
2+
================
3+
4+
* `bpf-helpers(7)`_ maintains a list of helpers available to eBPF programs.
5+
6+
.. Links
7+
.. _bpf-helpers(7): https://man7.org/linux/man-pages/man7/bpf-helpers.7.html

Documentation/bpf/index.rst

Lines changed: 15 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,104 +5,32 @@ BPF Documentation
55
This directory contains documentation for the BPF (Berkeley Packet
66
Filter) facility, with a focus on the extended BPF version (eBPF).
77

8-
This kernel side documentation is still work in progress. The main
9-
textual documentation is (for historical reasons) described in
10-
:ref:`networking-filter`, which describe both classical and extended
11-
BPF instruction-set.
8+
This kernel side documentation is still work in progress.
129
The Cilium project also maintains a `BPF and XDP Reference Guide`_
1310
that goes into great technical depth about the BPF Architecture.
1411

15-
libbpf
16-
======
17-
18-
Documentation/bpf/libbpf/index.rst is a userspace library for loading and interacting with bpf programs.
19-
20-
BPF Type Format (BTF)
21-
=====================
22-
2312
.. toctree::
2413
:maxdepth: 1
2514

15+
instruction-set
16+
verifier
17+
libbpf/index
2618
btf
27-
28-
29-
Frequently asked questions (FAQ)
30-
================================
31-
32-
Two sets of Questions and Answers (Q&A) are maintained.
33-
34-
.. toctree::
35-
:maxdepth: 1
36-
37-
bpf_design_QA
38-
bpf_devel_QA
39-
40-
Syscall API
41-
===========
42-
43-
The primary info for the bpf syscall is available in the `man-pages`_
44-
for `bpf(2)`_. For more information about the userspace API, see
45-
Documentation/userspace-api/ebpf/index.rst.
46-
47-
Helper functions
48-
================
49-
50-
* `bpf-helpers(7)`_ maintains a list of helpers available to eBPF programs.
51-
52-
53-
Program types
54-
=============
55-
56-
.. toctree::
57-
:maxdepth: 1
58-
59-
prog_cgroup_sockopt
60-
prog_cgroup_sysctl
61-
prog_flow_dissector
62-
bpf_lsm
63-
prog_sk_lookup
64-
65-
66-
Map types
67-
=========
68-
69-
.. toctree::
70-
:maxdepth: 1
71-
72-
map_cgroup_storage
73-
74-
75-
Testing and debugging BPF
76-
=========================
77-
78-
.. toctree::
79-
:maxdepth: 1
80-
81-
drgn
82-
s390
83-
84-
85-
Licensing
86-
=========
87-
88-
.. toctree::
89-
:maxdepth: 1
90-
19+
faq
20+
syscall_api
21+
helpers
22+
programs
23+
maps
9124
bpf_licensing
25+
test_debug
26+
other
9227

28+
.. only:: subproject and html
9329

94-
Other
95-
=====
96-
97-
.. toctree::
98-
:maxdepth: 1
30+
Indices
31+
=======
9932

100-
ringbuf
101-
llvm_reloc
33+
* :ref:`genindex`
10234

10335
.. Links:
104-
.. _networking-filter: ../networking/filter.rst
105-
.. _man-pages: https://www.kernel.org/doc/man-pages/
106-
.. _bpf(2): https://man7.org/linux/man-pages/man2/bpf.2.html
107-
.. _bpf-helpers(7): https://man7.org/linux/man-pages/man7/bpf-helpers.7.html
10836
.. _BPF and XDP Reference Guide: https://docs.cilium.io/en/latest/bpf/

0 commit comments

Comments
 (0)