1BPFTOOL-LINK(8) BPFTOOL-LINK(8)
2
3
4
6 bpftool-link - tool for inspection and simple manipulation of eBPF
7 links
8
10 bpftool [OPTIONS] link COMMAND
11
12 OPTIONS := { { -j | --json } [{ -p | --pretty }] | { -f | --bpffs }
13 }
14
15 COMMANDS := { show | list | pin | help }
16
18 bpftool link { show | list } [LINK]
19 bpftool link pin LINK FILE
20 bpftool link detach LINK
21 bpftool link help
22
23 LINK := { id LINK_ID | pinned FILE }
24
25
27 bpftool link { show | list } [LINK]
28 Show information about active links. If LINK is specified
29 show information only about given link, otherwise list all
30 links currently active on the system.
31
32 Output will start with link ID followed by link type and zero
33 or more named attributes, some of which depend on type of
34 link.
35
36 Since Linux 5.8 bpftool is able to discover information about
37 processes that hold open file descriptors (FDs) against BPF
38 links. On such kernels bpftool will automatically emit this
39 information as well.
40
41 bpftool link pin LINK FILE
42 Pin link LINK as FILE.
43
44 Note: FILE must be located in bpffs mount. It must not con‐
45 tain a dot character ('.'), which is reserved for future
46 extensions of bpffs.
47
48 bpftool link detach LINK
49 Force-detach link LINK. BPF link and its underlying BPF pro‐
50 gram will stay valid, but they will be detached from the
51 respective BPF hook and BPF link will transition into a
52 defunct state until last open file descriptor for that link
53 is closed.
54
55 bpftool link help
56 Print short help message.
57
59 -h, --help
60 Print short help message (similar to bpftool help).
61
62 -V, --version
63 Print version number (similar to bpftool version), and
64 optional features that were included when bpftool was com‐
65 piled. Optional features include linking against libbfd to
66 provide the disassembler for JIT-ted programs (bpftool prog
67 dump jited) and usage of BPF skeletons (some features like
68 bpftool prog profile or showing pids associated to BPF
69 objects may rely on it).
70
71 -j, --json
72 Generate JSON output. For commands that cannot produce JSON,
73 this option has no effect.
74
75 -p, --pretty
76 Generate human-readable JSON output. Implies -j.
77
78 -d, --debug
79 Print all logs available, even debug-level information. This
80 includes logs from libbpf as well as from the verifier, when
81 attempting to load programs.
82
83 -f, --bpffs
84 When showing BPF links, show file names of pinned links.
85
86 -n, --nomount
87 Do not automatically attempt to mount any virtual file system
88 (such as tracefs or BPF virtual file system) when necessary.
89
91 # bpftool link show
92
93 10: cgroup prog 25
94 cgroup_id 614 attach_type egress
95 pids test_progs(223)
96
97 # bpftool --json --pretty link show
98
99 [{
100 "type": "cgroup",
101 "prog_id": 25,
102 "cgroup_id": 614,
103 "attach_type": "egress",
104 "pids": [{
105 "pid": 223,
106 "comm": "test_progs"
107 }
108 ]
109 }
110 ]
111
112 # bpftool link pin id 10 /sys/fs/bpf/link
113 # ls -l /sys/fs/bpf/
114
115
116 -rw------- 1 root root 0 Apr 23 21:39 link
117
119 bpf(2), bpf-helpers(7), bpftool(8), bpftool-btf(8),
120 bpftool-cgroup(8), bpftool-feature(8), bpftool-gen(8),
121 bpftool-iter(8), bpftool-map(8), bpftool-net(8), bpftool-perf(8),
122 bpftool-prog(8), bpftool-struct_ops(8)
123
124
125
126
127 BPFTOOL-LINK(8)