summaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/bash-completion
diff options
context:
space:
mode:
authorDaniel Müller <deso@posteo.net>2022-05-24 02:04:25 +0300
committerAndrii Nakryiko <andrii@kernel.org>2022-06-03 02:26:30 +0300
commit1ba5ad36e00f46e3f7676f5de6b87f5a2f57f1f1 (patch)
treee94a1aa6c059a535fbecae41fdc39f0a1c673a20 /tools/bpf/bpftool/bash-completion
parent0b27b3d9fdf88c132b095a30ee2c61cd6e56e6cc (diff)
downloadlinux-1ba5ad36e00f46e3f7676f5de6b87f5a2f57f1f1.tar.xz
bpftool: Use libbpf_bpf_attach_type_str
This change switches bpftool over to using the recently introduced libbpf_bpf_attach_type_str function instead of maintaining its own string representation for the bpf_attach_type enum. Note that contrary to other enum types, the variant names that bpftool maps bpf_attach_type to do not adhere a simple to follow rule. With bpf_prog_type, for example, the textual representation can easily be inferred by stripping the BPF_PROG_TYPE_ prefix and lowercasing the remaining string. bpf_attach_type violates this rule for various variants. We decided to fix up this deficiency with this change, meaning that bpftool uses the same textual representations as libbpf. Supporting tests, completion scripts, and man pages have been adjusted accordingly. However, we did add support for accepting (the now undocumented) original attach type names when they are provided by users. For the test (test_bpftool_synctypes.py), I have removed the enum representation checks, because we no longer mirror the various enum variant names in bpftool source code. For the man page, help text, and completion script checks we are now using enum definitions from uapi/linux/bpf.h as the source of truth directly. Signed-off-by: Daniel Müller <deso@posteo.net> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20220523230428.3077108-10-deso@posteo.net
Diffstat (limited to 'tools/bpf/bpftool/bash-completion')
-rw-r--r--tools/bpf/bpftool/bash-completion/bpftool18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 5df8d72c5179..91f89a9a5b36 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -407,8 +407,8 @@ _bpftool()
return 0
;;
5)
- local BPFTOOL_PROG_ATTACH_TYPES='msg_verdict \
- skb_verdict stream_verdict stream_parser \
+ local BPFTOOL_PROG_ATTACH_TYPES='sk_msg_verdict \
+ sk_skb_verdict sk_skb_stream_verdict sk_skb_stream_parser \
flow_dissector'
COMPREPLY=( $( compgen -W "$BPFTOOL_PROG_ATTACH_TYPES" -- "$cur" ) )
return 0
@@ -1039,12 +1039,14 @@ _bpftool()
return 0
;;
attach|detach)
- local BPFTOOL_CGROUP_ATTACH_TYPES='ingress egress \
- sock_create sock_ops device \
- bind4 bind6 post_bind4 post_bind6 connect4 connect6 \
- getpeername4 getpeername6 getsockname4 getsockname6 \
- sendmsg4 sendmsg6 recvmsg4 recvmsg6 sysctl getsockopt \
- setsockopt sock_release'
+ local BPFTOOL_CGROUP_ATTACH_TYPES='cgroup_inet_ingress cgroup_inet_egress \
+ cgroup_inet_sock_create cgroup_sock_ops cgroup_device cgroup_inet4_bind \
+ cgroup_inet6_bind cgroup_inet4_post_bind cgroup_inet6_post_bind \
+ cgroup_inet4_connect cgroup_inet6_connect cgroup_inet4_getpeername \
+ cgroup_inet6_getpeername cgroup_inet4_getsockname cgroup_inet6_getsockname \
+ cgroup_udp4_sendmsg cgroup_udp6_sendmsg cgroup_udp4_recvmsg \
+ cgroup_udp6_recvmsg cgroup_sysctl cgroup_getsockopt cgroup_setsockopt \
+ cgroup_inet_sock_release'
local ATTACH_FLAGS='multi override'
local PROG_TYPE='id pinned tag name'
# Check for $prev = $command first