]>
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* := | |
18 | { **show** | **dump xlated** | **dump jited** | **pin** | **help** } | |
19 | ||
20 | MAP COMMANDS | |
21 | ============= | |
22 | ||
47ff7ac6 QM |
23 | | **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** | |
ff69c21a | 28 | | |
47ff7ac6 | 29 | | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* } |
ff69c21a JK |
30 | |
31 | DESCRIPTION | |
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 | ||
8dfbc6d1 | 41 | **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** }] |
c9c35995 JK |
42 | 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. | |
ff69c21a | 47 | |
8dfbc6d1 | 48 | **bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }] |
ff69c21a JK |
49 | 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 | ||
a2bc2e5c QM |
63 | OPTIONS |
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 | ||
0641c3c8 QM |
71 | -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 | ||
c541b734 PB |
78 | -f, --bpffs |
79 | Show file names of pinned programs. | |
80 | ||
ff69c21a JK |
81 | EXAMPLES |
82 | ======== | |
83 | **# bpftool prog show** | |
84 | :: | |
85 | ||
2dc7c1fe | 86 | 10: xdp name some_prog tag 005a3d2123620c8b |
ff69c21a JK |
87 | loaded_at Sep 29/20:11 uid 0 |
88 | xlated 528B jited 370B memlock 4096B map_ids 10 | |
89 | ||
0641c3c8 QM |
90 | **# 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 | ||
ff69c21a JK |
111 | | |
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 | ||
0641c3c8 | 116 | **# bpftool prog dum jited tag 005a3d2123620c8b** |
ff69c21a JK |
117 | |
118 | :: | |
119 | ||
120 | push %rbp | |
121 | mov %rsp,%rbp | |
122 | sub $0x228,%rsp | |
123 | sub $0x28,%rbp | |
124 | mov %rbx,0x0(%rbp) | |
125 | ||
0641c3c8 QM |
126 | | |
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 | |
ff69c21a JK |
146 | |
147 | ||
148 | SEE ALSO | |
149 | ======== | |
150 | **bpftool**\ (8), **bpftool-map**\ (8) |