| BPFTOOL-LINK(8) | System Manager's Manual | BPFTOOL-LINK(8) |
bpftool-link - tool for inspection and simple manipulation of eBPF links
bpftool [OPTIONS] link COMMAND
OPTIONS := { { -j | --json } [{ -p | --pretty }] | { -d | --debug } | { -f | --bpffs } | { -n | --nomount } }
COMMANDS := { show | list | pin | help }
bpftool link { show | list } [LINK]
bpftool link pin LINK FILE
bpftool link detach LINK
bpftool link help
LINK := { id LINK_ID | pinned FILE }
Output will start with link ID followed by link type and zero or more named attributes, some of which depend on type of link.
Since Linux 5.8 bpftool is able to discover information about processes that hold open file descriptors (FDs) against BPF links. On such kernels bpftool will automatically emit this information as well.
Note: FILE must be located in bpffs mount. It must not contain a dot character ('.'), which is reserved for future extensions of bpffs.
# bpftool link show
10: cgroup prog 25
cgroup_id 614 attach_type egress
pids test_progs(223)
# bpftool --json --pretty link show
[{
"type": "cgroup",
"prog_id": 25,
"cgroup_id": 614,
"attach_type": "egress",
"pids": [{
"pid": 223,
"comm": "test_progs"
}
]
}
]
# bpftool link pin id 10 /sys/fs/bpf/link # ls -l /sys/fs/bpf/
-rw------- 1 root root 0 Apr 23 21:39 link
bpf(2), bpf-helpers(7), bpftool(8), bpftool-btf(8), bpftool-cgroup(8), bpftool-feature(8), bpftool-gen(8), bpftool-iter(8), bpftool-map(8), bpftool-net(8), bpftool-perf(8), bpftool-prog(8), bpftool-struct_ops(8)