bpftool-link.rst 3.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
================
bpftool-link
================
-------------------------------------------------------------------------------
tool for inspection and simple manipulation of eBPF links
-------------------------------------------------------------------------------

:Manual section: 8

SYNOPSIS
========

	**bpftool** [*OPTIONS*] **link** *COMMAND*

	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }

	*COMMANDS* := { **show** | **list** | **pin** | **help** }

LINK COMMANDS
=============

|	**bpftool** **link { show | list }** [*LINK*]
|	**bpftool** **link pin** *LINK* *FILE*
|	**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.

40 41 42 43 44
		  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.

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
	**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 help**
		  Print short help message.

OPTIONS
=======
	-h, --help
		  Print short generic help message (similar to **bpftool help**).

	-V, --version
		  Print version number (similar to **bpftool version**).

	-j, --json
		  Generate JSON output. For commands that cannot produce JSON, this
		  option has no effect.

	-p, --pretty
		  Generate human-readable JSON output. Implies **-j**.

	-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.

	-d, --debug
		  Print all logs available, even debug-level information. This
		  includes logs from libbpf.

EXAMPLES
========
**# bpftool link show**

::

    10: cgroup  prog 25
            cgroup_id 614  attach_type egress
90
            pids test_progs(223)
91 92 93 94 95 96 97 98 99

**# bpftool --json --pretty link show**

::

    [{
            "type": "cgroup",
            "prog_id": 25,
            "cgroup_id": 614,
100 101 102 103 104 105
            "attach_type": "egress",
            "pids": [{
                    "pid": 223,
                    "comm": "test_progs"
                }
            ]
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
        }
    ]

|
| **# bpftool link pin id 10 /sys/fs/bpf/link**
| **# ls -l /sys/fs/bpf/**

::

    -rw------- 1 root root 0 Apr 23 21:39 link


SEE ALSO
========
	**bpf**\ (2),
	**bpf-helpers**\ (7),
	**bpftool**\ (8),
123
	**bpftool-btf**\ (8),
124 125
	**bpftool-cgroup**\ (8),
	**bpftool-feature**\ (8),
126 127 128
	**bpftool-gen**\ (8),
	**bpftool-iter**\ (8),
	**bpftool-map**\ (8),
129 130
	**bpftool-net**\ (8),
	**bpftool-perf**\ (8),
131 132
	**bpftool-prog**\ (8),
	**bpftool-struct_ops**\ (8)