1 .. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
6 -------------------------------------------------------------------------------
7 tool for inspection and simple manipulation of eBPF links
8 -------------------------------------------------------------------------------
12 .. include:: substitutions.rst
17 **bpftool** [*OPTIONS*] **link** *COMMAND*
19 *OPTIONS* := { |COMMON_OPTIONS| | { **-f** | **--bpffs** } | { **-n** | **--nomount** } }
21 *COMMANDS* := { **show** | **list** | **pin** | **help** }
26 | **bpftool** **link { show | list }** [*LINK*]
27 | **bpftool** **link pin** *LINK* *FILE*
28 | **bpftool** **link detach** *LINK*
29 | **bpftool** **link help**
31 | *LINK* := { **id** *LINK_ID* | **pinned** *FILE* }
36 **bpftool link { show | list }** [*LINK*]
37 Show information about active links. If *LINK* is
38 specified show information only about given link,
39 otherwise list all links currently active on the system.
41 Output will start with link ID followed by link type and
42 zero or more named attributes, some of which depend on type
45 Since Linux 5.8 bpftool is able to discover information about
46 processes that hold open file descriptors (FDs) against BPF
47 links. On such kernels bpftool will automatically emit this
50 **bpftool link pin** *LINK* *FILE*
51 Pin link *LINK* as *FILE*.
53 Note: *FILE* must be located in *bpffs* mount. It must not
54 contain a dot character ('.'), which is reserved for future
55 extensions of *bpffs*.
57 **bpftool link detach** *LINK*
58 Force-detach link *LINK*. BPF link and its underlying BPF
59 program will stay valid, but they will be detached from the
60 respective BPF hook and BPF link will transition into
61 a defunct state until last open file descriptor for that
65 Print short help message.
69 .. include:: common_options.rst
72 When showing BPF links, show file names of pinned
76 Do not automatically attempt to mount any virtual file system
77 (such as tracefs or BPF virtual file system) when necessary.
81 **# bpftool link show**
86 cgroup_id 614 attach_type egress
89 **# bpftool --json --pretty link show**
97 "attach_type": "egress",
107 | **# bpftool link pin id 10 /sys/fs/bpf/link**
108 | **# ls -l /sys/fs/bpf/**
112 -rw------- 1 root root 0 Apr 23 21:39 link