1BPFTOOL-LINK(8)                                                BPFTOOL-LINK(8)
2
3
4

NAME

6       bpftool-link  -  tool  for  inspection  and simple manipulation of eBPF
7       links
8

SYNOPSIS

10          bpftool [OPTIONS] link COMMAND
11
12          OPTIONS := { { -j | --json } [{ -p | --pretty }] | { -d | --debug  }
13          | { -l | --legacy } | { -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

DESCRIPTION

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

OPTIONS

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 libbfd to provide the disas‐
67                 sembler for JIT-ted programs (bpftool prog  dump  jited)  and
68                 usage  of BPF skeletons (some features like bpftool prog pro‐
69                 file or showing pids associated to BPF objects  may  rely  on
70                 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          -l, --legacy
85                 Use legacy libbpf mode which has more relaxed BPF program re‐
86                 quirements.  By default, bpftool has more strict requirements
87                 about section names, changes pinning logic and  doesn't  sup‐
88                 port some of the older non-BTF map declarations.
89
90                 See
91                 https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0
92                 for details.
93
94          -f, --bpffs
95                 When showing BPF links, show file names of pinned links.
96
97          -n, --nomount
98                 Do not automatically attempt to mount any virtual file system
99                 (such as tracefs or BPF virtual file system) when necessary.
100

EXAMPLES

102       # bpftool link show
103
104          10: cgroup  prog 25
105                  cgroup_id 614  attach_type egress
106                  pids test_progs(223)
107
108       # bpftool --json --pretty link show
109
110          [{
111                  "type": "cgroup",
112                  "prog_id": 25,
113                  "cgroup_id": 614,
114                  "attach_type": "egress",
115                  "pids": [{
116                          "pid": 223,
117                          "comm": "test_progs"
118                      }
119                  ]
120              }
121          ]
122
123       # bpftool link pin id 10 /sys/fs/bpf/link
124       # ls -l /sys/fs/bpf/
125
126
127          -rw------- 1 root root 0 Apr 23 21:39 link
128

SEE ALSO

130          bpf(2),      bpf-helpers(7),       bpftool(8),       bpftool-btf(8),
131          bpftool-cgroup(8),        bpftool-feature(8),        bpftool-gen(8),
132          bpftool-iter(8),  bpftool-map(8),  bpftool-net(8),  bpftool-perf(8),
133          bpftool-prog(8), bpftool-struct_ops(8)
134
135
136
137
138                                                               BPFTOOL-LINK(8)
Impressum