2017-10-05 03:10:05 +00:00
|
|
|
================
|
|
|
|
bpftool-prog
|
|
|
|
================
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
tool for inspection and simple manipulation of eBPF progs
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
:Manual section: 8
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
========
|
|
|
|
|
2017-10-23 16:24:16 +00:00
|
|
|
**bpftool** [*OPTIONS*] **prog** *COMMAND*
|
|
|
|
|
2017-11-08 04:55:49 +00:00
|
|
|
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
|
2017-10-23 16:24:16 +00:00
|
|
|
|
|
|
|
*COMMANDS* :=
|
2018-01-02 22:48:36 +00:00
|
|
|
{ **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | **help** }
|
2017-10-23 16:24:16 +00:00
|
|
|
|
|
|
|
MAP COMMANDS
|
|
|
|
=============
|
|
|
|
|
2018-01-02 22:48:36 +00:00
|
|
|
| **bpftool** **prog { show | list }** [*PROG*]
|
2018-03-02 02:01:22 +00:00
|
|
|
| **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual**}]
|
2017-10-23 16:24:15 +00:00
|
|
|
| **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes**}]
|
|
|
|
| **bpftool** **prog pin** *PROG* *FILE*
|
2017-12-13 15:18:53 +00:00
|
|
|
| **bpftool** **prog load** *OBJ* *FILE*
|
2017-10-23 16:24:15 +00:00
|
|
|
| **bpftool** **prog help**
|
2017-10-05 03:10:05 +00:00
|
|
|
|
|
2017-10-23 16:24:15 +00:00
|
|
|
| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
|
2017-10-05 03:10:05 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
===========
|
2018-01-02 22:48:36 +00:00
|
|
|
**bpftool prog { show | list }** [*PROG*]
|
2017-10-05 03:10:05 +00:00
|
|
|
Show information about loaded programs. If *PROG* is
|
|
|
|
specified show information only about given program, otherwise
|
|
|
|
list all programs currently loaded on the system.
|
|
|
|
|
|
|
|
Output will start with program ID followed by program type and
|
|
|
|
zero or more named attributes (depending on kernel version).
|
|
|
|
|
2018-03-02 02:01:22 +00:00
|
|
|
**bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** }]
|
|
|
|
Dump eBPF instructions of the program from the kernel. By
|
|
|
|
default, eBPF will be disassembled and printed to standard
|
|
|
|
output in human-readable format. In this case, **opcodes**
|
|
|
|
controls if raw opcodes should be printed as well.
|
2017-10-09 17:30:13 +00:00
|
|
|
|
2018-03-02 02:01:22 +00:00
|
|
|
If **file** is specified, the binary image will instead be
|
|
|
|
written to *FILE*.
|
|
|
|
|
|
|
|
If **visual** is specified, control flow graph (CFG) will be
|
|
|
|
built instead, and eBPF instructions will be presented with
|
|
|
|
CFG in DOT format, on standard output.
|
2017-10-05 03:10:05 +00:00
|
|
|
|
2017-10-19 22:46:25 +00:00
|
|
|
**bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }]
|
2017-10-05 03:10:05 +00:00
|
|
|
Dump jited image (host machine code) of the program.
|
|
|
|
If *FILE* is specified image will be written to a file,
|
|
|
|
otherwise it will be disassembled and printed to stdout.
|
|
|
|
|
|
|
|
**opcodes** controls if raw opcodes will be printed.
|
|
|
|
|
|
|
|
**bpftool prog pin** *PROG* *FILE*
|
|
|
|
Pin program *PROG* as *FILE*.
|
|
|
|
|
|
|
|
Note: *FILE* must be located in *bpffs* mount.
|
|
|
|
|
2017-12-13 15:18:53 +00:00
|
|
|
**bpftool prog load** *OBJ* *FILE*
|
|
|
|
Load bpf program from binary *OBJ* and pin as *FILE*.
|
|
|
|
|
|
|
|
Note: *FILE* must be located in *bpffs* mount.
|
|
|
|
|
2017-10-05 03:10:05 +00:00
|
|
|
**bpftool prog help**
|
|
|
|
Print short help message.
|
|
|
|
|
2017-10-23 16:24:06 +00:00
|
|
|
OPTIONS
|
|
|
|
=======
|
|
|
|
-h, --help
|
|
|
|
Print short generic help message (similar to **bpftool help**).
|
|
|
|
|
|
|
|
-v, --version
|
|
|
|
Print version number (similar to **bpftool version**).
|
|
|
|
|
2017-10-23 16:24:16 +00:00
|
|
|
-j, --json
|
|
|
|
Generate JSON output. For commands that cannot produce JSON, this
|
|
|
|
option has no effect.
|
|
|
|
|
|
|
|
-p, --pretty
|
|
|
|
Generate human-readable JSON output. Implies **-j**.
|
|
|
|
|
2017-11-08 04:55:49 +00:00
|
|
|
-f, --bpffs
|
|
|
|
Show file names of pinned programs.
|
|
|
|
|
2017-10-05 03:10:05 +00:00
|
|
|
EXAMPLES
|
|
|
|
========
|
|
|
|
**# bpftool prog show**
|
|
|
|
::
|
|
|
|
|
tools, bpftool: Display license GPL compatible in prog show/list
Display the license "gpl" string in bpftool prog command, like:
# bpftool prog list
5: tracepoint name func tag 57cd311f2e27366b gpl
loaded_at Apr 26/09:37 uid 0
xlated 16B not jited memlock 4096B
# bpftool --json --pretty prog show
[{
"id": 5,
"type": "tracepoint",
"name": "func",
"tag": "57cd311f2e27366b",
"gpl_compatible": true,
"loaded_at": "Apr 26/09:37",
"uid": 0,
"bytes_xlated": 16,
"jited": false,
"bytes_memlock": 4096
}
]
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-04-26 08:18:01 +00:00
|
|
|
10: xdp name some_prog tag 005a3d2123620c8b gpl
|
2017-10-05 03:10:05 +00:00
|
|
|
loaded_at Sep 29/20:11 uid 0
|
|
|
|
xlated 528B jited 370B memlock 4096B map_ids 10
|
|
|
|
|
2017-10-23 16:24:16 +00:00
|
|
|
**# bpftool --json --pretty prog show**
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"programs": [{
|
|
|
|
"id": 10,
|
|
|
|
"type": "xdp",
|
|
|
|
"tag": "005a3d2123620c8b",
|
tools, bpftool: Display license GPL compatible in prog show/list
Display the license "gpl" string in bpftool prog command, like:
# bpftool prog list
5: tracepoint name func tag 57cd311f2e27366b gpl
loaded_at Apr 26/09:37 uid 0
xlated 16B not jited memlock 4096B
# bpftool --json --pretty prog show
[{
"id": 5,
"type": "tracepoint",
"name": "func",
"tag": "57cd311f2e27366b",
"gpl_compatible": true,
"loaded_at": "Apr 26/09:37",
"uid": 0,
"bytes_xlated": 16,
"jited": false,
"bytes_memlock": 4096
}
]
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-04-26 08:18:01 +00:00
|
|
|
"gpl_compatible": true,
|
2017-10-23 16:24:16 +00:00
|
|
|
"loaded_at": "Sep 29/20:11",
|
|
|
|
"uid": 0,
|
|
|
|
"bytes_xlated": 528,
|
|
|
|
"jited": true,
|
|
|
|
"bytes_jited": 370,
|
|
|
|
"bytes_memlock": 4096,
|
|
|
|
"map_ids": [10
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-10-05 03:10:05 +00:00
|
|
|
|
|
|
|
|
| **# bpftool prog dump xlated id 10 file /tmp/t**
|
|
|
|
| **# ls -l /tmp/t**
|
|
|
|
| -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
|
|
|
|
|
2017-10-23 16:24:16 +00:00
|
|
|
**# bpftool prog dum jited tag 005a3d2123620c8b**
|
2017-10-05 03:10:05 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
push %rbp
|
|
|
|
mov %rsp,%rbp
|
|
|
|
sub $0x228,%rsp
|
|
|
|
sub $0x28,%rbp
|
|
|
|
mov %rbx,0x0(%rbp)
|
|
|
|
|
2017-10-23 16:24:16 +00:00
|
|
|
|
|
|
|
|
| **# mount -t bpf none /sys/fs/bpf/**
|
|
|
|
| **# bpftool prog pin id 10 /sys/fs/bpf/prog**
|
2017-12-13 15:18:53 +00:00
|
|
|
| **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2**
|
2017-10-23 16:24:16 +00:00
|
|
|
| **# ls -l /sys/fs/bpf/**
|
|
|
|
| -rw------- 1 root root 0 Jul 22 01:43 prog
|
2017-12-13 15:18:53 +00:00
|
|
|
| -rw------- 1 root root 0 Jul 22 01:44 prog2
|
2017-10-23 16:24:16 +00:00
|
|
|
|
|
|
|
**# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes**
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
push %rbp
|
|
|
|
55
|
|
|
|
mov %rsp,%rbp
|
|
|
|
48 89 e5
|
|
|
|
sub $0x228,%rsp
|
|
|
|
48 81 ec 28 02 00 00
|
|
|
|
sub $0x28,%rbp
|
|
|
|
48 83 ed 28
|
|
|
|
mov %rbx,0x0(%rbp)
|
|
|
|
48 89 5d 00
|
2017-10-05 03:10:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
========
|
2017-12-13 15:18:54 +00:00
|
|
|
**bpftool**\ (8), **bpftool-map**\ (8), **bpftool-cgroup**\ (8)
|