~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/bpf/bpftool/Documentation/bpftool-prog.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/bpf/bpftool/Documentation/bpftool-prog.rst (Version linux-6.12-rc7) and /tools/bpf/bpftool/Documentation/bpftool-prog.rst (Version linux-5.14.21)


  1 .. SPDX-License-Identifier: (GPL-2.0-only OR B << 
  2                                                << 
  3 ================                                    1 ================
  4 bpftool-prog                                        2 bpftool-prog
  5 ================                                    3 ================
  6 ----------------------------------------------      4 -------------------------------------------------------------------------------
  7 tool for inspection and simple manipulation of      5 tool for inspection and simple manipulation of eBPF progs
  8 ----------------------------------------------      6 -------------------------------------------------------------------------------
  9                                                     7 
 10 :Manual section: 8                                  8 :Manual section: 8
 11                                                     9 
 12 .. include:: substitutions.rst                 << 
 13                                                << 
 14 SYNOPSIS                                           10 SYNOPSIS
 15 ========                                           11 ========
 16                                                    12 
 17 **bpftool** [*OPTIONS*] **prog** *COMMAND*     !!  13         **bpftool** [*OPTIONS*] **prog** *COMMAND*
                                                   >>  14 
                                                   >>  15         *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
 18                                                    16 
 19 *OPTIONS* := { |COMMON_OPTIONS| |              !!  17         *COMMANDS* :=
 20 { **-f** | **--bpffs** } | { **-m** | **--mapc !!  18         { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load**
 21 { **-L** | **--use-loader** } }                !!  19         | **loadall** | **help** }
 22                                                << 
 23 *COMMANDS* :=                                  << 
 24 { **show** | **list** | **dump xlated** | **du << 
 25 **loadall** | **help** }                       << 
 26                                                    20 
 27 PROG COMMANDS                                      21 PROG COMMANDS
 28 =============                                      22 =============
 29                                                    23 
 30 | **bpftool** **prog** { **show** | **list** } !!  24 |       **bpftool** **prog** { **show** | **list** } [*PROG*]
 31 | **bpftool** **prog dump xlated** *PROG* [{ * !!  25 |       **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual** | **linum**}]
 32 | **bpftool** **prog dump jited**  *PROG* [{ * !!  26 |       **bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes** | **linum**}]
 33 | **bpftool** **prog pin** *PROG* *FILE*       !!  27 |       **bpftool** **prog pin** *PROG* *FILE*
 34 | **bpftool** **prog** { **load** | **loadall* !!  28 |       **bpftool** **prog** { **load** | **loadall** } *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
 35 | **bpftool** **prog attach** *PROG* *ATTACH_T !!  29 |       **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
 36 | **bpftool** **prog detach** *PROG* *ATTACH_T !!  30 |       **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
 37 | **bpftool** **prog tracelog**                !!  31 |       **bpftool** **prog tracelog**
 38 | **bpftool** **prog run** *PROG* **data_in**  !!  32 |       **bpftool** **prog run** *PROG* **data_in** *FILE* [**data_out** *FILE* [**data_size_out** *L*]] [**ctx_in** *FILE* [**ctx_out** *FILE* [**ctx_size_out** *M*]]] [**repeat** *N*]
 39 | **bpftool** **prog profile** *PROG* [**durat !!  33 |       **bpftool** **prog profile** *PROG* [**duration** *DURATION*] *METRICs*
 40 | **bpftool** **prog help**                    !!  34 |       **bpftool** **prog help**
 41 |                                                  35 |
 42 | *MAP* := { **id** *MAP_ID* | **pinned** *FIL !!  36 |       *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
 43 | *PROG* := { **id** *PROG_ID* | **pinned** *F !!  37 |       *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* | **name** *PROG_NAME* }
 44 | *TYPE* := {                                  !!  38 |       *TYPE* := {
 45 |     **socket** | **kprobe** | **kretprobe**  !!  39 |               **socket** | **kprobe** | **kretprobe** | **classifier** | **action** |
 46 |     **tracepoint** | **raw_tracepoint** | ** !!  40 |               **tracepoint** | **raw_tracepoint** | **xdp** | **perf_event** | **cgroup/skb** |
 47 |     **cgroup/sock** | **cgroup/dev** | **lwt !!  41 |               **cgroup/sock** | **cgroup/dev** | **lwt_in** | **lwt_out** | **lwt_xmit** |
 48 |     **lwt_seg6local** | **sockops** | **sk_s !!  42 |               **lwt_seg6local** | **sockops** | **sk_skb** | **sk_msg** | **lirc_mode2** |
 49 |     **cgroup/bind4** | **cgroup/bind6** | ** !!  43 |               **cgroup/bind4** | **cgroup/bind6** | **cgroup/post_bind4** | **cgroup/post_bind6** |
 50 |     **cgroup/connect4** | **cgroup/connect6* !!  44 |               **cgroup/connect4** | **cgroup/connect6** | **cgroup/getpeername4** | **cgroup/getpeername6** |
 51 |     **cgroup/getpeername4** | **cgroup/getpe !!  45 |               **cgroup/getsockname4** | **cgroup/getsockname6** | **cgroup/sendmsg4** | **cgroup/sendmsg6** |
 52 |     **cgroup/getsockname4** | **cgroup/getso !!  46 |               **cgroup/recvmsg4** | **cgroup/recvmsg6** | **cgroup/sysctl** |
 53 |     **cgroup/sendmsg4** | **cgroup/sendmsg6* !!  47 |               **cgroup/getsockopt** | **cgroup/setsockopt** | **cgroup/sock_release** |
 54 |     **cgroup/recvmsg4** | **cgroup/recvmsg6* !!  48 |               **struct_ops** | **fentry** | **fexit** | **freplace** | **sk_lookup**
 55 |     **cgroup/getsockopt** | **cgroup/setsock !!  49 |       }
 56 |     **struct_ops** | **fentry** | **fexit**  !!  50 |       *ATTACH_TYPE* := {
 57 | }                                            !!  51 |               **msg_verdict** | **stream_verdict** | **stream_parser** | **flow_dissector**
 58 | *ATTACH_TYPE* := {                           !!  52 |       }
 59 |     **sk_msg_verdict** | **sk_skb_verdict**  !!  53 |       *METRICs* := {
 60 |     **sk_skb_stream_parser** | **flow_dissec !!  54 |               **cycles** | **instructions** | **l1d_loads** | **llc_misses**
 61 | }                                            !!  55 |       }
 62 | *METRICs* := {                               << 
 63 |     **cycles** | **instructions** | **l1d_lo << 
 64 |     **itlb_misses** | **dtlb_misses**        << 
 65 | }                                            << 
 66                                                    56 
 67                                                    57 
 68 DESCRIPTION                                        58 DESCRIPTION
 69 ===========                                        59 ===========
 70 bpftool prog { show | list } [*PROG*]          !!  60         **bpftool prog { show | list }** [*PROG*]
 71     Show information about loaded programs.  I !!  61                   Show information about loaded programs.  If *PROG* is
 72     information only about given programs, oth !!  62                   specified show information only about given programs,
 73     currently loaded on the system. In case of !!  63                   otherwise list all programs currently loaded on the system.
 74     match several programs which will all be s !!  64                   In case of **tag** or **name**, *PROG* may match several
 75                                                !!  65                   programs which will all be shown.
 76     Output will start with program ID followed !!  66 
 77     named attributes (depending on kernel vers !!  67                   Output will start with program ID followed by program type and
 78                                                !!  68                   zero or more named attributes (depending on kernel version).
 79     Since Linux 5.1 the kernel can collect sta !!  69 
 80     the total time spent running the program,  !!  70                   Since Linux 5.1 the kernel can collect statistics on BPF
 81     run). If available, bpftool shows such sta !!  71                   programs (such as the total time spent running the program,
 82     not collect them by defaults, as it slight !!  72                   and the number of times it was run). If available, bpftool
 83     program run. Activation or deactivation of !!  73                   shows such statistics. However, the kernel does not collect
 84     **kernel.bpf_stats_enabled** sysctl knob.  !!  74                   them by defaults, as it slightly impacts performance on each
 85                                                !!  75                   program run. Activation or deactivation of the feature is
 86     Since Linux 5.8 bpftool is able to discove !!  76                   performed via the **kernel.bpf_stats_enabled** sysctl knob.
 87     that hold open file descriptors (FDs) agai !!  77 
 88     bpftool will automatically emit this infor !!  78                   Since Linux 5.8 bpftool is able to discover information about
 89                                                !!  79                   processes that hold open file descriptors (FDs) against BPF
 90 bpftool prog dump xlated *PROG* [{ file *FILE* !!  80                   programs. On such kernels bpftool will automatically emit this
 91     Dump eBPF instructions of the programs fro !!  81                   information as well.
 92     will be disassembled and printed to standa !!  82 
 93     format. In this case, **opcodes** controls !!  83         **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** | **linum** }]
 94     as well.                                   !!  84                   Dump eBPF instructions of the programs from the kernel. By
 95                                                !!  85                   default, eBPF will be disassembled and printed to standard
 96     In case of **tag** or **name**, *PROG* may !!  86                   output in human-readable format. In this case, **opcodes**
 97     will all be dumped.  However, if **file**  !!  87                   controls if raw opcodes should be printed as well.
 98     *PROG* must match a single program.        !!  88 
 99                                                !!  89                   In case of **tag** or **name**, *PROG* may match several
100     If **file** is specified, the binary image !!  90                   programs which will all be dumped.  However, if **file** or
101     *FILE*.                                    !!  91                   **visual** is specified, *PROG* must match a single program.
102                                                !!  92 
103     If **visual** is specified, control flow g !!  93                   If **file** is specified, the binary image will instead be
104     and eBPF instructions will be presented wi !!  94                   written to *FILE*.
105     output.                                    !!  95 
106                                                !!  96                   If **visual** is specified, control flow graph (CFG) will be
107     If the programs have line_info available,  !!  97                   built instead, and eBPF instructions will be presented with
108     displayed.  If **linum** is specified, the !!  98                   CFG in DOT format, on standard output.
109     column will also be displayed.             !!  99 
110                                                !! 100                   If the programs have line_info available, the source line will
111 bpftool prog dump jited  *PROG* [{ file *FILE* !! 101                   be displayed by default.  If **linum** is specified,
112     Dump jited image (host machine code) of th !! 102                   the filename, line number and line column will also be
113                                                !! 103                   displayed on top of the source line.
114     If *FILE* is specified image will be writt !! 104 
115     be disassembled and printed to stdout. *PR !! 105         **bpftool prog dump jited**  *PROG* [{ **file** *FILE* | **opcodes** | **linum** }]
116     when **file** is specified.                !! 106                   Dump jited image (host machine code) of the program.
117                                                !! 107 
118     **opcodes** controls if raw opcodes will b !! 108                   If *FILE* is specified image will be written to a file,
119                                                !! 109                   otherwise it will be disassembled and printed to stdout.
120     If the prog has line_info available, the s !! 110                   *PROG* must match a single program when **file** is specified.
121     **linum** is specified, the filename, line !! 111 
122     be displayed.                              !! 112                   **opcodes** controls if raw opcodes will be printed.
123                                                !! 113 
124 bpftool prog pin *PROG* *FILE*                 !! 114                   If the prog has line_info available, the source line will
125     Pin program *PROG* as *FILE*.              !! 115                   be displayed by default.  If **linum** is specified,
126                                                !! 116                   the filename, line number and line column will also be
127     Note: *FILE* must be located in *bpffs* mo !! 117                   displayed on top of the source line.
128     character ('.'), which is reserved for fut !! 118 
129                                                !! 119         **bpftool prog pin** *PROG* *FILE*
130 bpftool prog { load | loadall } *OBJ* *PATH* [ !! 120                   Pin program *PROG* as *FILE*.
131     Load bpf program(s) from binary *OBJ* and  !! 121 
132     load** pins only the first program from th !! 122                   Note: *FILE* must be located in *bpffs* mount. It must not
133     loadall** pins all programs from the *OBJ* !! 123                   contain a dot character ('.'), which is reserved for future
134     is optional, if not specified program type !! 124                   extensions of *bpffs*.
135     names. By default bpftool will create new  !! 125 
136     object being loaded.  **map** parameter al !! 126         **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
137     maps. It can be specified multiple times,  !! 127                   Load bpf program(s) from binary *OBJ* and pin as *PATH*.
138     *IDX* refers to index of the map to be rep !! 128                   **bpftool prog load** pins only the first program from the
139     from 0, while *NAME* allows to replace a m !! 129                   *OBJ* as *PATH*. **bpftool prog loadall** pins all programs
140     map to use, referring to it by **id** or t !! 130                   from the *OBJ* under *PATH* directory.
141     **offload_dev** *NAME* is specified progra !! 131                   **type** is optional, if not specified program type will be
142     networking device (offload). If **xdpmeta_ !! 132                   inferred from section names.
143     will become device-bound without offloadin !! 133                   By default bpftool will create new maps as declared in the ELF
144     metadata. Optional **pinmaps** argument ca !! 134                   object being loaded.  **map** parameter allows for the reuse
145     under *MAP_DIR* directory.                 !! 135                   of existing maps.  It can be specified multiple times, each
146                                                !! 136                   time for a different map.  *IDX* refers to index of the map
147     If **autoattach** is specified program wil !! 137                   to be replaced in the ELF file counting from 0, while *NAME*
148     case, only the link (representing the prog !! 138                   allows to replace a map by name.  *MAP* specifies the map to
149     pinned, not the program as such, so the pa !! 139                   use, referring to it by **id** or through a **pinned** file.
150     show -f**, only show in **bpftool link sho !! 140                   If **dev** *NAME* is specified program will be loaded onto
151     when bpftool (libbpf) is able to infer all !! 141                   given networking device (offload).
152     object file, in particular, it's not suppo !! 142                   Optional **pinmaps** argument can be provided to pin all
153     program does not support autoattach, bpfto !! 143                   maps under *MAP_DIR* directory.
154     for that program instead.                  !! 144 
155                                                !! 145                   Note: *PATH* must be located in *bpffs* mount. It must not
156     Note: *PATH* must be located in *bpffs* mo !! 146                   contain a dot character ('.'), which is reserved for future
157     character ('.'), which is reserved for fut !! 147                   extensions of *bpffs*.
158                                                !! 148 
159 bpftool prog attach *PROG* *ATTACH_TYPE* [*MAP !! 149         **bpftool prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
160     Attach bpf program *PROG* (with type speci !! 150                   Attach bpf program *PROG* (with type specified by
161     *ATTACH_TYPEs* require a *MAP* parameter,  !! 151                   *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP*
162     *flow_dissector* which is attached to curr !! 152                   parameter, with the exception of *flow_dissector* which is
163                                                !! 153                   attached to current networking name space.
164 bpftool prog detach *PROG* *ATTACH_TYPE* [*MAP !! 154 
165     Detach bpf program *PROG* (with type speci !! 155         **bpftool prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
166     *ATTACH_TYPEs* require a *MAP* parameter,  !! 156                   Detach bpf program *PROG* (with type specified by
167     *flow_dissector* which is detached from th !! 157                   *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP*
168                                                !! 158                   parameter, with the exception of *flow_dissector* which is
169 bpftool prog tracelog                          !! 159                   detached from the current networking name space.
170     Dump the trace pipe of the system to the c !! 160 
171     stop printing. BPF programs can write to t !! 161         **bpftool prog tracelog**
172     the **bpf_trace_printk**\ () helper. This  !! 162                   Dump the trace pipe of the system to the console (stdout).
173     purposes. For streaming data from BPF prog !! 163                   Hit <Ctrl+C> to stop printing. BPF programs can write to this
174     perf events (see also **bpftool-map**\ (8) !! 164                   trace pipe at runtime with the **bpf_trace_printk**\ () helper.
175                                                !! 165                   This should be used only for debugging purposes. For
176 bpftool prog run *PROG* data_in *FILE* [data_o !! 166                   streaming data from BPF programs to user space, one can use
177     Run BPF program *PROG* in the kernel testi !! 167                   perf events (see also **bpftool-map**\ (8)).
178     meaning that the program works on the data !! 168 
179     user, and not on actual packets or monitor !! 169         **bpftool prog run** *PROG* **data_in** *FILE* [**data_out** *FILE* [**data_size_out** *L*]] [**ctx_in** *FILE* [**ctx_out** *FILE* [**ctx_size_out** *M*]]] [**repeat** *N*]
180     and duration for the test run are printed  !! 170                   Run BPF program *PROG* in the kernel testing infrastructure
181                                                !! 171                   for BPF, meaning that the program works on the data and
182     Input data is read from the *FILE* passed  !! 172                   context provided by the user, and not on actual packets or
183     is "**-**", input data is read from standa !! 173                   monitored functions etc. Return value and duration for the
184     is read from *FILE* passed with **ctx_in** !! 174                   test run are printed out to the console.
185     read from standard input, but only if stan !! 175 
186     for input data. If a *FILE* is passed with !! 176                   Input data is read from the *FILE* passed with **data_in**.
187     written to that file. Similarly, output co !! 177                   If this *FILE* is "**-**", input data is read from standard
188     passed with **ctx_out**. For both output f !! 178                   input. Input context, if any, is read from *FILE* passed with
189     print to the standard output (as plain tex !! 179                   **ctx_in**. Again, "**-**" can be used to read from standard
190     passed). If output keywords are omitted, o !! 180                   input, but only if standard input is not already in use for
191     discarded. Keywords **data_size_out** and  !! 181                   input data. If a *FILE* is passed with **data_out**, output
192     the size (in bytes) for the output buffers !! 182                   data is written to that file. Similarly, output context is
193     default of 32 kB should be more than enoug !! 183                   written to the *FILE* passed with **ctx_out**. For both
194                                                !! 184                   output flows, "**-**" can be used to print to the standard
195     Keyword **repeat** is used to indicate the !! 185                   output (as plain text, or JSON if relevant option was
196     perform. Note that output data and context !! 186                   passed). If output keywords are omitted, output data and
197     the last of those runs. The duration print !! 187                   context are discarded. Keywords **data_size_out** and
198     an average over all runs performed by the  !! 188                   **ctx_size_out** are used to pass the size (in bytes) for the
199                                                !! 189                   output buffers to the kernel, although the default of 32 kB
200     Not all program types support test run. Am !! 190                   should be more than enough for most cases.
201     them can take the **ctx_in**/**ctx_out** a !! 191 
202     perform checks on program types.           !! 192                   Keyword **repeat** is used to indicate the number of
203                                                !! 193                   consecutive runs to perform. Note that output data and
204 bpftool prog profile *PROG* [duration *DURATIO !! 194                   context printed to files correspond to the last of those
205     Profile *METRICs* for bpf program *PROG* f !! 195                   runs. The duration printed out at the end of the runs is an
206     user hits <Ctrl+C>. *DURATION* is optional !! 196                   average over all runs performed by the command.
207     the profiling will run up to **UINT_MAX**  !! 197 
                                                   >> 198                   Not all program types support test run. Among those which do,
                                                   >> 199                   not all of them can take the **ctx_in**/**ctx_out**
                                                   >> 200                   arguments. bpftool does not perform checks on program types.
                                                   >> 201 
                                                   >> 202         **bpftool prog profile** *PROG* [**duration** *DURATION*] *METRICs*
                                                   >> 203                   Profile *METRICs* for bpf program *PROG* for *DURATION*
                                                   >> 204                   seconds or until user hits <Ctrl+C>. *DURATION* is optional.
                                                   >> 205                   If *DURATION* is not specified, the profiling will run up to
                                                   >> 206                   **UINT_MAX** seconds.
208                                                   207 
209 bpftool prog help                              !! 208         **bpftool prog help**
210     Print short help message.                  !! 209                   Print short help message.
211                                                   210 
212 OPTIONS                                           211 OPTIONS
213 =======                                           212 =======
214 .. include:: common_options.rst                !! 213         .. include:: common_options.rst
215                                                << 
216 -f, --bpffs                                    << 
217     When showing BPF programs, show file names << 
218                                                << 
219 -m, --mapcompat                                << 
220     Allow loading maps with unknown map defini << 
221                                                   214 
222 -n, --nomount                                  !! 215         -f, --bpffs
223     Do not automatically attempt to mount any  !! 216                   When showing BPF programs, show file names of pinned
224     tracefs or BPF virtual file system) when n !! 217                   programs.
225                                                !! 218 
226 -L, --use-loader                               !! 219         -m, --mapcompat
227     Load program as a "loader" program. This i !! 220                   Allow loading maps with unknown map definitions.
228     of such programs. When this option is in u !! 221 
229     programs from the object file into the ker !! 222         -n, --nomount
230     (therefore, the *PATH* must not be provide !! 223                   Do not automatically attempt to mount any virtual file system
231                                                !! 224                   (such as tracefs or BPF virtual file system) when necessary.
232     When combined with the **-d**\ \|\ **--deb << 
233     messages are generated, and the execution  << 
234     the **bpf_trace_printk**\ () helper to log << 
235     creating the maps, and loading the program << 
236     as a way to dump those messages).          << 
237                                                   225 
238 EXAMPLES                                          226 EXAMPLES
239 ========                                          227 ========
240 **# bpftool prog show**                           228 **# bpftool prog show**
241                                                   229 
242 ::                                                230 ::
243                                                   231 
244     10: xdp  name some_prog  tag 005a3d2123620    232     10: xdp  name some_prog  tag 005a3d2123620c8b  gpl run_time_ns 81632 run_cnt 10
245             loaded_at 2017-09-29T20:11:00+0000    233             loaded_at 2017-09-29T20:11:00+0000  uid 0
246             xlated 528B  jited 370B  memlock 4    234             xlated 528B  jited 370B  memlock 4096B  map_ids 10
247             pids systemd(1)                       235             pids systemd(1)
248                                                   236 
249 **# bpftool --json --pretty prog show**           237 **# bpftool --json --pretty prog show**
250                                                   238 
251 ::                                                239 ::
252                                                   240 
253     [{                                            241     [{
254             "id": 10,                             242             "id": 10,
255             "type": "xdp",                        243             "type": "xdp",
256             "tag": "005a3d2123620c8b",            244             "tag": "005a3d2123620c8b",
257             "gpl_compatible": true,               245             "gpl_compatible": true,
258             "run_time_ns": 81632,                 246             "run_time_ns": 81632,
259             "run_cnt": 10,                        247             "run_cnt": 10,
260             "loaded_at": 1506715860,              248             "loaded_at": 1506715860,
261             "uid": 0,                             249             "uid": 0,
262             "bytes_xlated": 528,                  250             "bytes_xlated": 528,
263             "jited": true,                        251             "jited": true,
264             "bytes_jited": 370,                   252             "bytes_jited": 370,
265             "bytes_memlock": 4096,                253             "bytes_memlock": 4096,
266             "map_ids": [10                        254             "map_ids": [10
267             ],                                    255             ],
268             "pids": [{                            256             "pids": [{
269                     "pid": 1,                     257                     "pid": 1,
270                     "comm": "systemd"             258                     "comm": "systemd"
271                 }                                 259                 }
272             ]                                     260             ]
273         }                                         261         }
274     ]                                             262     ]
275                                                   263 
276 |                                                 264 |
277 | **# bpftool prog dump xlated id 10 file /tmp    265 | **# bpftool prog dump xlated id 10 file /tmp/t**
278 | **$ ls -l /tmp/t**                              266 | **$ ls -l /tmp/t**
279                                                   267 
280 ::                                                268 ::
281                                                   269 
282     -rw------- 1 root root 560 Jul 22 01:42 /t    270     -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
283                                                   271 
284 **# bpftool prog dump jited tag 005a3d2123620c    272 **# bpftool prog dump jited tag 005a3d2123620c8b**
285                                                   273 
286 ::                                                274 ::
287                                                   275 
288     0:   push   %rbp                              276     0:   push   %rbp
289     1:   mov    %rsp,%rbp                         277     1:   mov    %rsp,%rbp
290     2:   sub    $0x228,%rsp                       278     2:   sub    $0x228,%rsp
291     3:   sub    $0x28,%rbp                        279     3:   sub    $0x28,%rbp
292     4:   mov    %rbx,0x0(%rbp)                    280     4:   mov    %rbx,0x0(%rbp)
293                                                   281 
294 |                                                 282 |
295 | **# mount -t bpf none /sys/fs/bpf/**            283 | **# mount -t bpf none /sys/fs/bpf/**
296 | **# bpftool prog pin id 10 /sys/fs/bpf/prog*    284 | **# bpftool prog pin id 10 /sys/fs/bpf/prog**
297 | **# bpftool prog load ./my_prog.o /sys/fs/bp    285 | **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2**
298 | **# ls -l /sys/fs/bpf/**                        286 | **# ls -l /sys/fs/bpf/**
299                                                   287 
300 ::                                                288 ::
301                                                   289 
302     -rw------- 1 root root 0 Jul 22 01:43 prog    290     -rw------- 1 root root 0 Jul 22 01:43 prog
303     -rw------- 1 root root 0 Jul 22 01:44 prog    291     -rw------- 1 root root 0 Jul 22 01:44 prog2
304                                                   292 
305 **# bpftool prog dump jited pinned /sys/fs/bpf    293 **# bpftool prog dump jited pinned /sys/fs/bpf/prog opcodes**
306                                                   294 
307 ::                                                295 ::
308                                                   296 
309    0:   push   %rbp                               297    0:   push   %rbp
310         55                                        298         55
311    1:   mov    %rsp,%rbp                          299    1:   mov    %rsp,%rbp
312         48 89 e5                                  300         48 89 e5
313    4:   sub    $0x228,%rsp                        301    4:   sub    $0x228,%rsp
314         48 81 ec 28 02 00 00                      302         48 81 ec 28 02 00 00
315    b:   sub    $0x28,%rbp                         303    b:   sub    $0x28,%rbp
316         48 83 ed 28                               304         48 83 ed 28
317    f:   mov    %rbx,0x0(%rbp)                     305    f:   mov    %rbx,0x0(%rbp)
318         48 89 5d 00                               306         48 89 5d 00
319                                                   307 
320 |                                                 308 |
321 | **# bpftool prog load xdp1_kern.o /sys/fs/bp    309 | **# bpftool prog load xdp1_kern.o /sys/fs/bpf/xdp1 type xdp map name rxcnt id 7**
322 | **# bpftool prog show pinned /sys/fs/bpf/xdp    310 | **# bpftool prog show pinned /sys/fs/bpf/xdp1**
323                                                   311 
324 ::                                                312 ::
325                                                   313 
326     9: xdp  name xdp_prog1  tag 539ec6ce11b52f    314     9: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
327             loaded_at 2018-06-25T16:17:31-0700    315             loaded_at 2018-06-25T16:17:31-0700  uid 0
328             xlated 488B  jited 336B  memlock 4    316             xlated 488B  jited 336B  memlock 4096B  map_ids 7
329                                                   317 
330 **# rm /sys/fs/bpf/xdp1**                         318 **# rm /sys/fs/bpf/xdp1**
331                                                   319 
332 |                                                 320 |
333 | **# bpftool prog profile id 337 duration 10     321 | **# bpftool prog profile id 337 duration 10 cycles instructions llc_misses**
334                                                   322 
335 ::                                                323 ::
336                                                   324 
337          51397 run_cnt                            325          51397 run_cnt
338       40176203 cycles                             326       40176203 cycles                                                 (83.05%)
339       42518139 instructions    #   1.06 insns     327       42518139 instructions    #   1.06 insns per cycle               (83.39%)
340            123 llc_misses      #   2.89 LLC mi    328            123 llc_misses      #   2.89 LLC misses per million insns  (83.15%)
341                                                << 
342 |                                              << 
343 | Output below is for the trace logs.          << 
344 | Run in separate terminals:                   << 
345 | **# bpftool prog tracelog**                  << 
346 | **# bpftool prog load -L -d file.o**         << 
347                                                << 
348 ::                                             << 
349                                                << 
350     bpftool-620059  [004] d... 2634685.517903: << 
351     bpftool-620059  [004] d... 2634685.517912: << 
352     bpftool-620059  [004] d... 2634685.517997: << 
353     bpftool-620059  [004] d... 2634685.517999: << 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php