Commit ab0720ce authored by Andrii Nakryiko's avatar Andrii Nakryiko

Merge branch 'tools: bpftool: update, synchronise and validate types and options'

Quentin Monnet says:

====================

To work with the different program types, map types, attach types etc.
supported by eBPF, bpftool needs occasional updates to learn about the new
features supported by the kernel. When such types translate into new
keyword for the command line, updates are expected in several locations:
typically, the help message displayed from bpftool itself, the manual page,
and the bash completion file should be updated. The options used by the
different commands for bpftool should also remain synchronised at those
locations.

Several omissions have occurred in the past, and a number of types are
still missing today. This set is an attempt to improve the situation. It
brings up-to-date the lists of types or options in bpftool, and also adds a
Python script to the BPF selftests to automatically check that most of
these lists remain synchronised.

v2:
- Reformat some lines in the bash completion file.
- Do not reformat attach types, to preserve git-blame history.
- Do not call Python script from tools/testing/selftests/bpf/Makefile.
====================
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 0b846445 475a23c2
...@@ -12,7 +12,8 @@ SYNOPSIS ...@@ -12,7 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **btf** *COMMAND* **bpftool** [*OPTIONS*] **btf** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | {**-d** | **--debug** } |
{ **-B** | **--base-btf** } }
*COMMANDS* := { **dump** | **help** } *COMMANDS* := { **dump** | **help** }
...@@ -73,6 +74,20 @@ OPTIONS ...@@ -73,6 +74,20 @@ OPTIONS
======= =======
.. include:: common_options.rst .. include:: common_options.rst
-B, --base-btf *FILE*
Pass a base BTF object. Base BTF objects are typically used
with BTF objects for kernel modules. To avoid duplicating
all kernel symbols required by modules, BTF objects for
modules are "split", they are built incrementally on top of
the kernel (vmlinux) BTF object. So the base BTF reference
should usually point to the kernel BTF.
When the main BTF object to process (for example, the
module BTF to dump) is passed as a *FILE*, bpftool attempts
to autodetect the path for the base object, and passing
this option is optional. When the main BTF object is passed
through other handles, this option becomes necessary.
EXAMPLES EXAMPLES
======== ========
**# bpftool btf dump id 1226** **# bpftool btf dump id 1226**
...@@ -217,3 +232,34 @@ All the standard ways to specify map or program are supported: ...@@ -217,3 +232,34 @@ All the standard ways to specify map or program are supported:
**# bpftool btf dump prog tag b88e0a09b1d9759d** **# bpftool btf dump prog tag b88e0a09b1d9759d**
**# bpftool btf dump prog pinned /sys/fs/bpf/prog_name** **# bpftool btf dump prog pinned /sys/fs/bpf/prog_name**
|
| **# bpftool btf dump file /sys/kernel/btf/i2c_smbus**
| (or)
| **# I2C_SMBUS_ID=$(bpftool btf show -p | jq '.[] | select(.name=="i2c_smbus").id')**
| **# bpftool btf dump id ${I2C_SMBUS_ID} -B /sys/kernel/btf/vmlinux**
::
[104848] STRUCT 'i2c_smbus_alert' size=40 vlen=2
'alert' type_id=393 bits_offset=0
'ara' type_id=56050 bits_offset=256
[104849] STRUCT 'alert_data' size=12 vlen=3
'addr' type_id=16 bits_offset=0
'type' type_id=56053 bits_offset=32
'data' type_id=7 bits_offset=64
[104850] PTR '(anon)' type_id=104848
[104851] PTR '(anon)' type_id=104849
[104852] FUNC 'i2c_register_spd' type_id=84745 linkage=static
[104853] FUNC 'smbalert_driver_init' type_id=1213 linkage=static
[104854] FUNC_PROTO '(anon)' ret_type_id=18 vlen=1
'ara' type_id=56050
[104855] FUNC 'i2c_handle_smbus_alert' type_id=104854 linkage=static
[104856] FUNC 'smbalert_remove' type_id=104854 linkage=static
[104857] FUNC_PROTO '(anon)' ret_type_id=18 vlen=2
'ara' type_id=56050
'id' type_id=56056
[104858] FUNC 'smbalert_probe' type_id=104857 linkage=static
[104859] FUNC 'smbalert_work' type_id=9695 linkage=static
[104860] FUNC 'smbus_alert' type_id=71367 linkage=static
[104861] FUNC 'smbus_do_alert' type_id=84827 linkage=static
...@@ -12,7 +12,8 @@ SYNOPSIS ...@@ -12,7 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **cgroup** *COMMAND* **bpftool** [*OPTIONS*] **cgroup** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
{ **-f** | **--bpffs** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **tree** | **attach** | **detach** | **help** } { **show** | **list** | **tree** | **attach** | **detach** | **help** }
......
...@@ -12,7 +12,7 @@ SYNOPSIS ...@@ -12,7 +12,7 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **feature** *COMMAND* **bpftool** [*OPTIONS*] **feature** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*COMMANDS* := { **probe** | **help** } *COMMANDS* := { **probe** | **help** }
......
...@@ -12,7 +12,8 @@ SYNOPSIS ...@@ -12,7 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **gen** *COMMAND* **bpftool** [*OPTIONS*] **gen** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
{ **-L** | **--use-loader** } }
*COMMAND* := { **object** | **skeleton** | **help** } *COMMAND* := { **object** | **skeleton** | **help** }
...@@ -152,6 +153,12 @@ OPTIONS ...@@ -152,6 +153,12 @@ OPTIONS
======= =======
.. include:: common_options.rst .. include:: common_options.rst
-L, --use-loader
For skeletons, generate a "light" skeleton (also known as "loader"
skeleton). A light skeleton contains a loader eBPF program. It does
not use the majority of the libbpf infrastructure, and does not need
libelf.
EXAMPLES EXAMPLES
======== ========
**$ cat example1.bpf.c** **$ cat example1.bpf.c**
......
...@@ -12,6 +12,8 @@ SYNOPSIS ...@@ -12,6 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **iter** *COMMAND* **bpftool** [*OPTIONS*] **iter** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*COMMANDS* := { **pin** | **help** } *COMMANDS* := { **pin** | **help** }
ITER COMMANDS ITER COMMANDS
......
...@@ -12,7 +12,8 @@ SYNOPSIS ...@@ -12,7 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **link** *COMMAND* **bpftool** [*OPTIONS*] **link** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
{ **-f** | **--bpffs** } | { **-n** | **--nomount** } }
*COMMANDS* := { **show** | **list** | **pin** | **help** } *COMMANDS* := { **show** | **list** | **pin** | **help** }
......
...@@ -12,7 +12,8 @@ SYNOPSIS ...@@ -12,7 +12,8 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **map** *COMMAND* **bpftool** [*OPTIONS*] **map** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
{ **-f** | **--bpffs** } | { **-n** | **--nomount** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext** { **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext**
......
...@@ -12,7 +12,7 @@ SYNOPSIS ...@@ -12,7 +12,7 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **net** *COMMAND* **bpftool** [*OPTIONS*] **net** *COMMAND*
*OPTIONS* := { [{ **-j** | **--json** }] [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **attach** | **detach** | **help** } { **show** | **list** | **attach** | **detach** | **help** }
......
...@@ -12,7 +12,7 @@ SYNOPSIS ...@@ -12,7 +12,7 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **perf** *COMMAND* **bpftool** [*OPTIONS*] **perf** *COMMAND*
*OPTIONS* := { [{ **-j** | **--json** }] [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **help** } { **show** | **list** | **help** }
......
...@@ -12,7 +12,9 @@ SYNOPSIS ...@@ -12,7 +12,9 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **prog** *COMMAND* **bpftool** [*OPTIONS*] **prog** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
{ **-f** | **--bpffs** } | { **-m** | **--mapcompat** } | { **-n** | **--nomount** } |
{ **-L** | **--use-loader** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load**
...@@ -48,10 +50,11 @@ PROG COMMANDS ...@@ -48,10 +50,11 @@ PROG COMMANDS
| **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup** | **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup**
| } | }
| *ATTACH_TYPE* := { | *ATTACH_TYPE* := {
| **msg_verdict** | **stream_verdict** | **stream_parser** | **flow_dissector** | **msg_verdict** | **skb_verdict** | **stream_verdict** | **stream_parser** | **flow_dissector**
| } | }
| *METRICs* := { | *METRICs* := {
| **cycles** | **instructions** | **l1d_loads** | **llc_misses** | **cycles** | **instructions** | **l1d_loads** | **llc_misses** |
| **itlb_misses** | **dtlb_misses**
| } | }
...@@ -223,6 +226,20 @@ OPTIONS ...@@ -223,6 +226,20 @@ OPTIONS
Do not automatically attempt to mount any virtual file system Do not automatically attempt to mount any virtual file system
(such as tracefs or BPF virtual file system) when necessary. (such as tracefs or BPF virtual file system) when necessary.
-L, --use-loader
Load program as a "loader" program. This is useful to debug
the generation of such programs. When this option is in
use, bpftool attempts to load the programs from the object
file into the kernel, but does not pin them (therefore, the
*PATH* must not be provided).
When combined with the **-d**\ \|\ **--debug** option,
additional debug messages are generated, and the execution
of the loader program will use the **bpf_trace_printk**\ ()
helper to log each step of loading BTF, creating the maps,
and loading the programs (see **bpftool prog tracelog** as
a way to dump those messages).
EXAMPLES EXAMPLES
======== ========
**# bpftool prog show** **# bpftool prog show**
...@@ -326,3 +343,16 @@ EXAMPLES ...@@ -326,3 +343,16 @@ EXAMPLES
40176203 cycles (83.05%) 40176203 cycles (83.05%)
42518139 instructions # 1.06 insns per cycle (83.39%) 42518139 instructions # 1.06 insns per cycle (83.39%)
123 llc_misses # 2.89 LLC misses per million insns (83.15%) 123 llc_misses # 2.89 LLC misses per million insns (83.15%)
|
| Output below is for the trace logs.
| Run in separate terminals:
| **# bpftool prog tracelog**
| **# bpftool prog load -L -d file.o**
::
bpftool-620059 [004] d... 2634685.517903: bpf_trace_printk: btf_load size 665 r=5
bpftool-620059 [004] d... 2634685.517912: bpf_trace_printk: map_create sample_map idx 0 type 2 value_size 4 value_btf_id 0 r=6
bpftool-620059 [004] d... 2634685.517997: bpf_trace_printk: prog_load sample insn_cnt 13 r=7
bpftool-620059 [004] d... 2634685.517999: bpf_trace_printk: close(5) = 0
...@@ -12,7 +12,7 @@ SYNOPSIS ...@@ -12,7 +12,7 @@ SYNOPSIS
**bpftool** [*OPTIONS*] **struct_ops** *COMMAND* **bpftool** [*OPTIONS*] **struct_ops** *COMMAND*
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] } *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*COMMANDS* := *COMMANDS* :=
{ **show** | **list** | **dump** | **register** | **unregister** | **help** } { **show** | **list** | **dump** | **register** | **unregister** | **help** }
......
...@@ -18,15 +18,15 @@ SYNOPSIS ...@@ -18,15 +18,15 @@ SYNOPSIS
*OBJECT* := { **map** | **program** | **cgroup** | **perf** | **net** | **feature** } *OBJECT* := { **map** | **program** | **cgroup** | **perf** | **net** | **feature** }
*OPTIONS* := { { **-V** | **--version** } | { **-h** | **--help** } *OPTIONS* := { { **-V** | **--version** } |
| { **-j** | **--json** } [{ **-p** | **--pretty** }] } { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }
*MAP-COMMANDS* := *MAP-COMMANDS* :=
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext** { **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext** |
| **delete** | **pin** | **event_pipe** | **help** } **delete** | **pin** | **event_pipe** | **help** }
*PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin** *PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin** |
| **load** | **attach** | **detach** | **help** } **load** | **attach** | **detach** | **help** }
*CGROUP-COMMANDS* := { **show** | **list** | **attach** | **detach** | **help** } *CGROUP-COMMANDS* := { **show** | **list** | **attach** | **detach** | **help** }
......
...@@ -260,7 +260,8 @@ _bpftool() ...@@ -260,7 +260,8 @@ _bpftool()
# Deal with options # Deal with options
if [[ ${words[cword]} == -* ]]; then if [[ ${words[cword]} == -* ]]; then
local c='--version --json --pretty --bpffs --mapcompat --debug' local c='--version --json --pretty --bpffs --mapcompat --debug \
--use-loader --base-btf'
COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
return 0 return 0
fi fi
...@@ -278,7 +279,7 @@ _bpftool() ...@@ -278,7 +279,7 @@ _bpftool()
_sysfs_get_netdevs _sysfs_get_netdevs
return 0 return 0
;; ;;
file|pinned) file|pinned|-B|--base-btf)
_filedir _filedir
return 0 return 0
;; ;;
...@@ -291,7 +292,8 @@ _bpftool() ...@@ -291,7 +292,8 @@ _bpftool()
# Remove all options so completions don't have to deal with them. # Remove all options so completions don't have to deal with them.
local i local i
for (( i=1; i < ${#words[@]}; )); do for (( i=1; i < ${#words[@]}; )); do
if [[ ${words[i]::1} == - ]]; then if [[ ${words[i]::1} == - ]] &&
[[ ${words[i]} != "-B" ]] && [[ ${words[i]} != "--base-btf" ]]; then
words=( "${words[@]:0:i}" "${words[@]:i+1}" ) words=( "${words[@]:0:i}" "${words[@]:i+1}" )
[[ $i -le $cword ]] && cword=$(( cword - 1 )) [[ $i -le $cword ]] && cword=$(( cword - 1 ))
else else
...@@ -343,7 +345,8 @@ _bpftool() ...@@ -343,7 +345,8 @@ _bpftool()
local PROG_TYPE='id pinned tag name' local PROG_TYPE='id pinned tag name'
local MAP_TYPE='id pinned name' local MAP_TYPE='id pinned name'
local METRIC_TYPE='cycles instructions l1d_loads llc_misses' local METRIC_TYPE='cycles instructions l1d_loads llc_misses \
itlb_misses dtlb_misses'
case $command in case $command in
show|list) show|list)
[[ $prev != "$command" ]] && return 0 [[ $prev != "$command" ]] && return 0
...@@ -404,8 +407,10 @@ _bpftool() ...@@ -404,8 +407,10 @@ _bpftool()
return 0 return 0
;; ;;
5) 5)
COMPREPLY=( $( compgen -W 'msg_verdict stream_verdict \ local BPFTOOL_PROG_ATTACH_TYPES='msg_verdict \
stream_parser flow_dissector' -- "$cur" ) ) skb_verdict stream_verdict stream_parser \
flow_dissector'
COMPREPLY=( $( compgen -W "$BPFTOOL_PROG_ATTACH_TYPES" -- "$cur" ) )
return 0 return 0
;; ;;
6) 6)
...@@ -464,7 +469,7 @@ _bpftool() ...@@ -464,7 +469,7 @@ _bpftool()
case $prev in case $prev in
type) type)
COMPREPLY=( $( compgen -W "socket kprobe \ local BPFTOOL_PROG_LOAD_TYPES='socket kprobe \
kretprobe classifier flow_dissector \ kretprobe classifier flow_dissector \
action tracepoint raw_tracepoint \ action tracepoint raw_tracepoint \
xdp perf_event cgroup/skb cgroup/sock \ xdp perf_event cgroup/skb cgroup/sock \
...@@ -479,8 +484,8 @@ _bpftool() ...@@ -479,8 +484,8 @@ _bpftool()
cgroup/post_bind4 cgroup/post_bind6 \ cgroup/post_bind4 cgroup/post_bind6 \
cgroup/sysctl cgroup/getsockopt \ cgroup/sysctl cgroup/getsockopt \
cgroup/setsockopt cgroup/sock_release struct_ops \ cgroup/setsockopt cgroup/sock_release struct_ops \
fentry fexit freplace sk_lookup" -- \ fentry fexit freplace sk_lookup'
"$cur" ) ) COMPREPLY=( $( compgen -W "$BPFTOOL_PROG_LOAD_TYPES" -- "$cur" ) )
return 0 return 0
;; ;;
id) id)
...@@ -698,15 +703,15 @@ _bpftool() ...@@ -698,15 +703,15 @@ _bpftool()
return 0 return 0
;; ;;
type) type)
COMPREPLY=( $( compgen -W 'hash array prog_array \ local BPFTOOL_MAP_CREATE_TYPES='hash array \
perf_event_array percpu_hash percpu_array \ prog_array perf_event_array percpu_hash \
stack_trace cgroup_array lru_hash \ percpu_array stack_trace cgroup_array lru_hash \
lru_percpu_hash lpm_trie array_of_maps \ lru_percpu_hash lpm_trie array_of_maps \
hash_of_maps devmap devmap_hash sockmap cpumap \ hash_of_maps devmap devmap_hash sockmap cpumap \
xskmap sockhash cgroup_storage reuseport_sockarray \ xskmap sockhash cgroup_storage reuseport_sockarray \
percpu_cgroup_storage queue stack sk_storage \ percpu_cgroup_storage queue stack sk_storage \
struct_ops inode_storage task_storage' -- \ struct_ops inode_storage task_storage ringbuf'
"$cur" ) ) COMPREPLY=( $( compgen -W "$BPFTOOL_MAP_CREATE_TYPES" -- "$cur" ) )
return 0 return 0
;; ;;
key|value|flags|entries) key|value|flags|entries)
...@@ -1017,34 +1022,37 @@ _bpftool() ...@@ -1017,34 +1022,37 @@ _bpftool()
return 0 return 0
;; ;;
attach|detach) attach|detach)
local ATTACH_TYPES='ingress egress sock_create sock_ops \ local BPFTOOL_CGROUP_ATTACH_TYPES='ingress egress \
device bind4 bind6 post_bind4 post_bind6 connect4 connect6 \ sock_create sock_ops device \
bind4 bind6 post_bind4 post_bind6 connect4 connect6 \
getpeername4 getpeername6 getsockname4 getsockname6 \ getpeername4 getpeername6 getsockname4 getsockname6 \
sendmsg4 sendmsg6 recvmsg4 recvmsg6 sysctl getsockopt \ sendmsg4 sendmsg6 recvmsg4 recvmsg6 sysctl getsockopt \
setsockopt sock_release' setsockopt sock_release'
local ATTACH_FLAGS='multi override' local ATTACH_FLAGS='multi override'
local PROG_TYPE='id pinned tag name' local PROG_TYPE='id pinned tag name'
case $prev in # Check for $prev = $command first
$command) if [ $prev = $command ]; then
_filedir _filedir
return 0 return 0
;; # Then check for attach type. This is done outside of the
ingress|egress|sock_create|sock_ops|device|bind4|bind6|\ # "case $prev in" to avoid writing the whole list of attach
post_bind4|post_bind6|connect4|connect6|getpeername4|\ # types again as pattern to match (where we cannot reuse
getpeername6|getsockname4|getsockname6|sendmsg4|sendmsg6|\ # our variable).
recvmsg4|recvmsg6|sysctl|getsockopt|setsockopt|sock_release) elif [[ $BPFTOOL_CGROUP_ATTACH_TYPES =~ $prev ]]; then
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \ COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \
"$cur" ) ) "$cur" ) )
return 0 return 0
;; fi
# case/esac for the other cases
case $prev in
id) id)
_bpftool_get_prog_ids _bpftool_get_prog_ids
return 0 return 0
;; ;;
*) *)
if ! _bpftool_search_list "$ATTACH_TYPES"; then if ! _bpftool_search_list "$BPFTOOL_CGROUP_ATTACH_TYPES"; then
COMPREPLY=( $( compgen -W "$ATTACH_TYPES" -- \ COMPREPLY=( $( compgen -W \
"$cur" ) ) "$BPFTOOL_CGROUP_ATTACH_TYPES" -- "$cur" ) )
elif [[ "$command" == "attach" ]]; then elif [[ "$command" == "attach" ]]; then
# We have an attach type on the command line, # We have an attach type on the command line,
# but it is not the previous word, or # but it is not the previous word, or
......
...@@ -981,7 +981,8 @@ static int do_help(int argc, char **argv) ...@@ -981,7 +981,8 @@ static int do_help(int argc, char **argv)
" FORMAT := { raw | c }\n" " FORMAT := { raw | c }\n"
" " HELP_SPEC_MAP "\n" " " HELP_SPEC_MAP "\n"
" " HELP_SPEC_PROGRAM "\n" " " HELP_SPEC_PROGRAM "\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-B|--base-btf} }\n"
"", "",
bin_name, "btf"); bin_name, "btf");
......
...@@ -501,7 +501,8 @@ static int do_help(int argc, char **argv) ...@@ -501,7 +501,8 @@ static int do_help(int argc, char **argv)
HELP_SPEC_ATTACH_TYPES "\n" HELP_SPEC_ATTACH_TYPES "\n"
" " HELP_SPEC_ATTACH_FLAGS "\n" " " HELP_SPEC_ATTACH_FLAGS "\n"
" " HELP_SPEC_PROGRAM "\n" " " HELP_SPEC_PROGRAM "\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -67,6 +67,12 @@ const char * const attach_type_name[__MAX_BPF_ATTACH_TYPE] = { ...@@ -67,6 +67,12 @@ const char * const attach_type_name[__MAX_BPF_ATTACH_TYPE] = {
[BPF_MODIFY_RETURN] = "mod_ret", [BPF_MODIFY_RETURN] = "mod_ret",
[BPF_LSM_MAC] = "lsm_mac", [BPF_LSM_MAC] = "lsm_mac",
[BPF_SK_LOOKUP] = "sk_lookup", [BPF_SK_LOOKUP] = "sk_lookup",
[BPF_TRACE_ITER] = "trace_iter",
[BPF_XDP_DEVMAP] = "xdp_devmap",
[BPF_XDP_CPUMAP] = "xdp_cpumap",
[BPF_XDP] = "xdp",
[BPF_SK_REUSEPORT_SELECT] = "sk_skb_reuseport_select",
[BPF_SK_REUSEPORT_SELECT_OR_MIGRATE] = "sk_skb_reuseport_select_or_migrate",
}; };
void p_err(const char *fmt, ...) void p_err(const char *fmt, ...)
......
...@@ -1005,6 +1005,7 @@ static int do_help(int argc, char **argv) ...@@ -1005,6 +1005,7 @@ static int do_help(int argc, char **argv)
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n" "\n"
" COMPONENT := { kernel | dev NAME }\n" " COMPONENT := { kernel | dev NAME }\n"
" " HELP_SPEC_OPTIONS " }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -1026,7 +1026,8 @@ static int do_help(int argc, char **argv) ...@@ -1026,7 +1026,8 @@ static int do_help(int argc, char **argv)
" %1$s %2$s skeleton FILE [name OBJECT_NAME]\n" " %1$s %2$s skeleton FILE [name OBJECT_NAME]\n"
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n" "\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-L|--use-loader} }\n"
"", "",
bin_name, "gen"); bin_name, "gen");
......
...@@ -97,7 +97,9 @@ static int do_help(int argc, char **argv) ...@@ -97,7 +97,9 @@ static int do_help(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"Usage: %1$s %2$s pin OBJ PATH [map MAP]\n" "Usage: %1$s %2$s pin OBJ PATH [map MAP]\n"
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n"
" " HELP_SPEC_MAP "\n" " " HELP_SPEC_MAP "\n"
" " HELP_SPEC_OPTIONS " }\n"
"", "",
bin_name, "iter"); bin_name, "iter");
......
...@@ -401,7 +401,8 @@ static int do_help(int argc, char **argv) ...@@ -401,7 +401,8 @@ static int do_help(int argc, char **argv)
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n" "\n"
" " HELP_SPEC_LINK "\n" " " HELP_SPEC_LINK "\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-n|--nomount} }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -64,7 +64,8 @@ static int do_help(int argc, char **argv) ...@@ -64,7 +64,8 @@ static int do_help(int argc, char **argv)
" %s version\n" " %s version\n"
"\n" "\n"
" OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }\n" " OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-V|--version} }\n"
"", "",
bin_name, bin_name, bin_name); bin_name, bin_name, bin_name);
......
...@@ -57,8 +57,7 @@ static inline void *u64_to_ptr(__u64 ptr) ...@@ -57,8 +57,7 @@ static inline void *u64_to_ptr(__u64 ptr)
#define HELP_SPEC_PROGRAM \ #define HELP_SPEC_PROGRAM \
"PROG := { id PROG_ID | pinned FILE | tag PROG_TAG | name PROG_NAME }" "PROG := { id PROG_ID | pinned FILE | tag PROG_TAG | name PROG_NAME }"
#define HELP_SPEC_OPTIONS \ #define HELP_SPEC_OPTIONS \
"OPTIONS := { {-j|--json} [{-p|--pretty}] | {-f|--bpffs} |\n" \ "OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug}"
"\t {-m|--mapcompat} | {-n|--nomount} }"
#define HELP_SPEC_MAP \ #define HELP_SPEC_MAP \
"MAP := { id MAP_ID | pinned FILE | name MAP_NAME }" "MAP := { id MAP_ID | pinned FILE | name MAP_NAME }"
#define HELP_SPEC_LINK \ #define HELP_SPEC_LINK \
......
...@@ -1466,8 +1466,9 @@ static int do_help(int argc, char **argv) ...@@ -1466,8 +1466,9 @@ static int do_help(int argc, char **argv)
" devmap | devmap_hash | sockmap | cpumap | xskmap | sockhash |\n" " devmap | devmap_hash | sockmap | cpumap | xskmap | sockhash |\n"
" cgroup_storage | reuseport_sockarray | percpu_cgroup_storage |\n" " cgroup_storage | reuseport_sockarray | percpu_cgroup_storage |\n"
" queue | stack | sk_storage | struct_ops | ringbuf | inode_storage |\n" " queue | stack | sk_storage | struct_ops | ringbuf | inode_storage |\n"
" task_storage }\n" " task_storage }\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-n|--nomount} }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -729,6 +729,7 @@ static int do_help(int argc, char **argv) ...@@ -729,6 +729,7 @@ static int do_help(int argc, char **argv)
"\n" "\n"
" " HELP_SPEC_PROGRAM "\n" " " HELP_SPEC_PROGRAM "\n"
" ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }\n" " ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }\n"
" " HELP_SPEC_OPTIONS " }\n"
"\n" "\n"
"Note: Only xdp and tc attachments are supported now.\n" "Note: Only xdp and tc attachments are supported now.\n"
" For progs attached to cgroups, use \"bpftool cgroup\"\n" " For progs attached to cgroups, use \"bpftool cgroup\"\n"
......
...@@ -231,7 +231,10 @@ static int do_show(int argc, char **argv) ...@@ -231,7 +231,10 @@ static int do_show(int argc, char **argv)
static int do_help(int argc, char **argv) static int do_help(int argc, char **argv)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: %1$s %2$s { show | list | help }\n" "Usage: %1$s %2$s { show | list }\n"
" %1$s %2$s help }\n"
"\n"
" " HELP_SPEC_OPTIONS " }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -2256,10 +2256,12 @@ static int do_help(int argc, char **argv) ...@@ -2256,10 +2256,12 @@ static int do_help(int argc, char **argv)
" cgroup/sendmsg6 | cgroup/recvmsg4 | cgroup/recvmsg6 |\n" " cgroup/sendmsg6 | cgroup/recvmsg4 | cgroup/recvmsg6 |\n"
" cgroup/getsockopt | cgroup/setsockopt | cgroup/sock_release |\n" " cgroup/getsockopt | cgroup/setsockopt | cgroup/sock_release |\n"
" struct_ops | fentry | fexit | freplace | sk_lookup }\n" " struct_ops | fentry | fexit | freplace | sk_lookup }\n"
" ATTACH_TYPE := { msg_verdict | stream_verdict | stream_parser |\n" " ATTACH_TYPE := { msg_verdict | skb_verdict | stream_verdict |\n"
" flow_dissector }\n" " stream_parser | flow_dissector }\n"
" METRIC := { cycles | instructions | l1d_loads | llc_misses | itlb_misses | dtlb_misses }\n" " METRIC := { cycles | instructions | l1d_loads | llc_misses | itlb_misses | dtlb_misses }\n"
" " HELP_SPEC_OPTIONS "\n" " " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-m|--mapcompat} | {-n|--nomount} |\n"
" {-L|--use-loader} }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
...@@ -572,8 +572,8 @@ static int do_help(int argc, char **argv) ...@@ -572,8 +572,8 @@ static int do_help(int argc, char **argv)
" %1$s %2$s unregister STRUCT_OPS_MAP\n" " %1$s %2$s unregister STRUCT_OPS_MAP\n"
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n" "\n"
" OPTIONS := { {-j|--json} [{-p|--pretty}] }\n"
" STRUCT_OPS_MAP := [ id STRUCT_OPS_MAP_ID | name STRUCT_OPS_MAP_NAME ]\n" " STRUCT_OPS_MAP := [ id STRUCT_OPS_MAP_ID | name STRUCT_OPS_MAP_NAME ]\n"
" " HELP_SPEC_OPTIONS " }\n"
"", "",
bin_name, argv[-2]); bin_name, argv[-2]);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment