Skip to content

Commit

Permalink
tools: bpftool: alias show and list commands
Browse files Browse the repository at this point in the history
iproute2 seems to accept show and list as aliases.
Let's do the same thing, and by allowing both bring
cgroup syntax back in line with maps and progs.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Jakub Kicinski authored and Daniel Borkmann committed Jan 4, 2018
1 parent 65b875b commit 6ebe6db
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ SYNOPSIS
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }

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

MAP COMMANDS
=============

| **bpftool** **cgroup list** *CGROUP*
| **bpftool** **cgroup { show | list }** *CGROUP*
| **bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
| **bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
| **bpftool** **cgroup help**
Expand All @@ -31,7 +31,7 @@ MAP COMMANDS
DESCRIPTION
===========
**bpftool cgroup list** *CGROUP*
**bpftool cgroup { show | list }** *CGROUP*
List all programs attached to the cgroup *CGROUP*.

Output will start with program ID followed by attach type,
Expand Down
6 changes: 3 additions & 3 deletions tools/bpf/bpftool/Documentation/bpftool-map.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ SYNOPSIS
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }

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

| **bpftool** **map show** [*MAP*]
| **bpftool** **map { show | list }** [*MAP*]
| **bpftool** **map dump** *MAP*
| **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
| **bpftool** **map lookup** *MAP* **key** *BYTES*
Expand All @@ -36,7 +36,7 @@ MAP COMMANDS
DESCRIPTION
===========
**bpftool map show** [*MAP*]
**bpftool map { show | list }** [*MAP*]
Show information about loaded maps. If *MAP* is specified
show information only about given map, otherwise list all
maps currently loaded on the system.
Expand Down
6 changes: 3 additions & 3 deletions tools/bpf/bpftool/Documentation/bpftool-prog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ SYNOPSIS
*OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }

*COMMANDS* :=
{ **show** | **dump xlated** | **dump jited** | **pin** | **load** | **help** }
{ **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load** | **help** }

MAP COMMANDS
=============

| **bpftool** **prog show** [*PROG*]
| **bpftool** **prog { show | list }** [*PROG*]
| **bpftool** **prog dump xlated** *PROG* [{**file** *FILE* | **opcodes**}]
| **bpftool** **prog dump jited** *PROG* [{**file** *FILE* | **opcodes**}]
| **bpftool** **prog pin** *PROG* *FILE*
Expand All @@ -31,7 +31,7 @@ MAP COMMANDS
DESCRIPTION
===========
**bpftool prog show** [*PROG*]
**bpftool prog { show | list }** [*PROG*]
Show information about loaded programs. If *PROG* is
specified show information only about given program, otherwise
list all programs currently loaded on the system.
Expand Down
6 changes: 3 additions & 3 deletions tools/bpf/bpftool/Documentation/bpftool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ SYNOPSIS
| { **-j** | **--json** } [{ **-p** | **--pretty** }] }
*MAP-COMMANDS* :=
{ **show** | **dump** | **update** | **lookup** | **getnext** | **delete**
{ **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete**
| **pin** | **help** }
*PROG-COMMANDS* := { **show** | **dump jited** | **dump xlated** | **pin**
*PROG-COMMANDS* := { **show** | **list** | **dump jited** | **dump xlated** | **pin**
| **load** | **help** }
*CGROUP-COMMANDS* := { **list** | **attach** | **detach** | **help** }
*CGROUP-COMMANDS* := { **show** | **list** | **attach** | **detach** | **help** }

DESCRIPTION
===========
Expand Down
8 changes: 4 additions & 4 deletions tools/bpf/bpftool/bash-completion/bpftool
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ _bpftool()

local PROG_TYPE='id pinned tag'
case $command in
show)
show|list)
[[ $prev != "$command" ]] && return 0
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
return 0
Expand Down Expand Up @@ -232,15 +232,15 @@ _bpftool()
;;
*)
[[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'dump help pin show' -- \
COMPREPLY=( $( compgen -W 'dump help pin show list' -- \
"$cur" ) )
;;
esac
;;
map)
local MAP_TYPE='id pinned'
case $command in
show|dump)
show|list|dump)
case $prev in
$command)
COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) )
Expand Down Expand Up @@ -343,7 +343,7 @@ _bpftool()
*)
[[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'delete dump getnext help \
lookup pin show update' -- "$cur" ) )
lookup pin show list update' -- "$cur" ) )
;;
esac
;;
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 @@ -277,7 +277,7 @@ static int do_help(int argc, char **argv)
}

fprintf(stderr,
"Usage: %s %s list CGROUP\n"
"Usage: %s %s { show | list } CGROUP\n"
" %s %s attach CGROUP ATTACH_TYPE PROG [ATTACH_FLAGS]\n"
" %s %s detach CGROUP ATTACH_TYPE PROG\n"
" %s %s help\n"
Expand All @@ -294,6 +294,7 @@ static int do_help(int argc, char **argv)
}

static const struct cmd cmds[] = {
{ "show", do_show },
{ "list", do_show },
{ "attach", do_attach },
{ "detach", do_detach },
Expand Down
3 changes: 2 additions & 1 deletion tools/bpf/bpftool/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static int do_help(int argc, char **argv)
}

fprintf(stderr,
"Usage: %s %s show [MAP]\n"
"Usage: %s %s { show | list } [MAP]\n"
" %s %s dump MAP\n"
" %s %s update MAP key BYTES value VALUE [UPDATE_FLAGS]\n"
" %s %s lookup MAP key BYTES\n"
Expand All @@ -885,6 +885,7 @@ static int do_help(int argc, char **argv)

static const struct cmd cmds[] = {
{ "show", do_show },
{ "list", do_show },
{ "help", do_help },
{ "dump", do_dump },
{ "update", do_update },
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 @@ -836,7 +836,7 @@ static int do_help(int argc, char **argv)
}

fprintf(stderr,
"Usage: %s %s show [PROG]\n"
"Usage: %s %s { show | list } [PROG]\n"
" %s %s dump xlated PROG [{ file FILE | opcodes }]\n"
" %s %s dump jited PROG [{ file FILE | opcodes }]\n"
" %s %s pin PROG FILE\n"
Expand All @@ -854,6 +854,7 @@ static int do_help(int argc, char **argv)

static const struct cmd cmds[] = {
{ "show", do_show },
{ "list", do_show },
{ "help", do_help },
{ "dump", do_dump },
{ "pin", do_pin },
Expand Down

0 comments on commit 6ebe6db

Please sign in to comment.