Commit ab0720ce authored by Andrii Nakryiko's avatar Andrii Nakryiko
Browse files

Merge branch 'tools: bpftool: update, synchronise and validate types and options'



Quentin Monnet says:

====================

To work with the different program types, map types, attach types etc.
supported by eBPF, bpftool needs occasional updates to learn about the new
features supported by the kernel. When such types translate into new
keyword for the command line, updates are expected in several locations:
typically, the help message displayed from bpftool itself, the manual page,
and the bash completion file should be updated. The options used by the
different commands for bpftool should also remain synchronised at those
locations.

Several omissions have occurred in the past, and a number of types are
still missing today. This set is an attempt to improve the situation. It
brings up-to-date the lists of types or options in bpftool, and also adds a
Python script to the BPF selftests to automatically check that most of
these lists remain synchronised.

v2:
- Reformat some lines in the bash completion file.
- Do not reformat attach types, to preserve git-blame history.
- Do not call Python script from tools/testing/selftests/bpf/Makefile.
====================

Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 0b846445 475a23c2
Loading
Loading
Loading
Loading
+47 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ SYNOPSIS

	**bpftool** [*OPTIONS*] **btf** *COMMAND*

	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] }
	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | {**-d** | **--debug** } |
		{ **-B** | **--base-btf** } }

	*COMMANDS* := { **dump** | **help** }

@@ -73,6 +74,20 @@ OPTIONS
=======
	.. include:: common_options.rst

	-B, --base-btf *FILE*
		  Pass a base BTF object. Base BTF objects are typically used
		  with BTF objects for kernel modules. To avoid duplicating
		  all kernel symbols required by modules, BTF objects for
		  modules are "split", they are built incrementally on top of
		  the kernel (vmlinux) BTF object. So the base BTF reference
		  should usually point to the kernel BTF.

		  When the main BTF object to process (for example, the
		  module BTF to dump) is passed as a *FILE*, bpftool attempts
		  to autodetect the path for the base object, and passing
		  this option is optional. When the main BTF object is passed
		  through other handles, this option becomes necessary.

EXAMPLES
========
**# bpftool btf dump id 1226**
@@ -217,3 +232,34 @@ All the standard ways to specify map or program are supported:
**# bpftool btf dump prog tag b88e0a09b1d9759d**

**# bpftool btf dump prog pinned /sys/fs/bpf/prog_name**

|
| **# bpftool btf dump file /sys/kernel/btf/i2c_smbus**
| (or)
| **# I2C_SMBUS_ID=$(bpftool btf show -p | jq '.[] | select(.name=="i2c_smbus").id')**
| **# bpftool btf dump id ${I2C_SMBUS_ID} -B /sys/kernel/btf/vmlinux**

::

  [104848] STRUCT 'i2c_smbus_alert' size=40 vlen=2
          'alert' type_id=393 bits_offset=0
          'ara' type_id=56050 bits_offset=256
  [104849] STRUCT 'alert_data' size=12 vlen=3
          'addr' type_id=16 bits_offset=0
          'type' type_id=56053 bits_offset=32
          'data' type_id=7 bits_offset=64
  [104850] PTR '(anon)' type_id=104848
  [104851] PTR '(anon)' type_id=104849
  [104852] FUNC 'i2c_register_spd' type_id=84745 linkage=static
  [104853] FUNC 'smbalert_driver_init' type_id=1213 linkage=static
  [104854] FUNC_PROTO '(anon)' ret_type_id=18 vlen=1
          'ara' type_id=56050
  [104855] FUNC 'i2c_handle_smbus_alert' type_id=104854 linkage=static
  [104856] FUNC 'smbalert_remove' type_id=104854 linkage=static
  [104857] FUNC_PROTO '(anon)' ret_type_id=18 vlen=2
          'ara' type_id=56050
          'id' type_id=56056
  [104858] FUNC 'smbalert_probe' type_id=104857 linkage=static
  [104859] FUNC 'smbalert_work' type_id=9695 linkage=static
  [104860] FUNC 'smbus_alert' type_id=71367 linkage=static
  [104861] FUNC 'smbus_do_alert' type_id=84827 linkage=static
+2 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ SYNOPSIS

	**bpftool** [*OPTIONS*] **cgroup** *COMMAND*

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

	*COMMANDS* :=
	{ **show** | **list** | **tree** | **attach** | **detach** | **help** }
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ SYNOPSIS

	**bpftool** [*OPTIONS*] **feature** *COMMAND*

	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] }
	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }

	*COMMANDS* := { **probe** | **help** }

+8 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ SYNOPSIS

	**bpftool** [*OPTIONS*] **gen** *COMMAND*

	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] }
	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
		{ **-L** | **--use-loader** } }

	*COMMAND* := { **object** | **skeleton** | **help** }

@@ -152,6 +153,12 @@ OPTIONS
=======
	.. include:: common_options.rst

	-L, --use-loader
		  For skeletons, generate a "light" skeleton (also known as "loader"
		  skeleton). A light skeleton contains a loader eBPF program. It does
		  not use the majority of the libbpf infrastructure, and does not need
		  libelf.

EXAMPLES
========
**$ cat example1.bpf.c**
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ SYNOPSIS

	**bpftool** [*OPTIONS*] **iter** *COMMAND*

	*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } }

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

ITER COMMANDS
Loading