<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/tools/bpf/bpftool/Documentation, branch master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/tools/bpf/bpftool/Documentation?h=master</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/tools/bpf/bpftool/Documentation?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-09-21T23:24:17Z</updated>
<entry>
<title>bpf: Define new BPF_MAP_TYPE_USER_RINGBUF map type</title>
<updated>2022-09-21T23:24:17Z</updated>
<author>
<name>David Vernet</name>
<email>void@manifault.com</email>
</author>
<published>2022-09-20T00:00:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=583c1f420173f7d84413a1a1fbf5109d798b4faa'/>
<id>urn:sha1:583c1f420173f7d84413a1a1fbf5109d798b4faa</id>
<content type='text'>
We want to support a ringbuf map type where samples are published from
user-space, to be consumed by BPF programs. BPF currently supports a
kernel -&gt; user-space circular ring buffer via the BPF_MAP_TYPE_RINGBUF
map type.  We'll need to define a new map type for user-space -&gt; kernel,
as none of the helpers exported for BPF_MAP_TYPE_RINGBUF will apply
to a user-space producer ring buffer, and we'll want to add one or
more helper functions that would not apply for a kernel-producer
ring buffer.

This patch therefore adds a new BPF_MAP_TYPE_USER_RINGBUF map type
definition. The map type is useless in its current form, as there is no
way to access or use it for anything until we one or more BPF helpers. A
follow-on patch will therefore add a new helper function that allows BPF
programs to run callbacks on samples that are published to the ring
buffer.

Signed-off-by: David Vernet &lt;void@manifault.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220920000100.477320-2-void@manifault.com
</content>
</entry>
<entry>
<title>bpftool: Rename "bpftool feature list" into "... feature list_builtins"</title>
<updated>2022-07-05T09:53:54Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2022-07-01T09:38:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=990a6194f7e16cc23334892287f32899e241b1a9'/>
<id>urn:sha1:990a6194f7e16cc23334892287f32899e241b1a9</id>
<content type='text'>
To make it more explicit that the features listed with "bpftool feature
list" are known to bpftool, but not necessary available on the system
(as opposed to the probed features), rename the "feature list" command
into "feature list_builtins".

Note that "bpftool feature list" still works as before given that we
recognise arguments from their prefixes; but the real name of the
subcommand, in particular as displayed in the man page or the
interactive help, will now include "_builtins".

Since we update the bash completion accordingly, let's also take this
chance to redirect error output to /dev/null in the completion script,
to avoid displaying unexpected error messages when users attempt to
tab-complete.

Suggested-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20220701093805.16920-1-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpftool: Add feature list (prog/map/link/attach types, helpers)</title>
<updated>2022-06-30T14:17:03Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2022-06-29T20:36:36Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=27b3f70553432114b3d26f4d9c72cf02f38b84ee'/>
<id>urn:sha1:27b3f70553432114b3d26f4d9c72cf02f38b84ee</id>
<content type='text'>
Add a "bpftool feature list" subcommand to list BPF "features".
Contrarily to "bpftool feature probe", this is not about the features
available on the system. Instead, it lists all features known to bpftool
from compilation time; in other words, all program, map, attach, link
types known to the libbpf version in use, and all helpers found in the
UAPI BPF header.

The first use case for this feature is bash completion: running the
command provides a list of types that can be used to produce the list of
candidate map types, for example.

Now that bpftool uses "standard" names provided by libbpf for the
program, map, link, and attach types, having the ability to list these
types and helpers could also be useful in scripts to loop over existing
items.

Sample output:

    # bpftool feature list prog_types | grep -vw unspec | head -n 6
    socket_filter
    kprobe
    sched_cls
    sched_act
    tracepoint
    xdp

    # bpftool -p feature list map_types | jq '.[1]'
    "hash"

    # bpftool feature list attach_types | grep '^cgroup_'
    cgroup_inet_ingress
    cgroup_inet_egress
    [...]
    cgroup_inet_sock_release

    # bpftool feature list helpers | grep -vw bpf_unspec | wc -l
    207

The "unspec" types and helpers are not filtered out by bpftool, so as to
remain closer to the enums, and to preserve the indices in the JSON
arrays (e.g. "hash" at index 1 == BPF_MAP_TYPE_HASH in map types list).

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Daniel Müller &lt;deso@posteo.net&gt;
Link: https://lore.kernel.org/bpf/20220629203637.138944-2-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpftool: Use libbpf_bpf_attach_type_str</title>
<updated>2022-06-02T23:26:30Z</updated>
<author>
<name>Daniel Müller</name>
<email>deso@posteo.net</email>
</author>
<published>2022-05-23T23:04:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=1ba5ad36e00f46e3f7676f5de6b87f5a2f57f1f1'/>
<id>urn:sha1:1ba5ad36e00f46e3f7676f5de6b87f5a2f57f1f1</id>
<content type='text'>
This change switches bpftool over to using the recently introduced
libbpf_bpf_attach_type_str function instead of maintaining its own
string representation for the bpf_attach_type enum.

Note that contrary to other enum types, the variant names that bpftool
maps bpf_attach_type to do not adhere a simple to follow rule. With
bpf_prog_type, for example, the textual representation can easily be
inferred by stripping the BPF_PROG_TYPE_ prefix and lowercasing the
remaining string. bpf_attach_type violates this rule for various
variants.
We decided to fix up this deficiency with this change, meaning that
bpftool uses the same textual representations as libbpf. Supporting
tests, completion scripts, and man pages have been adjusted accordingly.
However, we did add support for accepting (the now undocumented)
original attach type names when they are provided by users.

For the test (test_bpftool_synctypes.py), I have removed the enum
representation checks, because we no longer mirror the various enum
variant names in bpftool source code. For the man page, help text, and
completion script checks we are now using enum definitions from
uapi/linux/bpf.h as the source of truth directly.

Signed-off-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Link: https://lore.kernel.org/bpf/20220523230428.3077108-10-deso@posteo.net
</content>
</entry>
<entry>
<title>bpftool: Add support for subskeletons</title>
<updated>2022-03-18T06:12:39Z</updated>
<author>
<name>Delyan Kratunov</name>
<email>delyank@fb.com</email>
</author>
<published>2022-03-16T23:37:28Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=00389c58ffe993782a8ba4bb5a34a102b1f6fe24'/>
<id>urn:sha1:00389c58ffe993782a8ba4bb5a34a102b1f6fe24</id>
<content type='text'>
Subskeletons are headers which require an already loaded program to
operate.

For example, when a BPF library is linked into a larger BPF object file,
the library userspace needs a way to access its own global variables
without requiring knowledge about the larger program at build time.

As a result, subskeletons require a loaded bpf_object to open().
Further, they find their own symbols in the larger program by
walking BTF type data at run time.

At this time, programs, maps, and globals are supported through
non-owning pointers.

Signed-off-by: Delyan Kratunov &lt;delyank@fb.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/ca8a48b4841c72d285ecce82371bef4a899756cb.1647473511.git.delyank@fb.com
</content>
</entry>
<entry>
<title>bpftool: man: Add missing top level docs</title>
<updated>2022-03-15T22:51:41Z</updated>
<author>
<name>Daniel Xu</name>
<email>dxu@dxuuu.xyz</email>
</author>
<published>2022-03-13T23:19:46Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=6585abea98ae5f750358a6427f2ddf7715393f69'/>
<id>urn:sha1:6585abea98ae5f750358a6427f2ddf7715393f69</id>
<content type='text'>
The top-level (bpftool.8) man page was missing docs for a few
subcommands and their respective sub-sub-commands.

This commit brings the top level man page up to date. Note that I've
kept the ordering of the subcommands the same as in `bpftool help`.

Signed-off-by: Daniel Xu &lt;dxu@dxuuu.xyz&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/3049ef5dc509c0d1832f0a8b2dba2ccaad0af688.1647213551.git.dxu@dxuuu.xyz
</content>
</entry>
<entry>
<title>bpftool: Gen min_core_btf explanation and examples</title>
<updated>2022-02-16T18:13:21Z</updated>
<author>
<name>Rafael David Tinoco</name>
<email>rafaeldtinoco@gmail.com</email>
</author>
<published>2022-02-15T22:58:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=1d1ffbf7f0b261fd5dcac2cd40a92b9394df08f6'/>
<id>urn:sha1:1d1ffbf7f0b261fd5dcac2cd40a92b9394df08f6</id>
<content type='text'>
Add "min_core_btf" feature explanation and one example of how to use it
to bpftool-gen man page.

Signed-off-by: Mauricio Vásquez &lt;mauricio@kinvolk.io&gt;
Signed-off-by: Rafael David Tinoco &lt;rafael.tinoco@aquasec.com&gt;
Signed-off-by: Lorenzo Fontana &lt;lorenzo.fontana@elastic.co&gt;
Signed-off-by: Leonardo Di Donato &lt;leonardo.didonato@elastic.co&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220215225856.671072-7-mauricio@kinvolk.io
</content>
</entry>
<entry>
<title>bpftool: Add libbpf's version number to "bpftool version" output</title>
<updated>2022-02-11T05:09:47Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2022-02-10T10:42:36Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=61fce9693f0311949c59cc62a8fdee6e36243553'/>
<id>urn:sha1:61fce9693f0311949c59cc62a8fdee6e36243553</id>
<content type='text'>
To help users check what version of libbpf is being used with bpftool,
print the number along with bpftool's own version number.

Output:

    $ ./bpftool version
    ./bpftool v5.16.0
    using libbpf v0.7
    features: libbfd, libbpf_strict, skeletons

    $ ./bpftool version --json --pretty
    {
        "version": "5.16.0",
        "libbpf_version": "0.7",
        "features": {
            "libbfd": true,
            "libbpf_strict": true,
            "skeletons": true
        }
    }

Note that libbpf does not expose its patch number.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220210104237.11649-2-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpftool: Update doc (use susbtitutions) and test_bpftool_synctypes.py</title>
<updated>2021-11-16T12:56:22Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-11-15T22:58:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=b623181520404ef48f7421333561bd294c6c6b11'/>
<id>urn:sha1:b623181520404ef48f7421333561bd294c6c6b11</id>
<content type='text'>
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 &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20211115225844.33943-3-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpftool: Add SPDX tags to RST documentation files</title>
<updated>2021-11-16T12:56:22Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-11-15T22:58:42Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4344842836e9b9a7b695dc84956cdecd83ac02e9'/>
<id>urn:sha1:4344842836e9b9a7b695dc84956cdecd83ac02e9</id>
<content type='text'>
Most files in the kernel repository have a SPDX tags. The files that
don't have such a tag (or another license boilerplate) tend to fall
under the GPL-2.0 license. In the past, bpftool's Makefile (for example)
has been marked as GPL-2.0 for that reason, when in fact all bpftool is
dual-licensed.

To prevent a similar confusion from happening with the RST documentation
files for bpftool, let's explicitly mark all files as dual-licensed.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20211115225844.33943-2-quentin@isovalent.com
</content>
</entry>
</feed>
