mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 00:17:44 +00:00
b623181520
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
76 lines
2.1 KiB
ReStructuredText
76 lines
2.1 KiB
ReStructuredText
.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
|
|
|
============
|
|
bpftool-iter
|
|
============
|
|
-------------------------------------------------------------------------------
|
|
tool to create BPF iterators
|
|
-------------------------------------------------------------------------------
|
|
|
|
:Manual section: 8
|
|
|
|
.. include:: substitutions.rst
|
|
|
|
SYNOPSIS
|
|
========
|
|
|
|
**bpftool** [*OPTIONS*] **iter** *COMMAND*
|
|
|
|
*OPTIONS* := { |COMMON_OPTIONS| }
|
|
|
|
*COMMANDS* := { **pin** | **help** }
|
|
|
|
ITER COMMANDS
|
|
===================
|
|
|
|
| **bpftool** **iter pin** *OBJ* *PATH* [**map** *MAP*]
|
|
| **bpftool** **iter help**
|
|
|
|
|
| *OBJ* := /a/file/of/bpf_iter_target.o
|
|
| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
|
|
|
|
DESCRIPTION
|
|
===========
|
|
**bpftool iter pin** *OBJ* *PATH* [**map** *MAP*]
|
|
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**
|
|
Print short help message.
|
|
|
|
OPTIONS
|
|
=======
|
|
.. include:: common_options.rst
|
|
|
|
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
|