4 -------------------------------------------------------------------------------
5 tool for inspection and simple manipulation of eBPF links
6 -------------------------------------------------------------------------------
13 **bpftool** [*OPTIONS*] **link** *COMMAND*
15 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
17 *COMMANDS* := { **show** | **list** | **pin** | **help** }
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* }
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
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
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
61 Print short help message.
66 Print short generic help message (similar to **bpftool help**).
69 Print version number (similar to **bpftool version**).
72 Generate JSON output. For commands that cannot produce JSON, this
76 Generate human-readable JSON output. Implies **-j**.
79 When showing BPF links, show file names of pinned
83 Do not automatically attempt to mount any virtual file system
84 (such as tracefs or BPF virtual file system) when necessary.
87 Print all logs available, even debug-level information. This
88 includes logs from libbpf.
92 **# bpftool link show**
97 cgroup_id 614 attach_type egress
100 **# bpftool --json --pretty link show**
108 "attach_type": "egress",
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
129 **bpf-helpers**\ (7),
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)