Thread (21 messages) 21 messages, 2 authors, 2022-02-16

Re: [PATCH bpf-next v6 6/7] bpftool: gen min_core_btf explanation and examples

flat view

From: Mauricio Vásquez Bernal <hidden>
Date: 2022-02-15 22:57:11
Also in: bpf

On Fri, Feb 11, 2022 at 7:42 PM Andrii Nakryiko
[off-list ref] wrote:
On Wed, Feb 9, 2022 at 2:27 PM Mauricio Vásquez [off-list ref] wrote:
quoted
From: Rafael David Tinoco <redacted>

Add "min_core_btf" feature explanation and one example of how to use it
to bpftool-gen man page.

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>
---
 .../bpf/bpftool/Documentation/bpftool-gen.rst | 93 +++++++++++++++++++
 1 file changed, 93 insertions(+)
[...]
quoted
+Now, the "5.4.0-smaller.btf" file may be used by libbpf as an external BTF file
+when loading the "one.bpf.o" object into the "5.4.0-example" kernel. Note that
+the generated BTF file won't allow other eBPF objects to be loaded, just the
+ones given to min_core_btf.
+
+::
+
+  struct bpf_object *obj = NULL;
+  struct bpf_object_open_opts openopts = {};
+
+  openopts.sz = sizeof(struct bpf_object_open_opts);
+  openopts.btf_custom_path = "./5.4.0-smaller.btf";
+
+  obj = bpf_object__open_file("./one.bpf.o", &openopts);
Can you please use LIBBPF_OPTS() macro in the example, that's how
users are normally expected to use OPTS-based APIs anyways. Also there
is no need for "./" when specifying file location. This is a different
case than running a binary in the shell, where binary is searched in
PATH. This is never done when opening files.

So all this should be:

LIBBPF_OPTS(bpf_object_open_opts, opts, .btf_custom_path = "5.4.0-smaller.btf");
struct bpf_object *obj;
I suppose you meant DECLARE_LIBBPF_OPTS(...)
obj = bpf_object__open_file("one.bpf.o", &opts);

That's all.

quoted
+
+  ...
--
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help