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          |
14                 { -f | --bpffs } | { -n | --nomount } }
15
16          COMMANDS := { show | list | pin | help }
17
19       bpftool link { show | list } [LINK]
20       bpftool link pin LINK FILE
21       bpftool link detach LINK
22       bpftool link help
23
24       LINK := { id LINK_ID | pinned FILE }
25
26

DESCRIPTION

28          bpftool link { show | list } [LINK]
29                 Show  information  about  active  links. If LINK is specified
30                 show information only about given link,  otherwise  list  all
31                 links currently active on the system.
32
33                 Output will start with link ID followed by link type and zero
34                 or more named attributes, some of which  depend  on  type  of
35                 link.
36
37                 Since Linux 5.8 bpftool is able to discover information about
38                 processes that hold open file descriptors (FDs)  against  BPF
39                 links.  On  such kernels bpftool will automatically emit this
40                 information as well.
41
42          bpftool link pin LINK FILE
43                 Pin link LINK as FILE.
44
45                 Note: FILE must be located in bpffs mount. It must  not  con‐
46                 tain  a dot character ('.'), which is reserved for future ex‐
47                 tensions of bpffs.
48
49          bpftool link detach LINK
50                 Force-detach link LINK. BPF link and its underlying BPF  pro‐
51                 gram  will stay valid, but they will be detached from the re‐
52                 spective BPF hook and BPF link will transition into a defunct
53                 state  until  last  open  file  descriptor  for  that link is
54                 closed.
55
56          bpftool link help
57                 Print short help message.
58

OPTIONS

60          -h, --help
61                 Print short help message (similar to bpftool help).
62
63          -V, --version
64                 Print version number (similar to bpftool  version),  and  op‐
65                 tional features that were included when bpftool was compiled.
66                 Optional features include linking against 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

EXAMPLES

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

SEE ALSO

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)
Impressum