mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 14:14:37 +00:00
c07ba629df
All bpftool commands support the options for JSON output and debug from libbpf. In addition, some commands support additional options corresponding to specific use cases. The list of options described in the man pages for the different commands are not always accurate. The messages for interactive help are mostly limited to HELP_SPEC_OPTIONS, and are even less representative of the actual set of options supported for the commands. Let's update the lists: - HELP_SPEC_OPTIONS is modified to contain the "default" options (JSON and debug), and to be extensible (no ending curly bracket). - All commands use HELP_SPEC_OPTIONS in their help message, and then complete the list with their specific options. - The lists of options in the man pages are updated. - The formatting of the list for bpftool.rst is adjusted to match formatting for the other man pages. This is for consistency, and also because it will be helpful in a future patch to automatically check that the files are synchronised. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210730215435.7095-5-quentin@isovalent.com
109 lines
2.8 KiB
ReStructuredText
109 lines
2.8 KiB
ReStructuredText
================
|
|
bpftool-link
|
|
================
|
|
-------------------------------------------------------------------------------
|
|
tool for inspection and simple manipulation of eBPF links
|
|
-------------------------------------------------------------------------------
|
|
|
|
:Manual section: 8
|
|
|
|
SYNOPSIS
|
|
========
|
|
|
|
**bpftool** [*OPTIONS*] **link** *COMMAND*
|
|
|
|
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
|
|
{ **-f** | **--bpffs** } | { **-n** | **--nomount** } }
|
|
|
|
*COMMANDS* := { **show** | **list** | **pin** | **help** }
|
|
|
|
LINK COMMANDS
|
|
=============
|
|
|
|
| **bpftool** **link { show | list }** [*LINK*]
|
|
| **bpftool** **link pin** *LINK* *FILE*
|
|
| **bpftool** **link detach** *LINK*
|
|
| **bpftool** **link help**
|
|
|
|
|
| *LINK* := { **id** *LINK_ID* | **pinned** *FILE* }
|
|
|
|
|
|
DESCRIPTION
|
|
===========
|
|
**bpftool link { show | list }** [*LINK*]
|
|
Show information about active links. If *LINK* is
|
|
specified show information only about given link,
|
|
otherwise list all links currently active on the system.
|
|
|
|
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.
|
|
|
|
**bpftool link pin** *LINK* *FILE*
|
|
Pin link *LINK* as *FILE*.
|
|
|
|
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 detach** *LINK*
|
|
Force-detach link *LINK*. BPF link and its underlying BPF
|
|
program will stay valid, but they will be detached from the
|
|
respective BPF hook and BPF link will transition into
|
|
a defunct state until last open file descriptor for that
|
|
link is closed.
|
|
|
|
**bpftool link help**
|
|
Print short help message.
|
|
|
|
OPTIONS
|
|
=======
|
|
.. include:: common_options.rst
|
|
|
|
-f, --bpffs
|
|
When showing BPF links, show file names of pinned
|
|
links.
|
|
|
|
-n, --nomount
|
|
Do not automatically attempt to mount any virtual file system
|
|
(such as tracefs or BPF virtual file system) when necessary.
|
|
|
|
EXAMPLES
|
|
========
|
|
**# 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
|