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.
65 .. include:: common_options.rst
68 When showing BPF links, show file names of pinned
72 Do not automatically attempt to mount any virtual file system
73 (such as tracefs or BPF virtual file system) when necessary.
77 **# bpftool link show**
82 cgroup_id 614 attach_type egress
85 **# bpftool --json --pretty link show**
93 "attach_type": "egress",
103 | **# bpftool link pin id 10 /sys/fs/bpf/link**
104 | **# ls -l /sys/fs/bpf/**
108 -rw------- 1 root root 0 Apr 23 21:39 link