Merge branch 'master' into fixes
[linux-2.6-microblaze.git] / tools / bpf / bpftool / Documentation / bpftool-prog.rst
index ecf6188..58c8369 100644 (file)
@@ -15,18 +15,20 @@ SYNOPSIS
        *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
 
        *COMMANDS* :=
-       { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | **help** }
+       { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load**
+       | **loadall** | **help** }
 
 MAP COMMANDS
 =============
 
 |      **bpftool** **prog { show | list }** [*PROG*]
-|      **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual**}]
-|      **bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes**}]
+|      **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes** | **visual** | **linum**}]
+|      **bpftool** **prog dump jited**  *PROG* [{**file** *FILE* | **opcodes** | **linum**}]
 |      **bpftool** **prog pin** *PROG* *FILE*
-|      **bpftool** **prog load** *OBJ* *FILE* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*]
-|       **bpftool** **prog attach** *PROG* *ATTACH_TYPE* *MAP*
-|       **bpftool** **prog detach** *PROG* *ATTACH_TYPE* *MAP*
+|      **bpftool** **prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*]
+|      **bpftool** **prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
+|      **bpftool** **prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
+|      **bpftool** **prog tracelog**
 |      **bpftool** **prog help**
 |
 |      *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
@@ -39,7 +41,9 @@ MAP COMMANDS
 |              **cgroup/bind4** | **cgroup/bind6** | **cgroup/post_bind4** | **cgroup/post_bind6** |
 |              **cgroup/connect4** | **cgroup/connect6** | **cgroup/sendmsg4** | **cgroup/sendmsg6**
 |      }
-|       *ATTACH_TYPE* := { **msg_verdict** | **skb_verdict** | **skb_parse** }
+|       *ATTACH_TYPE* := {
+|              **msg_verdict** | **skb_verdict** | **skb_parse** | **flow_dissector**
+|      }
 
 
 DESCRIPTION
@@ -52,7 +56,7 @@ DESCRIPTION
                  Output will start with program ID followed by program type and
                  zero or more named attributes (depending on kernel version).
 
-       **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** }]
+       **bpftool prog dump xlated** *PROG* [{ **file** *FILE* | **opcodes** | **visual** | **linum** }]
                  Dump eBPF instructions of the program from the kernel. By
                  default, eBPF will be disassembled and printed to standard
                  output in human-readable format. In this case, **opcodes**
@@ -65,13 +69,23 @@ DESCRIPTION
                  built instead, and eBPF instructions will be presented with
                  CFG in DOT format, on standard output.
 
-       **bpftool prog dump jited**  *PROG* [{ **file** *FILE* | **opcodes** }]
+                 If the prog has line_info available, the source line will
+                 be displayed by default.  If **linum** is specified,
+                 the filename, line number and line column will also be
+                 displayed on top of the source line.
+
+       **bpftool prog dump jited**  *PROG* [{ **file** *FILE* | **opcodes** | **linum** }]
                  Dump jited image (host machine code) of the program.
                  If *FILE* is specified image will be written to a file,
                  otherwise it will be disassembled and printed to stdout.
 
                  **opcodes** controls if raw opcodes will be printed.
 
+                 If the prog has line_info available, the source line will
+                 be displayed by default.  If **linum** is specified,
+                 the filename, line number and line column will also be
+                 displayed on top of the source line.
+
        **bpftool prog pin** *PROG* *FILE*
                  Pin program *PROG* as *FILE*.
 
@@ -79,8 +93,11 @@ DESCRIPTION
                  contain a dot character ('.'), which is reserved for future
                  extensions of *bpffs*.
 
-       **bpftool prog load** *OBJ* *FILE* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*]
-                 Load bpf program from binary *OBJ* and pin as *FILE*.
+       **bpftool prog { load | loadall }** *OBJ* *PATH* [**type** *TYPE*] [**map** {**idx** *IDX* | **name** *NAME*} *MAP*] [**dev** *NAME*] [**pinmaps** *MAP_DIR*]
+                 Load bpf program(s) from binary *OBJ* and pin as *PATH*.
+                 **bpftool prog load** pins only the first program from the
+                 *OBJ* as *PATH*. **bpftool prog loadall** pins all programs
+                 from the *OBJ* under *PATH* directory.
                  **type** is optional, if not specified program type will be
                  inferred from section names.
                  By default bpftool will create new maps as declared in the ELF
@@ -92,18 +109,32 @@ DESCRIPTION
                  use, referring to it by **id** or through a **pinned** file.
                  If **dev** *NAME* is specified program will be loaded onto
                  given networking device (offload).
+                 Optional **pinmaps** argument can be provided to pin all
+                 maps under *MAP_DIR* directory.
 
-                 Note: *FILE* must be located in *bpffs* mount. It must not
+                 Note: *PATH* must be located in *bpffs* mount. It must not
                  contain a dot character ('.'), which is reserved for future
                  extensions of *bpffs*.
 
-        **bpftool prog attach** *PROG* *ATTACH_TYPE* *MAP*
-                  Attach bpf program *PROG* (with type specified by *ATTACH_TYPE*)
-                  to the map *MAP*.
-
-        **bpftool prog detach** *PROG* *ATTACH_TYPE* *MAP*
-                  Detach bpf program *PROG* (with type specified by *ATTACH_TYPE*)
-                  from the map *MAP*.
+       **bpftool prog attach** *PROG* *ATTACH_TYPE* [*MAP*]
+                 Attach bpf program *PROG* (with type specified by
+                 *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP*
+                 parameter, with the exception of *flow_dissector* which is
+                 attached to current networking name space.
+
+       **bpftool prog detach** *PROG* *ATTACH_TYPE* [*MAP*]
+                 Detach bpf program *PROG* (with type specified by
+                 *ATTACH_TYPE*). Most *ATTACH_TYPEs* require a *MAP*
+                 parameter, with the exception of *flow_dissector* which is
+                 detached from the current networking name space.
+
+       **bpftool prog tracelog**
+                 Dump the trace pipe of the system to the console (stdout).
+                 Hit <Ctrl+C> to stop printing. BPF programs can write to this
+                 trace pipe at runtime with the **bpf_trace_printk()** helper.
+                 This should be used only for debugging purposes. For
+                 streaming data from BPF programs to user space, one can use
+                 perf events (see also **bpftool-map**\ (8)).
 
        **bpftool prog help**
                  Print short help message.
@@ -127,83 +158,98 @@ OPTIONS
                  When showing BPF programs, show file names of pinned
                  programs.
 
+       -m, --mapcompat
+                 Allow loading maps with unknown map definitions.
+
+       -n, --nomount
+                 Do not automatically attempt to mount any virtual file system
+                 (such as tracefs or BPF virtual file system) when necessary.
+
 EXAMPLES
 ========
 **# bpftool prog show**
+
 ::
 
-  10: xdp  name some_prog  tag 005a3d2123620c8b  gpl
-       loaded_at Sep 29/20:11  uid 0
-       xlated 528B  jited 370B  memlock 4096B  map_ids 10
+    10: xdp  name some_prog  tag 005a3d2123620c8b  gpl
+            loaded_at 2017-09-29T20:11:00+0000  uid 0
+            xlated 528B  jited 370B  memlock 4096B  map_ids 10
 
 **# bpftool --json --pretty prog show**
 
 ::
 
-    {
-        "programs": [{
-                "id": 10,
-                "type": "xdp",
-                "tag": "005a3d2123620c8b",
-                "gpl_compatible": true,
-                "loaded_at": "Sep 29/20:11",
-                "uid": 0,
-                "bytes_xlated": 528,
-                "jited": true,
-                "bytes_jited": 370,
-                "bytes_memlock": 4096,
-                "map_ids": [10
-                ]
-            }
-        ]
-    }
+    [{
+            "id": 10,
+            "type": "xdp",
+            "tag": "005a3d2123620c8b",
+            "gpl_compatible": true,
+            "loaded_at": 1506715860,
+            "uid": 0,
+            "bytes_xlated": 528,
+            "jited": true,
+            "bytes_jited": 370,
+            "bytes_memlock": 4096,
+            "map_ids": [10
+            ]
+        }
+    ]
 
 |
 | **# bpftool prog dump xlated id 10 file /tmp/t**
 | **# ls -l /tmp/t**
-|   -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
 
-**# bpftool prog dum jited tag 005a3d2123620c8b**
+::
+
+    -rw------- 1 root root 560 Jul 22 01:42 /tmp/t
+
+**# bpftool prog dump jited tag 005a3d2123620c8b**
 
 ::
 
-    push   %rbp
-    mov    %rsp,%rbp
-    sub    $0x228,%rsp
-    sub    $0x28,%rbp
-    mov    %rbx,0x0(%rbp)
+    0:   push   %rbp
+    1:   mov    %rsp,%rbp
+    2:   sub    $0x228,%rsp
+    3:   sub    $0x28,%rbp
+    4:   mov    %rbx,0x0(%rbp)
 
 |
 | **# mount -t bpf none /sys/fs/bpf/**
 | **# bpftool prog pin id 10 /sys/fs/bpf/prog**
 | **# bpftool prog load ./my_prog.o /sys/fs/bpf/prog2**
 | **# ls -l /sys/fs/bpf/**
-|   -rw------- 1 root root 0 Jul 22 01:43 prog
-|   -rw------- 1 root root 0 Jul 22 01:44 prog2
 
-**# bpftool prog dum jited pinned /sys/fs/bpf/prog opcodes**
+::
+
+    -rw------- 1 root root 0 Jul 22 01:43 prog
+    -rw------- 1 root root 0 Jul 22 01:44 prog2
+
+**# bpftool prog dump jited pinned /sys/fs/bpf/prog opcodes**
 
 ::
 
-    push   %rbp
-    55
-    mov    %rsp,%rbp
-    48 89 e5
-    sub    $0x228,%rsp
-    48 81 ec 28 02 00 00
-    sub    $0x28,%rbp
-    48 83 ed 28
-    mov    %rbx,0x0(%rbp)
-    48 89 5d 00
+   0:   push   %rbp
+        55
+   1:   mov    %rsp,%rbp
+        48 89 e5
+   4:   sub    $0x228,%rsp
+        48 81 ec 28 02 00 00
+   b:   sub    $0x28,%rbp
+        48 83 ed 28
+   f:   mov    %rbx,0x0(%rbp)
+        48 89 5d 00
 
 |
 | **# bpftool prog load xdp1_kern.o /sys/fs/bpf/xdp1 type xdp map name rxcnt id 7**
 | **# bpftool prog show pinned /sys/fs/bpf/xdp1**
-|   9: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
-|      loaded_at 2018-06-25T16:17:31-0700  uid 0
-|      xlated 488B  jited 336B  memlock 4096B  map_ids 7
-| **# rm /sys/fs/bpf/xdp1**
-|
+
+::
+
+    9: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
+            loaded_at 2018-06-25T16:17:31-0700  uid 0
+            xlated 488B  jited 336B  memlock 4096B  map_ids 7
+
+**# rm /sys/fs/bpf/xdp1**
 
 SEE ALSO
 ========