^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) bpftool-link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) tool for inspection and simple manipulation of eBPF links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) :Manual section: 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) SYNOPSIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) **bpftool** [*OPTIONS*] **link** *COMMAND*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *COMMANDS* := { **show** | **list** | **pin** | **help** }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) LINK COMMANDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) | **bpftool** **link { show | list }** [*LINK*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) | **bpftool** **link pin** *LINK* *FILE*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) | **bpftool** **link detach** *LINK*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) | **bpftool** **link help**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) | *LINK* := { **id** *LINK_ID* | **pinned** *FILE* }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) DESCRIPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) **bpftool link { show | list }** [*LINK*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Show information about active links. If *LINK* is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) specified show information only about given link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) otherwise list all links currently active on the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Output will start with link ID followed by link type and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) zero or more named attributes, some of which depend on type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) of link.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Since Linux 5.8 bpftool is able to discover information about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) processes that hold open file descriptors (FDs) against BPF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) links. On such kernels bpftool will automatically emit this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) information as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) **bpftool link pin** *LINK* *FILE*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) Pin link *LINK* as *FILE*.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) Note: *FILE* must be located in *bpffs* mount. It must not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) contain a dot character ('.'), which is reserved for future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extensions of *bpffs*.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) **bpftool link detach** *LINK*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Force-detach link *LINK*. BPF link and its underlying BPF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) program will stay valid, but they will be detached from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) respective BPF hook and BPF link will transition into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) a defunct state until last open file descriptor for that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) link is closed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) **bpftool link help**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) Print short help message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) OPTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .. include:: common_options.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) -f, --bpffs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) When showing BPF links, show file names of pinned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) links.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) -n, --nomount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) Do not automatically attempt to mount any virtual file system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) (such as tracefs or BPF virtual file system) when necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) EXAMPLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) **# bpftool link show**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 10: cgroup prog 25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) cgroup_id 614 attach_type egress
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) pids test_progs(223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) **# bpftool --json --pretty link show**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) [{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) "type": "cgroup",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) "prog_id": 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) "cgroup_id": 614,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) "attach_type": "egress",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) "pids": [{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) "pid": 223,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) "comm": "test_progs"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) | **# bpftool link pin id 10 /sys/fs/bpf/link**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) | **# ls -l /sys/fs/bpf/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) -rw------- 1 root root 0 Apr 23 21:39 link