Centos-kernel-stream-9/tools/bpf/bpftool/Documentation/bpftool-iter.rst

73 lines
2.0 KiB
ReStructuredText
Raw Normal View History

.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2020-05-09 17:59:20 +00:00
============
bpftool-iter
============
-------------------------------------------------------------------------------
tool to create BPF iterators
-------------------------------------------------------------------------------
:Manual section: 8
bpftool: Update doc (use susbtitutions) and test_bpftool_synctypes.py Bugzilla: https://bugzilla.redhat.com/2069046 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit b623181520404ef48f7421333561bd294c6c6b11 Author: Quentin Monnet <quentin@isovalent.com> Date: Mon Nov 15 22:58:43 2021 +0000 bpftool: Update doc (use susbtitutions) and test_bpftool_synctypes.py test_bpftool_synctypes.py helps detecting inconsistencies in bpftool between the different list of types and options scattered in the sources, the documentation, and the bash completion. For options that apply to all bpftool commands, the script had a hardcoded list of values, and would use them to check whether the man pages are up-to-date. When writing the script, it felt acceptable to have this list in order to avoid to open and parse bpftool's main.h every time, and because the list of global options in bpftool doesn't change so often. However, this is prone to omissions, and we recently added a new -l|--legacy option which was described in common_options.rst, but not listed in the options summary of each manual page. The script did not complain, because it keeps comparing the hardcoded list to the (now) outdated list in the header file. To address the issue, this commit brings the following changes: - Options that are common to all bpftool commands (--json, --pretty, and --debug) are moved to a dedicated file, and used in the definition of a RST substitution. This substitution is used in the sources of all the man pages. - This list of common options is updated, with the addition of the new -l|--legacy option. - The script test_bpftool_synctypes.py is updated to compare: - Options specific to a command, found in C files, for the interactive help messages, with the same specific options from the relevant man page for that command. - Common options, checked just once: the list in main.h is compared with the new list in substitutions.rst. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211115225844.33943-3-quentin@isovalent.com Signed-off-by: Artem Savkov <asavkov@redhat.com>
2022-06-10 13:01:30 +00:00
.. include:: substitutions.rst
2020-05-09 17:59:20 +00:00
SYNOPSIS
========
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
**bpftool** [*OPTIONS*] **iter** *COMMAND*
2020-05-09 17:59:20 +00:00
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
*OPTIONS* := { |COMMON_OPTIONS| }
tools: bpftool: Update and synchronise option list in doc and help msg Bugzilla: http://bugzilla.redhat.com/2041365 commit c07ba629df97b796ca7bbdfbf4748266ead27745 Author: Quentin Monnet <quentin@isovalent.com> Date: Fri Jul 30 22:54:32 2021 +0100 tools: bpftool: Update and synchronise option list in doc and help msg All bpftool commands support the options for JSON output and debug from libbpf. In addition, some commands support additional options corresponding to specific use cases. The list of options described in the man pages for the different commands are not always accurate. The messages for interactive help are mostly limited to HELP_SPEC_OPTIONS, and are even less representative of the actual set of options supported for the commands. Let's update the lists: - HELP_SPEC_OPTIONS is modified to contain the "default" options (JSON and debug), and to be extensible (no ending curly bracket). - All commands use HELP_SPEC_OPTIONS in their help message, and then complete the list with their specific options. - The lists of options in the man pages are updated. - The formatting of the list for bpftool.rst is adjusted to match formatting for the other man pages. This is for consistency, and also because it will be helpful in a future patch to automatically check that the files are synchronised. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210730215435.7095-5-quentin@isovalent.com Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-01-17 14:25:38 +00:00
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
*COMMANDS* := { **pin** | **help** }
2020-05-09 17:59:20 +00:00
ITER COMMANDS
=============
2020-05-09 17:59:20 +00:00
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
| **bpftool** **iter pin** *OBJ* *PATH* [**map** *MAP*]
| **bpftool** **iter help**
2020-05-09 17:59:20 +00:00
|
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
| *OBJ* := /a/file/of/bpf_iter_target.o
| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
2020-05-09 17:59:20 +00:00
DESCRIPTION
===========
bpftool iter pin *OBJ* *PATH* [map *MAP*]
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
A bpf iterator combines a kernel iterating of particular kernel data (e.g.,
tasks, bpf_maps, etc.) and a bpf program called for each kernel data object
(e.g., one task, one bpf_map, etc.). User space can *read* kernel iterator
output through *read()* syscall.
The *pin* command creates a bpf iterator from *OBJ*, and pin it to *PATH*.
The *PATH* should be located in *bpffs* mount. It must not contain a dot
character ('.'), which is reserved for future extensions of *bpffs*.
Map element bpf iterator requires an additional parameter *MAP* so bpf
program can iterate over map elements for that map. User can have a bpf
program in kernel to run with each map element, do checking, filtering,
aggregation, etc. without copying data to user space.
User can then *cat PATH* to see the bpf iterator output.
bpftool iter help
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
Print short help message.
2020-05-09 17:59:20 +00:00
OPTIONS
=======
bpftool: Use simpler indentation in source rST for documentation JIRA: https://issues.redhat.com/browse/RHEL-30773 commit f7b68543642136164ce7348945d3ada707c4e635 Author: Rameez Rehman <rameezrehman408@hotmail.com> Date: Sun Mar 31 21:03:44 2024 +0100 bpftool: Use simpler indentation in source rST for documentation The rST manual pages for bpftool would use a mix of tabs and spaces for indentation. While this is the norm in C code, this is rather unusual for rST documents, and over time we've seen many contributors use a wrong level of indentation for documentation update. Let's fix bpftool's indentation in docs once and for all: - Let's use spaces, that are more common in rST files. - Remove one level of indentation for the synopsis, the command description, and the "see also" section. As a result, all sections start with the same indentation level in the generated man page. - Rewrap the paragraphs after the changes. There is no content change in this patch, only indentation and rewrapping changes. The wrapping in the generated source files for the manual pages is changed, but the pages displayed with "man" remain the same, apart from the adjusted indentation level on relevant sections. [ Quentin: rebased on bpf-next, removed indent level for command description and options, updated synopsis, command summary, and "see also" sections. ] Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com> Signed-off-by: Quentin Monnet <qmo@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-10-23 10:44:02 +00:00
.. include:: common_options.rst
2020-05-09 17:59:20 +00:00
EXAMPLES
========
**# bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink**
::
Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
to /sys/fs/bpf/my_netlink
**# bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20**
::
Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
id 20, and pin it to /sys/fs/bpf/my_hashmap