[PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

Subsystems: bpf [general] (safe dynamic programs and tools), bpf [tooling] (bpftool), the rest

STALE2654d

4 messages, 4 authors, 2019-05-28 · open the first message on its own page

[PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

From: Andrii Nakryiko <hidden>
Date: 2019-05-26 00:01:11

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.

Suggested-by: Quentin Monnet <redacted>
Signed-off-by: Andrii Nakryiko <redacted>
---
 tools/bpf/bpftool/bash-completion/bpftool | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 75c01eafd3a1..fbbad0ed8e82 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -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
                             ;;
-- 
2.17.1

Re: [PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

From: Quentin Monnet <hidden>
Date: 2019-05-28 08:25:09

2019-05-25 17:01 UTC-0700 ~ Andrii Nakryiko [off-list ref]
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.

Suggested-by: Quentin Monnet <redacted>
Signed-off-by: Andrii Nakryiko <redacted>
Reviewed-by: Quentin Monnet <redacted>

Thanks!

Re: [PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2019-05-28 09:24:15

On 05/26/2019 02:01 AM, Andrii Nakryiko wrote:
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.

Suggested-by: Quentin Monnet <redacted>
Signed-off-by: Andrii Nakryiko <redacted>
Applied, thanks!

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

Re: [PATCH bpf-next] bpftool: auto-complete BTF IDs for btf dump

From: Andrii Nakryiko <hidden>
Date: 2019-05-28 16:41:29

On Tue, May 28, 2019 at 2:24 AM Daniel Borkmann [off-list ref] wrote:
On 05/26/2019 02:01 AM, Andrii Nakryiko wrote:
quoted
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.

Suggested-by: Quentin Monnet <redacted>
Signed-off-by: Andrii Nakryiko <redacted>
Applied, thanks!
Thanks!
(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 :(
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help