xref: /openbmc/linux/tools/bpf/bpftool/Documentation/bpftool-feature.rst (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
143448428SQuentin Monnet.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
243448428SQuentin Monnet
349eb7ab3SQuentin Monnet===============
449eb7ab3SQuentin Monnetbpftool-feature
549eb7ab3SQuentin Monnet===============
649eb7ab3SQuentin Monnet-------------------------------------------------------------------------------
749eb7ab3SQuentin Monnettool for inspection of eBPF-related parameters for Linux kernel or net device
849eb7ab3SQuentin Monnet-------------------------------------------------------------------------------
949eb7ab3SQuentin Monnet
1049eb7ab3SQuentin Monnet:Manual section: 8
1149eb7ab3SQuentin Monnet
12b6231815SQuentin Monnet.. include:: substitutions.rst
13b6231815SQuentin Monnet
1449eb7ab3SQuentin MonnetSYNOPSIS
1549eb7ab3SQuentin Monnet========
1649eb7ab3SQuentin Monnet
1749eb7ab3SQuentin Monnet	**bpftool** [*OPTIONS*] **feature** *COMMAND*
1849eb7ab3SQuentin Monnet
19b6231815SQuentin Monnet	*OPTIONS* := { |COMMON_OPTIONS| }
2049eb7ab3SQuentin Monnet
2149eb7ab3SQuentin Monnet	*COMMANDS* := { **probe** | **help** }
2249eb7ab3SQuentin Monnet
23a5f2d082SPrashant BholeFEATURE COMMANDS
24a5f2d082SPrashant Bhole================
2549eb7ab3SQuentin Monnet
26cf9bf714SQuentin Monnet|	**bpftool** **feature probe** [*COMPONENT*] [**full**] [**unprivileged**] [**macros** [**prefix** *PREFIX*]]
27*990a6194SQuentin Monnet|	**bpftool** **feature list_builtins** *GROUP*
2849eb7ab3SQuentin Monnet|	**bpftool** **feature help**
29f9499fedSQuentin Monnet|
30f9499fedSQuentin Monnet|	*COMPONENT* := { **kernel** | **dev** *NAME* }
3127b3f705SQuentin Monnet|	*GROUP* := { **prog_types** | **map_types** | **attach_types** | **link_types** | **helpers** }
3249eb7ab3SQuentin Monnet
3349eb7ab3SQuentin MonnetDESCRIPTION
3449eb7ab3SQuentin Monnet===========
35bcdacab6SMichal Rostecki	**bpftool feature probe** [**kernel**] [**full**] [**macros** [**prefix** *PREFIX*]]
3649eb7ab3SQuentin Monnet		  Probe the running kernel and dump a number of eBPF-related
37c8caa0bbSQuentin Monnet		  parameters, such as availability of the **bpf**\ () system call,
38f9499fedSQuentin Monnet		  JIT status, eBPF program types availability, eBPF helper
39f9499fedSQuentin Monnet		  functions availability, and more.
4049eb7ab3SQuentin Monnet
41bcdacab6SMichal Rostecki		  By default, bpftool **does not run probes** for
42bcdacab6SMichal Rostecki		  **bpf_probe_write_user**\ () and **bpf_trace_printk**\()
43bcdacab6SMichal Rostecki		  helpers which print warnings to kernel logs. To enable them
44bcdacab6SMichal Rostecki		  and run all probes, the **full** keyword should be used.
45bcdacab6SMichal Rostecki
46d267cff4SQuentin Monnet		  If the **macros** keyword (but not the **-j** option) is
47d267cff4SQuentin Monnet		  passed, a subset of the output is dumped as a list of
48d267cff4SQuentin Monnet		  **#define** macros that are ready to be included in a C
49d267cff4SQuentin Monnet		  header file, for example. If, additionally, **prefix** is
50d267cff4SQuentin Monnet		  used to define a *PREFIX*, the provided string will be used
51d267cff4SQuentin Monnet		  as a prefix to the names of the macros: this can be used to
52d267cff4SQuentin Monnet		  avoid conflicts on macro names when including the output of
53d267cff4SQuentin Monnet		  this command as a header file.
54d267cff4SQuentin Monnet
55f9499fedSQuentin Monnet		  Keyword **kernel** can be omitted. If no probe target is
56f9499fedSQuentin Monnet		  specified, probing the kernel is the default behaviour.
5749eb7ab3SQuentin Monnet
58cf9bf714SQuentin Monnet		  When the **unprivileged** keyword is used, bpftool will dump
59cf9bf714SQuentin Monnet		  only the features available to a user who does not have the
60cf9bf714SQuentin Monnet		  **CAP_SYS_ADMIN** capability set. The features available in
61cf9bf714SQuentin Monnet		  that case usually represent a small subset of the parameters
62cf9bf714SQuentin Monnet		  supported by the system. Unprivileged users MUST use the
63cf9bf714SQuentin Monnet		  **unprivileged** keyword: This is to avoid misdetection if
640b3b9ca3SQuentin Monnet		  bpftool is inadvertently run as non-root, for example. This
650b3b9ca3SQuentin Monnet		  keyword is unavailable if bpftool was compiled without
660b3b9ca3SQuentin Monnet		  libcap.
67cf9bf714SQuentin Monnet
68bcdacab6SMichal Rostecki	**bpftool feature probe dev** *NAME* [**full**] [**macros** [**prefix** *PREFIX*]]
69f9499fedSQuentin Monnet		  Probe network device for supported eBPF features and dump
70f9499fedSQuentin Monnet		  results to the console.
71f9499fedSQuentin Monnet
72bcdacab6SMichal Rostecki		  The keywords **full**, **macros** and **prefix** have the
73bcdacab6SMichal Rostecki		  same role as when probing the kernel.
74f9499fedSQuentin Monnet
75*990a6194SQuentin Monnet	**bpftool feature list_builtins** *GROUP*
7627b3f705SQuentin Monnet		  List items known to bpftool. These can be BPF program types
7727b3f705SQuentin Monnet		  (**prog_types**), BPF map types (**map_types**), attach types
7827b3f705SQuentin Monnet		  (**attach_types**), link types (**link_types**), or BPF helper
7927b3f705SQuentin Monnet		  functions (**helpers**). The command does not probe the system, but
8027b3f705SQuentin Monnet		  simply lists the elements that bpftool knows from compilation time,
8127b3f705SQuentin Monnet		  as provided from libbpf (for all object types) or from the BPF UAPI
8227b3f705SQuentin Monnet		  header (list of helpers). This can be used in scripts to iterate over
8327b3f705SQuentin Monnet		  BPF types or helpers.
8427b3f705SQuentin Monnet
8549eb7ab3SQuentin Monnet	**bpftool feature help**
8649eb7ab3SQuentin Monnet		  Print short help message.
8749eb7ab3SQuentin Monnet
8849eb7ab3SQuentin MonnetOPTIONS
8949eb7ab3SQuentin Monnet=======
90f28ef96dSQuentin Monnet	.. include:: common_options.rst
91