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 }] | { -d | --debug }
13 | { -f | --bpffs } | { -n | --nomount } }
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 ex‐
46 tensions 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 re‐
51 spective BPF hook and BPF link will transition into a defunct
52 state until last open file descriptor for that link is
53 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 bpftool's version number (similar to bpftool version),
64 the number of the libbpf version in use, and optional fea‐
65 tures that were included when bpftool was compiled. Optional
66 features include linking against LLVM or libbfd to provide
67 the disassembler for JIT-ted programs (bpftool prog dump
68 jited) and usage of BPF skeletons (some features like bpftool
69 prog profile or showing pids associated to BPF objects may
70 rely on it).
71
72 -j, --json
73 Generate JSON output. For commands that cannot produce JSON,
74 this option has no effect.
75
76 -p, --pretty
77 Generate human-readable JSON output. Implies -j.
78
79 -d, --debug
80 Print all logs available, even debug-level information. This
81 includes logs from libbpf as well as from the verifier, when
82 attempting to load programs.
83
84 -f, --bpffs
85 When showing BPF links, show file names of pinned links.
86
87 -n, --nomount
88 Do not automatically attempt to mount any virtual file system
89 (such as tracefs or BPF virtual file system) when necessary.
90
92 # bpftool link show
93
94 10: cgroup prog 25
95 cgroup_id 614 attach_type egress
96 pids test_progs(223)
97
98 # bpftool --json --pretty link show
99
100 [{
101 "type": "cgroup",
102 "prog_id": 25,
103 "cgroup_id": 614,
104 "attach_type": "egress",
105 "pids": [{
106 "pid": 223,
107 "comm": "test_progs"
108 }
109 ]
110 }
111 ]
112
113 # bpftool link pin id 10 /sys/fs/bpf/link
114 # ls -l /sys/fs/bpf/
115
116
117 -rw------- 1 root root 0 Apr 23 21:39 link
118
120 bpf(2), bpf-helpers(7), bpftool(8), bpftool-btf(8),
121 bpftool-cgroup(8), bpftool-feature(8), bpftool-gen(8),
122 bpftool-iter(8), bpftool-map(8), bpftool-net(8), bpftool-perf(8),
123 bpftool-prog(8), bpftool-struct_ops(8)
124
125
126
127
128 BPFTOOL-LINK(8)