Re: [PATCH bpf-next 4/9] bpftool: add support for BTF_KIND_TAG

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

 



On Wed, Sep 8, 2021 at 10:28 PM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@xxxxxx> wrote:
> >
> > added bpftool support to dump BTF_KIND_TAG information.
> > The new bpftool will be used in later patches to dump
> > btf in the test bpf program object file.
> >

What should be done for `bpftool btf dump file <path> format c` if BTF
contains btf_tag? Should it ignore it silently? Should it error out?
Or should we corrupt output (as will be the case right now, I think)?

> > Signed-off-by: Yonghong Song <yhs@xxxxxx>
> > ---
> >  tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> > index f7e5ff3586c9..89c17ea62d8e 100644
> > --- a/tools/bpf/bpftool/btf.c
> > +++ b/tools/bpf/bpftool/btf.c
> > @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
> >         [BTF_KIND_VAR]          = "VAR",
> >         [BTF_KIND_DATASEC]      = "DATASEC",
> >         [BTF_KIND_FLOAT]        = "FLOAT",
> > +       [BTF_KIND_TAG]          = "TAG",
> >  };
> >
> >  struct btf_attach_table {
> > @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> >                         printf(" size=%u", t->size);
> >                 break;
> >         }
> > +       case BTF_KIND_TAG: {
> > +               const struct btf_tag *tag = (const void *)(t + 1);
> > +
> > +
>
> extra empty line?
>
> > +               if (json_output) {
> > +                       jsonw_uint_field(w, "type_id", t->type);
> > +                       if (btf_kflag(t))
> > +                               jsonw_int_field(w, "comp_id", -1);
> > +                       else
> > +                               jsonw_uint_field(w, "comp_id", tag->comp_id);
> > +               } else if (btf_kflag(t)) {
> > +                       printf(" type_id=%u, comp_id=-1", t->type);
> > +               } else {
> > +                       printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id);
> > +               }
>
> here not using kflag would be more natural as well ;)
>
> > +               break;
> > +       }
> >         default:
> >                 break;
> >         }
> > --
> > 2.30.2
> >



[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