2017-10-05 11:10:05 +08:00
|
|
|
================
|
|
|
|
BPFTOOL
|
|
|
|
================
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
tool for inspection and simple manipulation of eBPF programs and maps
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
:Manual section: 8
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
========
|
|
|
|
|
2017-10-24 00:24:16 +08:00
|
|
|
**bpftool** [*OPTIONS*] *OBJECT* { *COMMAND* | **help** }
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2017-10-24 00:24:15 +08:00
|
|
|
**bpftool** **batch file** *FILE*
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2017-10-24 00:24:15 +08:00
|
|
|
**bpftool** **version**
|
2017-10-20 06:46:26 +08:00
|
|
|
|
2019-02-12 09:25:12 +08:00
|
|
|
*OBJECT* := { **map** | **program** | **cgroup** | **perf** | **net** | **feature** }
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2017-10-24 00:24:16 +08:00
|
|
|
*OPTIONS* := { { **-V** | **--version** } | { **-h** | **--help** }
|
|
|
|
| { **-j** | **--json** } [{ **-p** | **--pretty** }] }
|
|
|
|
|
2017-10-05 11:10:05 +08:00
|
|
|
*MAP-COMMANDS* :=
|
2018-10-16 07:30:36 +08:00
|
|
|
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext**
|
|
|
|
| **delete** | **pin** | **event_pipe** | **help** }
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2018-01-03 06:48:36 +08:00
|
|
|
*PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin**
|
2018-10-16 02:19:50 +08:00
|
|
|
| **load** | **attach** | **detach** | **help** }
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2018-01-03 06:48:36 +08:00
|
|
|
*CGROUP-COMMANDS* := { **show** | **list** | **attach** | **detach** | **help** }
|
2017-12-13 23:18:54 +08:00
|
|
|
|
tools/bpftool: add perf subcommand
The new command "bpftool perf [show | list]" will traverse
all processes under /proc, and if any fd is associated
with a perf event, it will print out related perf event
information. Documentation is also added.
Below is an example to show the results using bcc commands.
Running the following 4 bcc commands:
kprobe: trace.py '__x64_sys_nanosleep'
kretprobe: trace.py 'r::__x64_sys_nanosleep'
tracepoint: trace.py 't:syscalls:sys_enter_nanosleep'
uprobe: trace.py 'p:/home/yhs/a.out:main'
The bpftool command line and result:
$ bpftool perf
pid 21711 fd 5: prog_id 5 kprobe func __x64_sys_write offset 0
pid 21765 fd 5: prog_id 7 kretprobe func __x64_sys_nanosleep offset 0
pid 21767 fd 5: prog_id 8 tracepoint sys_enter_nanosleep
pid 21800 fd 5: prog_id 9 uprobe filename /home/yhs/a.out offset 1159
$ bpftool -j perf
[{"pid":21711,"fd":5,"prog_id":5,"fd_type":"kprobe","func":"__x64_sys_write","offset":0}, \
{"pid":21765,"fd":5,"prog_id":7,"fd_type":"kretprobe","func":"__x64_sys_nanosleep","offset":0}, \
{"pid":21767,"fd":5,"prog_id":8,"fd_type":"tracepoint","tracepoint":"sys_enter_nanosleep"}, \
{"pid":21800,"fd":5,"prog_id":9,"fd_type":"uprobe","filename":"/home/yhs/a.out","offset":1159}]
$ bpftool prog
5: kprobe name probe___x64_sys tag e495a0c82f2c7a8d gpl
loaded_at 2018-05-15T04:46:37-0700 uid 0
xlated 200B not jited memlock 4096B map_ids 4
7: kprobe name probe___x64_sys tag f2fdee479a503abf gpl
loaded_at 2018-05-15T04:48:32-0700 uid 0
xlated 200B not jited memlock 4096B map_ids 7
8: tracepoint name tracepoint__sys tag 5390badef2395fcf gpl
loaded_at 2018-05-15T04:48:48-0700 uid 0
xlated 200B not jited memlock 4096B map_ids 8
9: kprobe name probe_main_1 tag 0a87bdc2e2953b6d gpl
loaded_at 2018-05-15T04:49:52-0700 uid 0
xlated 200B not jited memlock 4096B map_ids 9
$ ps ax | grep "python ./trace.py"
21711 pts/0 T 0:03 python ./trace.py __x64_sys_write
21765 pts/0 S+ 0:00 python ./trace.py r::__x64_sys_nanosleep
21767 pts/2 S+ 0:00 python ./trace.py t:syscalls:sys_enter_nanosleep
21800 pts/3 S+ 0:00 python ./trace.py p:/home/yhs/a.out:main
22374 pts/1 S+ 0:00 grep --color=auto python ./trace.py
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2018-05-25 02:21:58 +08:00
|
|
|
*PERF-COMMANDS* := { **show** | **list** | **help** }
|
|
|
|
|
tools/bpf: bpftool: add net support
Add "bpftool net" support. Networking devices are enumerated
to dump device index/name associated with xdp progs.
For each networking device, tc classes and qdiscs are enumerated
in order to check their bpf filters.
In addition, root handle and clsact ingress/egress are also checked for
bpf filters. Not all filter information is printed out. Only ifindex,
kind, filter name, prog_id and tag are printed out, which are good
enough to show attachment information. If the filter action
is a bpf action, its bpf program id, bpf name and tag will be
printed out as well.
For example,
$ ./bpftool net
xdp [
ifindex 2 devname eth0 prog_id 198
]
tc_filters [
ifindex 2 kind qdisc_htb name prefix_matcher.o:[cls_prefix_matcher_htb]
prog_id 111727 tag d08fe3b4319bc2fd act []
ifindex 2 kind qdisc_clsact_ingress name fbflow_icmp
prog_id 130246 tag 3f265c7f26db62c9 act []
ifindex 2 kind qdisc_clsact_egress name prefix_matcher.o:[cls_prefix_matcher_clsact]
prog_id 111726 tag 99a197826974c876
ifindex 2 kind qdisc_clsact_egress name cls_fg_dscp
prog_id 108619 tag dc4630674fd72dcc act []
ifindex 2 kind qdisc_clsact_egress name fbflow_egress
prog_id 130245 tag 72d2d830d6888d2c
]
$ ./bpftool -jp net
[{
"xdp": [{
"ifindex": 2,
"devname": "eth0",
"prog_id": 198
}
],
"tc_filters": [{
"ifindex": 2,
"kind": "qdisc_htb",
"name": "prefix_matcher.o:[cls_prefix_matcher_htb]",
"prog_id": 111727,
"tag": "d08fe3b4319bc2fd",
"act": []
},{
"ifindex": 2,
"kind": "qdisc_clsact_ingress",
"name": "fbflow_icmp",
"prog_id": 130246,
"tag": "3f265c7f26db62c9",
"act": []
},{
"ifindex": 2,
"kind": "qdisc_clsact_egress",
"name": "prefix_matcher.o:[cls_prefix_matcher_clsact]",
"prog_id": 111726,
"tag": "99a197826974c876"
},{
"ifindex": 2,
"kind": "qdisc_clsact_egress",
"name": "cls_fg_dscp",
"prog_id": 108619,
"tag": "dc4630674fd72dcc",
"act": []
},{
"ifindex": 2,
"kind": "qdisc_clsact_egress",
"name": "fbflow_egress",
"prog_id": 130245,
"tag": "72d2d830d6888d2c"
}
]
}
]
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2018-09-06 07:58:06 +08:00
|
|
|
*NET-COMMANDS* := { **show** | **list** | **help** }
|
|
|
|
|
2019-02-12 09:25:12 +08:00
|
|
|
*FEATURE-COMMANDS* := { **probe** | **help** }
|
|
|
|
|
2017-10-05 11:10:05 +08:00
|
|
|
DESCRIPTION
|
|
|
|
===========
|
|
|
|
*bpftool* allows for inspection and simple modification of BPF objects
|
|
|
|
on the system.
|
|
|
|
|
|
|
|
Note that format of the output of all tools is not guaranteed to be
|
|
|
|
stable and should not be depended upon.
|
|
|
|
|
2017-10-24 00:24:06 +08:00
|
|
|
OPTIONS
|
|
|
|
=======
|
2020-09-10 00:24:59 +08:00
|
|
|
.. include:: common_options.rst
|
2017-10-24 00:24:16 +08:00
|
|
|
|
2018-10-16 02:19:55 +08:00
|
|
|
-m, --mapcompat
|
|
|
|
Allow loading maps with unknown map definitions.
|
|
|
|
|
2018-12-18 18:13:19 +08:00
|
|
|
-n, --nomount
|
|
|
|
Do not automatically attempt to mount any virtual file system
|
|
|
|
(such as tracefs or BPF virtual file system) when necessary.
|