Skip to content

Commit

Permalink
tools: bpftool: Update and synchronise option list in doc and help msg
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Quentin Monnet authored and Andrii Nakryiko committed Jul 30, 2021
1 parent b544342 commit c07ba62
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-btf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

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

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

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

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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** }
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-gen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

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

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

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

Expand Down
2 changes: 2 additions & 0 deletions tools/bpf/bpftool/Documentation/bpftool-iter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SYNOPSIS

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

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

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

ITER COMMANDS
Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/Documentation/bpftool-link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ SYNOPSIS

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

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

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

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/Documentation/bpftool-map.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ SYNOPSIS

**bpftool** [*OPTIONS*] **map** *COMMAND*

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

*COMMANDS* :=
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext**
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-net.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

**bpftool** [*OPTIONS*] **net** *COMMAND*

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

*COMMANDS* :=
{ **show** | **list** | **attach** | **detach** | **help** }
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-perf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

**bpftool** [*OPTIONS*] **perf** *COMMAND*

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

*COMMANDS* :=
{ **show** | **list** | **help** }
Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/Documentation/bpftool-prog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ SYNOPSIS

**bpftool** [*OPTIONS*] **prog** *COMMAND*

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

*COMMANDS* :=
{ **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load**
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/Documentation/bpftool-struct_ops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS

**bpftool** [*OPTIONS*] **struct_ops** *COMMAND*

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

*COMMANDS* :=
{ **show** | **list** | **dump** | **register** | **unregister** | **help** }
Expand Down
12 changes: 6 additions & 6 deletions tools/bpf/bpftool/Documentation/bpftool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ SYNOPSIS

*OBJECT* := { **map** | **program** | **cgroup** | **perf** | **net** | **feature** }

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

*MAP-COMMANDS* :=
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext**
| **delete** | **pin** | **event_pipe** | **help** }
{ **show** | **list** | **create** | **dump** | **update** | **lookup** | **getnext** |
**delete** | **pin** | **event_pipe** | **help** }

*PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin**
| **load** | **attach** | **detach** | **help** }
*PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin** |
**load** | **attach** | **detach** | **help** }

*CGROUP-COMMANDS* := { **show** | **list** | **attach** | **detach** | **help** }

Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ static int do_help(int argc, char **argv)
" FORMAT := { raw | c }\n"
" " HELP_SPEC_MAP "\n"
" " HELP_SPEC_PROGRAM "\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, "btf");

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ static int do_help(int argc, char **argv)
HELP_SPEC_ATTACH_TYPES "\n"
" " HELP_SPEC_ATTACH_FLAGS "\n"
" " HELP_SPEC_PROGRAM "\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} }
"",
bin_name, argv[-2]);

Expand Down
1 change: 1 addition & 0 deletions tools/bpf/bpftool/feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ static int do_help(int argc, char **argv)
" %1$s %2$s help\n"
"\n"
" COMPONENT := { kernel | dev NAME }\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, argv[-2]);

Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ static int do_help(int argc, char **argv)
" %1$s %2$s skeleton FILE [name OBJECT_NAME]\n"
" %1$s %2$s help\n"
"\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, "gen");

Expand Down
2 changes: 2 additions & 0 deletions tools/bpf/bpftool/iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ static int do_help(int argc, char **argv)
fprintf(stderr,
"Usage: %1$s %2$s pin OBJ PATH [map MAP]\n"
" %1$s %2$s help\n"
"\n"
" " HELP_SPEC_MAP "\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, "iter");

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ static int do_help(int argc, char **argv)
" %1$s %2$s help\n"
"\n"
" " HELP_SPEC_LINK "\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-n|--nomount} }\n"
"",
bin_name, argv[-2]);

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ static int do_help(int argc, char **argv)
" %s version\n"
"\n"
" OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " |\n"
" {-V|--version} }\n"
"",
bin_name, bin_name, bin_name);

Expand Down
3 changes: 1 addition & 2 deletions tools/bpf/bpftool/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static inline void *u64_to_ptr(__u64 ptr)
#define HELP_SPEC_PROGRAM \
"PROG := { id PROG_ID | pinned FILE | tag PROG_TAG | name PROG_NAME }"
#define HELP_SPEC_OPTIONS \
"OPTIONS := { {-j|--json} [{-p|--pretty}] | {-f|--bpffs} |\n" \
"\t {-m|--mapcompat} | {-n|--nomount} }"
"OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug}"
#define HELP_SPEC_MAP \
"MAP := { id MAP_ID | pinned FILE | name MAP_NAME }"
#define HELP_SPEC_LINK \
Expand Down
5 changes: 3 additions & 2 deletions tools/bpf/bpftool/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,9 @@ static int do_help(int argc, char **argv)
" devmap | devmap_hash | sockmap | cpumap | xskmap | sockhash |\n"
" cgroup_storage | reuseport_sockarray | percpu_cgroup_storage |\n"
" queue | stack | sk_storage | struct_ops | ringbuf | inode_storage |\n"
" task_storage }\n"
" " HELP_SPEC_OPTIONS "\n"
" task_storage }\n"
" " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-n|--nomount} }\n"
"",
bin_name, argv[-2]);

Expand Down
1 change: 1 addition & 0 deletions tools/bpf/bpftool/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ static int do_help(int argc, char **argv)
"\n"
" " HELP_SPEC_PROGRAM "\n"
" ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }\n"
" " HELP_SPEC_OPTIONS " }\n"
"\n"
"Note: Only xdp and tc attachments are supported now.\n"
" For progs attached to cgroups, use \"bpftool cgroup\"\n"
Expand Down
5 changes: 4 additions & 1 deletion tools/bpf/bpftool/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ static int do_show(int argc, char **argv)
static int do_help(int argc, char **argv)
{
fprintf(stderr,
"Usage: %1$s %2$s { show | list | help }\n"
"Usage: %1$s %2$s { show | list }\n"
" %1$s %2$s help }\n"
"\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, argv[-2]);

Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,8 @@ static int do_help(int argc, char **argv)
" ATTACH_TYPE := { msg_verdict | skb_verdict | stream_verdict |\n"
" stream_parser | flow_dissector }\n"
" METRIC := { cycles | instructions | l1d_loads | llc_misses | itlb_misses | dtlb_misses }\n"
" " HELP_SPEC_OPTIONS "\n"
" " HELP_SPEC_OPTIONS " |\n"
" {-f|--bpffs} | {-m|--mapcompat} | {-n|--nomount} }\n"
"",
bin_name, argv[-2]);

Expand Down
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/struct_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ static int do_help(int argc, char **argv)
" %1$s %2$s unregister STRUCT_OPS_MAP\n"
" %1$s %2$s help\n"
"\n"
" OPTIONS := { {-j|--json} [{-p|--pretty}] }\n"
" STRUCT_OPS_MAP := [ id STRUCT_OPS_MAP_ID | name STRUCT_OPS_MAP_NAME ]\n"
" " HELP_SPEC_OPTIONS " }\n"
"",
bin_name, argv[-2]);

Expand Down

0 comments on commit c07ba62

Please sign in to comment.