1================
2bpftool-link
3================
4-------------------------------------------------------------------------------
5tool for inspection and simple manipulation of eBPF links
6-------------------------------------------------------------------------------
7
8:Manual section: 8
9
10SYNOPSIS
11========
12
13	**bpftool** [*OPTIONS*] **link** *COMMAND*
14
15	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
16
17	*COMMANDS* := { **show** | **list** | **pin** | **help** }
18
19LINK COMMANDS
20=============
21
22|	**bpftool** **link { show | list }** [*LINK*]
23|	**bpftool** **link pin** *LINK* *FILE*
24|	**bpftool** **link detach *LINK*
25|	**bpftool** **link help**
26|
27|	*LINK* := { **id** *LINK_ID* | **pinned** *FILE* }
28
29
30DESCRIPTION
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.
36
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.
40
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.
45
46	**bpftool link pin** *LINK* *FILE*
47		  Pin link *LINK* as *FILE*.
48
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*.
52
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.
59
60	**bpftool link help**
61		  Print short help message.
62
63OPTIONS
64=======
65	-h, --help
66		  Print short generic help message (similar to **bpftool help**).
67
68	-V, --version
69		  Print version number (similar to **bpftool version**).
70
71	-j, --json
72		  Generate JSON output. For commands that cannot produce JSON, this
73		  option has no effect.
74
75	-p, --pretty
76		  Generate human-readable JSON output. Implies **-j**.
77
78	-f, --bpffs
79		  When showing BPF links, show file names of pinned
80		  links.
81
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.
85
86	-d, --debug
87		  Print all logs available, even debug-level information. This
88		  includes logs from libbpf.
89
90EXAMPLES
91========
92**# bpftool link show**
93
94::
95
96    10: cgroup  prog 25
97            cgroup_id 614  attach_type egress
98            pids test_progs(223)
99
100**# bpftool --json --pretty link show**
101
102::
103
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    ]
116
117|
118| **# bpftool link pin id 10 /sys/fs/bpf/link**
119| **# ls -l /sys/fs/bpf/**
120
121::
122
123    -rw------- 1 root root 0 Apr 23 21:39 link
124
125
126SEE 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)
141