1================ 2bpftool-prog 3================ 4------------------------------------------------------------------------------- 5tool for inspection and simple manipulation of eBPF progs 6------------------------------------------------------------------------------- 7 8:Manual section: 8 9 10SYNOPSIS 11======== 12 13 **bpftool** [*OPTIONS*] **prog** *COMMAND* 14 15 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] } 16 17 *COMMANDS* := 18 { **show** | **dump xlated** | **dump jited** | **pin** | **help** } 19 20MAP COMMANDS 21============= 22 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** 28| 29| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* } 30 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 41 **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** }] 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. 47 48 **bpftool prog dump jited** *PROG* [{ **file** *FILE* | **opcodes** }] 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 63OPTIONS 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 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 78EXAMPLES 79======== 80**# bpftool prog show** 81:: 82 83 10: xdp name some_prog tag 005a3d2123620c8b 84 loaded_at Sep 29/20:11 uid 0 85 xlated 528B jited 370B memlock 4096B map_ids 10 86 87**# bpftool --json --pretty prog show** 88 89:: 90 91 { 92 "programs": [{ 93 "id": 10, 94 "type": "xdp", 95 "tag": "005a3d2123620c8b", 96 "loaded_at": "Sep 29/20:11", 97 "uid": 0, 98 "bytes_xlated": 528, 99 "jited": true, 100 "bytes_jited": 370, 101 "bytes_memlock": 4096, 102 "map_ids": [10 103 ] 104 } 105 ] 106 } 107 108| 109| **# bpftool prog dump xlated id 10 file /tmp/t** 110| **# ls -l /tmp/t** 111| -rw------- 1 root root 560 Jul 22 01:42 /tmp/t 112 113**# bpftool prog dum jited tag 005a3d2123620c8b** 114 115:: 116 117 push %rbp 118 mov %rsp,%rbp 119 sub $0x228,%rsp 120 sub $0x28,%rbp 121 mov %rbx,0x0(%rbp) 122 123| 124| **# mount -t bpf none /sys/fs/bpf/** 125| **# bpftool prog pin id 10 /sys/fs/bpf/prog** 126| **# ls -l /sys/fs/bpf/** 127| -rw------- 1 root root 0 Jul 22 01:43 prog 128 129**# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes** 130 131:: 132 133 push %rbp 134 55 135 mov %rsp,%rbp 136 48 89 e5 137 sub $0x228,%rsp 138 48 81 ec 28 02 00 00 139 sub $0x28,%rbp 140 48 83 ed 28 141 mov %rbx,0x0(%rbp) 142 48 89 5d 00 143 144 145SEE ALSO 146======== 147 **bpftool**\ (8), **bpftool-map**\ (8) 148