4 -------------------------------------------------------------------------------
5 tool for inspection and simple manipulation of eBPF progs
6 -------------------------------------------------------------------------------
13 **bpftool** [*OPTIONS*] **prog** *COMMAND*
15 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
18 { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | **help** }
23 | **bpftool** **prog { show | list }** [*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 load** *OBJ* *FILE*
28 | **bpftool** **prog help**
30 | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
34 **bpftool prog { show | list }** [*PROG*]
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.
39 Output will start with program ID followed by program type and
40 zero or more named attributes (depending on kernel version).
42 **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** }]
43 Dump eBPF instructions of the program from the kernel.
44 If *FILE* is specified image will be written to a file,
45 otherwise it will be disassembled and printed to stdout.
47 **opcodes** controls if raw opcodes will be printed.
49 **bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }]
50 Dump jited image (host machine code) of the program.
51 If *FILE* is specified image will be written to a file,
52 otherwise it will be disassembled and printed to stdout.
54 **opcodes** controls if raw opcodes will be printed.
56 **bpftool prog pin** *PROG* *FILE*
57 Pin program *PROG* as *FILE*.
59 Note: *FILE* must be located in *bpffs* mount.
61 **bpftool prog load** *OBJ* *FILE*
62 Load bpf program from binary *OBJ* and pin as *FILE*.
64 Note: *FILE* must be located in *bpffs* mount.
67 Print short help message.
72 Print short generic help message (similar to **bpftool help**).
75 Print version number (similar to **bpftool version**).
78 Generate JSON output. For commands that cannot produce JSON, this
82 Generate human-readable JSON output. Implies **-j**.
85 Show file names of pinned programs.
89 **# bpftool prog show**
92 10: xdp name some_prog tag 005a3d2123620c8b
93 loaded_at Sep 29/20:11 uid 0
94 xlated 528B jited 370B memlock 4096B map_ids 10
96 **# bpftool --json --pretty prog show**
104 "tag": "005a3d2123620c8b",
105 "loaded_at": "Sep 29/20:11",
110 "bytes_memlock": 4096,
118 | **# bpftool prog dump xlated id 10 file /tmp/t**
120 | -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
122 **# bpftool prog dum jited tag 005a3d2123620c8b**
133 | **# mount -t bpf none /sys/fs/bpf/**
134 | **# bpftool prog pin id 10 /sys/fs/bpf/prog**
135 | **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2**
136 | **# ls -l /sys/fs/bpf/**
137 | -rw------- 1 root root 0 Jul 22 01:43 prog
138 | -rw------- 1 root root 0 Jul 22 01:44 prog2
140 **# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes**
158 **bpftool**\ (8), **bpftool-map**\ (8), **bpftool-cgroup**\ (8)