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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 11, 2022 at 7:42 PM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Wed, Feb 9, 2022 at 2:27 PM Mauricio Vásquez <mauricio@xxxxxxxxxx> wrote:
> >
> > From: Rafael David Tinoco <rafaeldtinoco@xxxxxxxxx>
> >
> > 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 <mauricio@xxxxxxxxxx>
> > Signed-off-by: Rafael David Tinoco <rafael.tinoco@xxxxxxxxxxx>
> > Signed-off-by: Lorenzo Fontana <lorenzo.fontana@xxxxxxxxxx>
> > Signed-off-by: Leonardo Di Donato <leonardo.didonato@xxxxxxxxxx>
> > ---
> >  .../bpf/bpftool/Documentation/bpftool-gen.rst | 93 +++++++++++++++++++
> >  1 file changed, 93 insertions(+)
> >
>
> [...]
>
> > +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.
>
>
> > +
> > +  ...
> > --
> > 2.25.1
> >




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux