Merge tag 'x86-urgent-2020-08-15' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux/fpc-iii.git] / tools / bpf / bpftool / Documentation / bpftool-link.rst
blob4a52e7a933399c0df5e6e50ef32e02af25c70799
1 ================
2 bpftool-link
3 ================
4 -------------------------------------------------------------------------------
5 tool for inspection and simple manipulation of eBPF links
6 -------------------------------------------------------------------------------
8 :Manual section: 8
10 SYNOPSIS
11 ========
13         **bpftool** [*OPTIONS*] **link** *COMMAND*
15         *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
17         *COMMANDS* := { **show** | **list** | **pin** | **help** }
19 LINK COMMANDS
20 =============
22 |       **bpftool** **link { show | list }** [*LINK*]
23 |       **bpftool** **link pin** *LINK* *FILE*
24 |       **bpftool** **link detach *LINK*
25 |       **bpftool** **link help**
27 |       *LINK* := { **id** *LINK_ID* | **pinned** *FILE* }
30 DESCRIPTION
31 ===========
32         **bpftool link { show | list }** [*LINK*]
33                   Show information about active links. If *LINK* is
34                   specified show information only about given link,
35                   otherwise list all links currently active on the system.
37                   Output will start with link ID followed by link type and
38                   zero or more named attributes, some of which depend on type
39                   of link.
41                   Since Linux 5.8 bpftool is able to discover information about
42                   processes that hold open file descriptors (FDs) against BPF
43                   links. On such kernels bpftool will automatically emit this
44                   information as well.
46         **bpftool link pin** *LINK* *FILE*
47                   Pin link *LINK* as *FILE*.
49                   Note: *FILE* must be located in *bpffs* mount. It must not
50                   contain a dot character ('.'), which is reserved for future
51                   extensions of *bpffs*.
53         **bpftool link detach** *LINK*
54                   Force-detach link *LINK*. BPF link and its underlying BPF
55                   program will stay valid, but they will be detached from the
56                   respective BPF hook and BPF link will transition into
57                   a defunct state until last open file descriptor for that
58                   link is closed.
60         **bpftool link help**
61                   Print short help message.
63 OPTIONS
64 =======
65         -h, --help
66                   Print short generic help message (similar to **bpftool help**).
68         -V, --version
69                   Print version number (similar to **bpftool version**).
71         -j, --json
72                   Generate JSON output. For commands that cannot produce JSON, this
73                   option has no effect.
75         -p, --pretty
76                   Generate human-readable JSON output. Implies **-j**.
78         -f, --bpffs
79                   When showing BPF links, show file names of pinned
80                   links.
82         -n, --nomount
83                   Do not automatically attempt to mount any virtual file system
84                   (such as tracefs or BPF virtual file system) when necessary.
86         -d, --debug
87                   Print all logs available, even debug-level information. This
88                   includes logs from libbpf.
90 EXAMPLES
91 ========
92 **# bpftool link show**
96     10: cgroup  prog 25
97             cgroup_id 614  attach_type egress
98             pids test_progs(223)
100 **# bpftool --json --pretty link show**
104     [{
105             "type": "cgroup",
106             "prog_id": 25,
107             "cgroup_id": 614,
108             "attach_type": "egress",
109             "pids": [{
110                     "pid": 223,
111                     "comm": "test_progs"
112                 }
113             ]
114         }
115     ]
118 | **# bpftool link pin id 10 /sys/fs/bpf/link**
119 | **# ls -l /sys/fs/bpf/**
123     -rw------- 1 root root 0 Apr 23 21:39 link
126 SEE ALSO
127 ========
128         **bpf**\ (2),
129         **bpf-helpers**\ (7),
130         **bpftool**\ (8),
131         **bpftool-btf**\ (8),
132         **bpftool-cgroup**\ (8),
133         **bpftool-feature**\ (8),
134         **bpftool-gen**\ (8),
135         **bpftool-iter**\ (8),
136         **bpftool-map**\ (8),
137         **bpftool-net**\ (8),
138         **bpftool-perf**\ (8),
139         **bpftool-prog**\ (8),
140         **bpftool-struct_ops**\ (8)