Commit 990a6194 authored by Quentin Monnet's avatar Quentin Monnet Committed by Daniel Borkmann

bpftool: Rename "bpftool feature list" into "... feature list_builtins"

To make it more explicit that the features listed with "bpftool feature
list" are known to bpftool, but not necessary available on the system
(as opposed to the probed features), rename the "feature list" command
into "feature list_builtins".

Note that "bpftool feature list" still works as before given that we
recognise arguments from their prefixes; but the real name of the
subcommand, in particular as displayed in the man page or the
interactive help, will now include "_builtins".

Since we update the bash completion accordingly, let's also take this
chance to redirect error output to /dev/null in the completion script,
to avoid displaying unexpected error messages when users attempt to
tab-complete.
Suggested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220701093805.16920-1-quentin@isovalent.com
parent 2064a132
...@@ -24,7 +24,7 @@ FEATURE COMMANDS ...@@ -24,7 +24,7 @@ FEATURE COMMANDS
================ ================
| **bpftool** **feature probe** [*COMPONENT*] [**full**] [**unprivileged**] [**macros** [**prefix** *PREFIX*]] | **bpftool** **feature probe** [*COMPONENT*] [**full**] [**unprivileged**] [**macros** [**prefix** *PREFIX*]]
| **bpftool** **feature list** *GROUP* | **bpftool** **feature list_builtins** *GROUP*
| **bpftool** **feature help** | **bpftool** **feature help**
| |
| *COMPONENT* := { **kernel** | **dev** *NAME* } | *COMPONENT* := { **kernel** | **dev** *NAME* }
...@@ -72,7 +72,7 @@ DESCRIPTION ...@@ -72,7 +72,7 @@ DESCRIPTION
The keywords **full**, **macros** and **prefix** have the The keywords **full**, **macros** and **prefix** have the
same role as when probing the kernel. same role as when probing the kernel.
**bpftool feature list** *GROUP* **bpftool feature list_builtins** *GROUP*
List items known to bpftool. These can be BPF program types List items known to bpftool. These can be BPF program types
(**prog_types**), BPF map types (**map_types**), attach types (**prog_types**), BPF map types (**map_types**), attach types
(**attach_types**), link types (**link_types**), or BPF helper (**attach_types**), link types (**link_types**), or BPF helper
......
...@@ -703,7 +703,7 @@ _bpftool() ...@@ -703,7 +703,7 @@ _bpftool()
return 0 return 0
;; ;;
type) type)
local BPFTOOL_MAP_CREATE_TYPES="$(bpftool feature list map_types | \ local BPFTOOL_MAP_CREATE_TYPES="$(bpftool feature list_builtins map_types 2>/dev/null | \
grep -v '^unspec$')" grep -v '^unspec$')"
COMPREPLY=( $( compgen -W "$BPFTOOL_MAP_CREATE_TYPES" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$BPFTOOL_MAP_CREATE_TYPES" -- "$cur" ) )
return 0 return 0
...@@ -1032,7 +1032,7 @@ _bpftool() ...@@ -1032,7 +1032,7 @@ _bpftool()
return 0 return 0
;; ;;
attach|detach) attach|detach)
local BPFTOOL_CGROUP_ATTACH_TYPES="$(bpftool feature list attach_types | \ local BPFTOOL_CGROUP_ATTACH_TYPES="$(bpftool feature list_builtins attach_types 2>/dev/null | \
grep '^cgroup_')" grep '^cgroup_')"
local ATTACH_FLAGS='multi override' local ATTACH_FLAGS='multi override'
local PROG_TYPE='id pinned tag name' local PROG_TYPE='id pinned tag name'
...@@ -1162,14 +1162,14 @@ _bpftool() ...@@ -1162,14 +1162,14 @@ _bpftool()
_bpftool_once_attr 'full unprivileged' _bpftool_once_attr 'full unprivileged'
return 0 return 0
;; ;;
list) list_builtins)
[[ $prev != "$command" ]] && return 0 [[ $prev != "$command" ]] && return 0
COMPREPLY=( $( compgen -W 'prog_types map_types \ COMPREPLY=( $( compgen -W 'prog_types map_types \
attach_types link_types helpers' -- "$cur" ) ) attach_types link_types helpers' -- "$cur" ) )
;; ;;
*) *)
[[ $prev == $object ]] && \ [[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'help list probe' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'help list_builtins probe' -- "$cur" ) )
;; ;;
esac esac
;; ;;
......
...@@ -1266,7 +1266,7 @@ static const char *get_helper_name(unsigned int id) ...@@ -1266,7 +1266,7 @@ static const char *get_helper_name(unsigned int id)
return helper_name[id]; return helper_name[id];
} }
static int do_list(int argc, char **argv) static int do_list_builtins(int argc, char **argv)
{ {
const char *(*get_name)(unsigned int id); const char *(*get_name)(unsigned int id);
unsigned int id = 0; unsigned int id = 0;
...@@ -1319,7 +1319,7 @@ static int do_help(int argc, char **argv) ...@@ -1319,7 +1319,7 @@ static int do_help(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"Usage: %1$s %2$s probe [COMPONENT] [full] [unprivileged] [macros [prefix PREFIX]]\n" "Usage: %1$s %2$s probe [COMPONENT] [full] [unprivileged] [macros [prefix PREFIX]]\n"
" %1$s %2$s list GROUP\n" " %1$s %2$s list_builtins GROUP\n"
" %1$s %2$s help\n" " %1$s %2$s help\n"
"\n" "\n"
" COMPONENT := { kernel | dev NAME }\n" " COMPONENT := { kernel | dev NAME }\n"
...@@ -1332,9 +1332,9 @@ static int do_help(int argc, char **argv) ...@@ -1332,9 +1332,9 @@ static int do_help(int argc, char **argv)
} }
static const struct cmd cmds[] = { static const struct cmd cmds[] = {
{ "probe", do_probe }, { "probe", do_probe },
{ "list", do_list }, { "list_builtins", do_list_builtins },
{ "help", do_help }, { "help", do_help },
{ 0 } { 0 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment