Skip to contentSkip to conversation

bpftool: auto-complete BTF IDs for btf dump

PATCH Applied Andrii Nakryiko 4 participants 4 messages May 26, 2019 – May 28, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpftool: auto-complete BTF IDs for btf dump

Auto-complete BTF IDs for btf dump id sub-command. List of possible BTF IDs is scavenged from loaded BPF programs that have associated BTFs, as there is currently no API in libbpf to fetch list of all BTFs in the system.

---
 tools/bpf/bpftool/bash-completion/bpftool | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/bpf/bpftool/bash-completion/bpftool +9 -0
index 75c01eafd3a1..fbbad0ed8e82 100644
@@ -71,6 +71,12 @@ _bpftool_get_prog_tags()
         command sed -n 's/.*"tag": "\(.*\)",$/\1/p' )" -- "$cur" ) )
 }
 
+_bpftool_get_btf_ids()
+{
+    COMPREPLY+=( $( compgen -W "$( bpftool -jp prog 2>&1 | \
+        command sed -n 's/.*"btf_id": \(.*\),\?$/\1/p' )" -- "$cur" ) )
+}
+
 _bpftool_get_obj_map_names()
 {
     local obj
@@ -635,6 +641,9 @@ _bpftool()
                                 map)
                                     _bpftool_get_map_ids
                                     ;;
+                                dump)
+                                    _bpftool_get_btf_ids
+                                    ;;
                             esac
                             return 0
                             ;;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

2019-05-25 17:01 UTC-0700 ~ Andrii Nakryiko <[email protected]>

Quoted 7 lines

Auto-complete BTF IDs for btf dump id sub-command. List of possible BTF IDs is scavenged from loaded BPF programs that have associated BTFs, as there is currently no API in libbpf to fetch list of all BTFs in the system.

Thanks!

maintainer Applied
#2 lore raw
In reply to Andrii Nakryiko
Quoted 7 lines · Andrii Nakryiko

Auto-complete BTF IDs for btf dump id sub-command. List of possible BTF IDs is scavenged from loaded BPF programs that have associated BTFs, as there is currently no API in libbpf to fetch list of all BTFs in the system.

Applied, thanks!

(Please add versioning in the subject in future, e.g. [PATCH v2 bpf-next])

#3 lore raw
Quoted 11 lines · Daniel Borkmann
Quoted 7 lines · Andrii Nakryiko

Auto-complete BTF IDs for btf dump id sub-command. List of possible BTF IDs is scavenged from loaded BPF programs that have associated BTFs, as there is currently no API in libbpf to fetch list of all BTFs in the system.

Applied, thanks!

Thanks!

Quoted 2 lines

(Please add versioning in the subject in future, e.g. [PATCH v2 bpf-next])

Ah yeah, sorry about that, forgot to update --subject-prefix when generating patch :(