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 specified show
38 information only about given link, otherwise list all links currently
41 Output will start with link ID followed by link type and zero or more named
42 attributes, some of which depend on type of link.
44 Since Linux 5.8 bpftool is able to discover information about processes
45 that hold open file descriptors (FDs) against BPF links. On such kernels
46 bpftool will automatically emit this information as well.
48 bpftool link pin *LINK* *FILE*
49 Pin link *LINK* as *FILE*.
51 Note: *FILE* must be located in *bpffs* mount. It must not contain a dot
52 character ('.'), which is reserved for future extensions of *bpffs*.
54 bpftool link detach *LINK*
55 Force-detach link *LINK*. BPF link and its underlying BPF program will stay
56 valid, but they will be detached from the respective BPF hook and BPF link
57 will transition into a defunct state until last open file descriptor for
61 Print short help message.
65 .. include:: common_options.rst
68 When showing BPF links, show file names of pinned links.
71 Do not automatically attempt to mount any virtual file system (such as
72 tracefs or BPF virtual file system) when necessary.
76 **# bpftool link show**
81 cgroup_id 614 attach_type egress
84 **# bpftool --json --pretty link show**
92 "attach_type": "egress",
102 | **# bpftool link pin id 10 /sys/fs/bpf/link**
103 | **# ls -l /sys/fs/bpf/**
107 -rw------- 1 root root 0 Apr 23 21:39 link