diff options
author | Daniel T. Lee <danieltimlee@gmail.com> | 2019-08-12 22:46:20 -0400 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-08-15 20:00:33 -0400 |
commit | 10a708c24a31ae1be1ea23d1c38da2691d1fd65c (patch) | |
tree | b15a913e563e50885276c2dfdd7c8842176d7dbc | |
parent | 37c7f863ba92f0a7aa8bdfde9dfb6c392393fb83 (diff) |
tools: bpftool: add bash-completion for net attach/detach
This commit adds bash-completion for new "net attach/detach"
subcommand for attaching XDP program on interface.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | tools/bpf/bpftool/bash-completion/bpftool | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool index df16c5415444..4549fd424069 100644 --- a/tools/bpf/bpftool/bash-completion/bpftool +++ b/tools/bpf/bpftool/bash-completion/bpftool | |||
@@ -201,6 +201,10 @@ _bpftool() | |||
201 | _bpftool_get_prog_tags | 201 | _bpftool_get_prog_tags |
202 | return 0 | 202 | return 0 |
203 | ;; | 203 | ;; |
204 | dev) | ||
205 | _sysfs_get_netdevs | ||
206 | return 0 | ||
207 | ;; | ||
204 | file|pinned) | 208 | file|pinned) |
205 | _filedir | 209 | _filedir |
206 | return 0 | 210 | return 0 |
@@ -399,10 +403,6 @@ _bpftool() | |||
399 | _filedir | 403 | _filedir |
400 | return 0 | 404 | return 0 |
401 | ;; | 405 | ;; |
402 | dev) | ||
403 | _sysfs_get_netdevs | ||
404 | return 0 | ||
405 | ;; | ||
406 | *) | 406 | *) |
407 | COMPREPLY=( $( compgen -W "map" -- "$cur" ) ) | 407 | COMPREPLY=( $( compgen -W "map" -- "$cur" ) ) |
408 | _bpftool_once_attr 'type' | 408 | _bpftool_once_attr 'type' |
@@ -498,10 +498,6 @@ _bpftool() | |||
498 | key|value|flags|name|entries) | 498 | key|value|flags|name|entries) |
499 | return 0 | 499 | return 0 |
500 | ;; | 500 | ;; |
501 | dev) | ||
502 | _sysfs_get_netdevs | ||
503 | return 0 | ||
504 | ;; | ||
505 | *) | 501 | *) |
506 | _bpftool_once_attr 'type' | 502 | _bpftool_once_attr 'type' |
507 | _bpftool_once_attr 'key' | 503 | _bpftool_once_attr 'key' |
@@ -778,18 +774,67 @@ _bpftool() | |||
778 | esac | 774 | esac |
779 | ;; | 775 | ;; |
780 | net) | 776 | net) |
777 | local PROG_TYPE='id pinned tag' | ||
778 | local ATTACH_TYPES='xdp xdpgeneric xdpdrv xdpoffload' | ||
781 | case $command in | 779 | case $command in |
780 | show|list) | ||
781 | [[ $prev != "$command" ]] && return 0 | ||
782 | COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) | ||
783 | return 0 | ||
784 | ;; | ||
785 | attach) | ||
786 | case $cword in | ||
787 | 3) | ||
788 | COMPREPLY=( $( compgen -W "$ATTACH_TYPES" -- "$cur" ) ) | ||
789 | return 0 | ||
790 | ;; | ||
791 | 4) | ||
792 | COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) ) | ||
793 | return 0 | ||
794 | ;; | ||
795 | 5) | ||
796 | case $prev in | ||
797 | id) | ||
798 | _bpftool_get_prog_ids | ||
799 | ;; | ||
800 | pinned) | ||
801 | _filedir | ||
802 | ;; | ||
803 | esac | ||
804 | return 0 | ||
805 | ;; | ||
806 | 6) | ||
807 | COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) | ||
808 | return 0 | ||
809 | ;; | ||
810 | 8) | ||
811 | _bpftool_once_attr 'overwrite' | ||
812 | return 0 | ||
813 | ;; | ||
814 | esac | ||
815 | ;; | ||
816 | detach) | ||
817 | case $cword in | ||
818 | 3) | ||
819 | COMPREPLY=( $( compgen -W "$ATTACH_TYPES" -- "$cur" ) ) | ||
820 | return 0 | ||
821 | ;; | ||
822 | 4) | ||
823 | COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) | ||
824 | return 0 | ||
825 | ;; | ||
826 | esac | ||
827 | ;; | ||
782 | *) | 828 | *) |
783 | [[ $prev == $object ]] && \ | 829 | [[ $prev == $object ]] && \ |
784 | COMPREPLY=( $( compgen -W 'help \ | 830 | COMPREPLY=( $( compgen -W 'help \ |
785 | show list' -- "$cur" ) ) | 831 | show list attach detach' -- "$cur" ) ) |
786 | ;; | 832 | ;; |
787 | esac | 833 | esac |
788 | ;; | 834 | ;; |
789 | feature) | 835 | feature) |
790 | case $command in | 836 | case $command in |
791 | probe) | 837 | probe) |
792 | [[ $prev == "dev" ]] && _sysfs_get_netdevs && return 0 | ||
793 | [[ $prev == "prefix" ]] && return 0 | 838 | [[ $prev == "prefix" ]] && return 0 |
794 | if _bpftool_search_list 'macros'; then | 839 | if _bpftool_search_list 'macros'; then |
795 | COMPREPLY+=( $( compgen -W 'prefix' -- "$cur" ) ) | 840 | COMPREPLY+=( $( compgen -W 'prefix' -- "$cur" ) ) |