blob: 36e8d1c3c40d15e3b9cca40c2780393977d77cfa [file] [log] [blame]
Jakub Kicinskiff69c212017-10-04 20:10:05 -07001================
2bpftool-prog
3================
4-------------------------------------------------------------------------------
5tool for inspection and simple manipulation of eBPF progs
6-------------------------------------------------------------------------------
7
8:Manual section: 8
9
10SYNOPSIS
11========
12
Quentin Monnet0641c3c2017-10-23 09:24:16 -070013 **bpftool** [*OPTIONS*] **prog** *COMMAND*
14
Prashant Bholec541b732017-11-08 13:55:49 +090015 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
Quentin Monnet0641c3c2017-10-23 09:24:16 -070016
17 *COMMANDS* :=
18 { **show** | **dump xlated** | **dump jited** | **pin** | **help** }
19
20MAP COMMANDS
21=============
22
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070023| **bpftool** **prog show** [*PROG*]
24| **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes**}]
25| **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes**}]
26| **bpftool** **prog pin** *PROG* *FILE*
27| **bpftool** **prog help**
Jakub Kicinskiff69c212017-10-04 20:10:05 -070028|
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070029| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070030
31DESCRIPTION
32===========
33 **bpftool prog show** [*PROG*]
34 Show information about loaded programs. If *PROG* is
35 specified show information only about given program, otherwise
36 list all programs currently loaded on the system.
37
38 Output will start with program ID followed by program type and
39 zero or more named attributes (depending on kernel version).
40
Quentin Monnet8dfbc6d2017-10-19 15:46:25 -070041 **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** }]
Jakub Kicinskic9c35992017-10-09 10:30:13 -070042 Dump eBPF instructions of the program from the kernel.
43 If *FILE* is specified image will be written to a file,
44 otherwise it will be disassembled and printed to stdout.
45
46 **opcodes** controls if raw opcodes will be printed.
Jakub Kicinskiff69c212017-10-04 20:10:05 -070047
Quentin Monnet8dfbc6d2017-10-19 15:46:25 -070048 **bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070049 Dump jited image (host machine code) of the program.
50 If *FILE* is specified image will be written to a file,
51 otherwise it will be disassembled and printed to stdout.
52
53 **opcodes** controls if raw opcodes will be printed.
54
55 **bpftool prog pin** *PROG* *FILE*
56 Pin program *PROG* as *FILE*.
57
58 Note: *FILE* must be located in *bpffs* mount.
59
60 **bpftool prog help**
61 Print short help message.
62
Quentin Monneta2bc2e52017-10-23 09:24:06 -070063OPTIONS
64=======
65 -h, --help
66 Print short generic help message (similar to **bpftool help**).
67
68 -v, --version
69 Print version number (similar to **bpftool version**).
70
Quentin Monnet0641c3c2017-10-23 09:24:16 -070071 -j, --json
72 Generate JSON output. For commands that cannot produce JSON, this
73 option has no effect.
74
75 -p, --pretty
76 Generate human-readable JSON output. Implies **-j**.
77
Prashant Bholec541b732017-11-08 13:55:49 +090078 -f, --bpffs
79 Show file names of pinned programs.
80
Jakub Kicinskiff69c212017-10-04 20:10:05 -070081EXAMPLES
82========
83**# bpftool prog show**
84::
85
Jakub Kicinski2dc7c1f2017-10-16 10:12:54 -070086 10: xdp name some_prog tag 005a3d2123620c8b
Jakub Kicinskiff69c212017-10-04 20:10:05 -070087 loaded_at Sep 29/20:11 uid 0
88 xlated 528B jited 370B memlock 4096B map_ids 10
89
Quentin Monnet0641c3c2017-10-23 09:24:16 -070090**# bpftool --json --pretty prog show**
91
92::
93
94 {
95 "programs": [{
96 "id": 10,
97 "type": "xdp",
98 "tag": "005a3d2123620c8b",
99 "loaded_at": "Sep 29/20:11",
100 "uid": 0,
101 "bytes_xlated": 528,
102 "jited": true,
103 "bytes_jited": 370,
104 "bytes_memlock": 4096,
105 "map_ids": [10
106 ]
107 }
108 ]
109 }
110
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700111|
112| **# bpftool prog dump xlated id 10 file /tmp/t**
113| **# ls -l /tmp/t**
114| -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
115
Quentin Monnet0641c3c2017-10-23 09:24:16 -0700116**# bpftool prog dum jited tag 005a3d2123620c8b**
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700117
118::
119
120 push %rbp
121 mov %rsp,%rbp
122 sub $0x228,%rsp
123 sub $0x28,%rbp
124 mov %rbx,0x0(%rbp)
125
Quentin Monnet0641c3c2017-10-23 09:24:16 -0700126|
127| **# mount -t bpf none /sys/fs/bpf/**
128| **# bpftool prog pin id 10 /sys/fs/bpf/prog**
129| **# ls -l /sys/fs/bpf/**
130| -rw------- 1 root root 0 Jul 22 01:43 prog
131
132**# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes**
133
134::
135
136 push %rbp
137 55
138 mov %rsp,%rbp
139 48 89 e5
140 sub $0x228,%rsp
141 48 81 ec 28 02 00 00
142 sub $0x28,%rbp
143 48 83 ed 28
144 mov %rbx,0x0(%rbp)
145 48 89 5d 00
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700146
147
148SEE ALSO
149========
150 **bpftool**\ (8), **bpftool-map**\ (8)