Thread (24 messages) 24 messages, 3 authors, 2022-01-21

Re: [PATCH bpf-next v4 3/8] bpftool: Add gen btf command

flat view

From: Andrii Nakryiko <hidden>
Date: 2022-01-21 21:35:32
Also in: bpf

On Fri, Jan 21, 2022 at 12:40 PM Mauricio Vásquez Bernal
[off-list ref] wrote:
On Wed, Jan 12, 2022 at 1:08 PM Quentin Monnet [off-list ref] wrote:
quoted
2022-01-12 09:27 UTC-0500 ~ Mauricio Vásquez [off-list ref]
quoted
This command is implemented under the "gen" command in bpftool and the
syntax is the following:

$ bpftool gen btf INPUT OUTPUT OBJECT(S)
Thanks a lot for this work!

Please update the relevant manual page under Documentation, to let users
know how to use the feature. You may also consider adding an example at
the end of that document.
We're working on it, and will be part of the next spin.
quoted
The bash completion script should also be updated with the new "btf"
subcommand for "gen". Given that all the arguments are directories and
files, it should not be hard.
Will do.
quoted
Have you considered adding tests for the feature? There are a few
bpftool-related selftests under tools/testing/selftests/bpf/.
Yes, we have but it seems not that trivial. One idea I have is to
include a couple of BTF source files from
https://github.com/aquasecurity/btfhub-archive/ and create a test
program that generates some field, type and enum relocations. Then we
could check if the generated BTF file has the expected types, fields
and so on by parsing it and using the BTF API from libbpf. One concern
about it is the size of those two source BTF files (~5MB each),
perhaps we should not include a full file but something that is
already "trimmed"? Another possibility is to use
"/sys/kernel/btf/vmlinux" but it'll limit the test to machines with
CONFIG_DEBUG_INFO_BTF.

Do you have any ideas / feedback on this one? Should the tests be
included in this series or can we push them later on?
See how we test CO-RE relocations and how we use C files to get custom
BTFs. See progs/btf_* and prog_tests/core_reloc.c selftests. You don't
have to use real vmlinux BTF to test this functionality.

quoted
quoted
INPUT can be either a single BTF file or a folder containing BTF files,
when it's a folder, a BTF file is generated for each BTF file contained
in this folder. OUTPUT is the file (or folder) where generated files are
stored and OBJECT(S) is the list of bpf objects we want to generate the
BTF file(s) for (each generated BTF file contains all the types needed
by all the objects).

Signed-off-by: Mauricio Vásquez <redacted>
Signed-off-by: Rafael David Tinoco <redacted>
Signed-off-by: Lorenzo Fontana <redacted>
Signed-off-by: Leonardo Di Donato <redacted>
---
 tools/bpf/bpftool/gen.c | 117 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 117 insertions(+)
[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help