]>
Commit | Line | Data |
---|---|---|
ff69c21a JK |
1 | ================ |
2 | bpftool-prog | |
3 | ================ | |
4 | ------------------------------------------------------------------------------- | |
5 | tool for inspection and simple manipulation of eBPF progs | |
6 | ------------------------------------------------------------------------------- | |
7 | ||
8 | :Manual section: 8 | |
9 | ||
10 | SYNOPSIS | |
11 | ======== | |
12 | ||
0641c3c8 QM |
13 | **bpftool** [*OPTIONS*] **prog** *COMMAND* |
14 | ||
c541b734 | 15 | *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } |
0641c3c8 QM |
16 | |
17 | *COMMANDS* := | |
6ebe6dbd | 18 | { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | **help** } |
0641c3c8 QM |
19 | |
20 | MAP COMMANDS | |
21 | ============= | |
22 | ||
6ebe6dbd | 23 | | **bpftool** **prog { show | list }** [*PROG*] |
b6c1cedb | 24 | | **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual**}] |
47ff7ac6 QM |
25 | | **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes**}] |
26 | | **bpftool** **prog pin** *PROG* *FILE* | |
ba6dd679 | 27 | | **bpftool** **prog load** *OBJ* *FILE* [**dev** *NAME*] |
47ff7ac6 | 28 | | **bpftool** **prog help** |
ff69c21a | 29 | | |
47ff7ac6 | 30 | | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* } |
ff69c21a JK |
31 | |
32 | DESCRIPTION | |
33 | =========== | |
6ebe6dbd | 34 | **bpftool prog { show | list }** [*PROG*] |
ff69c21a JK |
35 | Show information about loaded programs. If *PROG* is |
36 | specified show information only about given program, otherwise | |
37 | list all programs currently loaded on the system. | |
38 | ||
39 | Output will start with program ID followed by program type and | |
40 | zero or more named attributes (depending on kernel version). | |
41 | ||
b6c1cedb JW |
42 | **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** }] |
43 | Dump eBPF instructions of the program from the kernel. By | |
44 | default, eBPF will be disassembled and printed to standard | |
45 | output in human-readable format. In this case, **opcodes** | |
46 | controls if raw opcodes should be printed as well. | |
c9c35995 | 47 | |
b6c1cedb JW |
48 | If **file** is specified, the binary image will instead be |
49 | written to *FILE*. | |
50 | ||
51 | If **visual** is specified, control flow graph (CFG) will be | |
52 | built instead, and eBPF instructions will be presented with | |
53 | CFG in DOT format, on standard output. | |
ff69c21a | 54 | |
8dfbc6d1 | 55 | **bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }] |
ff69c21a JK |
56 | Dump jited image (host machine code) of the program. |
57 | If *FILE* is specified image will be written to a file, | |
58 | otherwise it will be disassembled and printed to stdout. | |
59 | ||
60 | **opcodes** controls if raw opcodes will be printed. | |
61 | ||
62 | **bpftool prog pin** *PROG* *FILE* | |
63 | Pin program *PROG* as *FILE*. | |
64 | ||
65 | Note: *FILE* must be located in *bpffs* mount. | |
66 | ||
ba6dd679 | 67 | **bpftool prog load** *OBJ* *FILE* [**dev** *NAME*] |
49a086c2 | 68 | Load bpf program from binary *OBJ* and pin as *FILE*. |
ba6dd679 JK |
69 | If **dev** *NAME* is specified program will be loaded onto |
70 | given networking device (offload). | |
49a086c2 RG |
71 | |
72 | Note: *FILE* must be located in *bpffs* mount. | |
73 | ||
ff69c21a JK |
74 | **bpftool prog help** |
75 | Print short help message. | |
76 | ||
a2bc2e5c QM |
77 | OPTIONS |
78 | ======= | |
79 | -h, --help | |
80 | Print short generic help message (similar to **bpftool help**). | |
81 | ||
82 | -v, --version | |
83 | Print version number (similar to **bpftool version**). | |
84 | ||
0641c3c8 QM |
85 | -j, --json |
86 | Generate JSON output. For commands that cannot produce JSON, this | |
87 | option has no effect. | |
88 | ||
89 | -p, --pretty | |
90 | Generate human-readable JSON output. Implies **-j**. | |
91 | ||
c541b734 PB |
92 | -f, --bpffs |
93 | Show file names of pinned programs. | |
94 | ||
ff69c21a JK |
95 | EXAMPLES |
96 | ======== | |
97 | **# bpftool prog show** | |
98 | :: | |
99 | ||
9b984a20 | 100 | 10: xdp name some_prog tag 005a3d2123620c8b gpl |
ff69c21a JK |
101 | loaded_at Sep 29/20:11 uid 0 |
102 | xlated 528B jited 370B memlock 4096B map_ids 10 | |
103 | ||
0641c3c8 QM |
104 | **# bpftool --json --pretty prog show** |
105 | ||
106 | :: | |
107 | ||
108 | { | |
109 | "programs": [{ | |
110 | "id": 10, | |
111 | "type": "xdp", | |
112 | "tag": "005a3d2123620c8b", | |
9b984a20 | 113 | "gpl_compatible": true, |
0641c3c8 QM |
114 | "loaded_at": "Sep 29/20:11", |
115 | "uid": 0, | |
116 | "bytes_xlated": 528, | |
117 | "jited": true, | |
118 | "bytes_jited": 370, | |
119 | "bytes_memlock": 4096, | |
120 | "map_ids": [10 | |
121 | ] | |
122 | } | |
123 | ] | |
124 | } | |
125 | ||
ff69c21a JK |
126 | | |
127 | | **# bpftool prog dump xlated id 10 file /tmp/t** | |
128 | | **# ls -l /tmp/t** | |
129 | | -rw------- 1 root root 560 Jul 22 01:42 /tmp/t | |
130 | ||
0641c3c8 | 131 | **# bpftool prog dum jited tag 005a3d2123620c8b** |
ff69c21a JK |
132 | |
133 | :: | |
134 | ||
135 | push %rbp | |
136 | mov %rsp,%rbp | |
137 | sub $0x228,%rsp | |
138 | sub $0x28,%rbp | |
139 | mov %rbx,0x0(%rbp) | |
140 | ||
0641c3c8 QM |
141 | | |
142 | | **# mount -t bpf none /sys/fs/bpf/** | |
143 | | **# bpftool prog pin id 10 /sys/fs/bpf/prog** | |
49a086c2 | 144 | | **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2** |
0641c3c8 QM |
145 | | **# ls -l /sys/fs/bpf/** |
146 | | -rw------- 1 root root 0 Jul 22 01:43 prog | |
49a086c2 | 147 | | -rw------- 1 root root 0 Jul 22 01:44 prog2 |
0641c3c8 QM |
148 | |
149 | **# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes** | |
150 | ||
151 | :: | |
152 | ||
153 | push %rbp | |
154 | 55 | |
155 | mov %rsp,%rbp | |
156 | 48 89 e5 | |
157 | sub $0x228,%rsp | |
158 | 48 81 ec 28 02 00 00 | |
159 | sub $0x28,%rbp | |
160 | 48 83 ed 28 | |
161 | mov %rbx,0x0(%rbp) | |
162 | 48 89 5d 00 | |
ff69c21a JK |
163 | |
164 | ||
165 | SEE ALSO | |
166 | ======== | |
5ccda64d | 167 | **bpftool**\ (8), **bpftool-map**\ (8), **bpftool-cgroup**\ (8) |