Message ID | 20210913155150.3727112-1-yhs@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: add support for new btf kind BTF_KIND_TAG | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 8 maintainers not CCed: thunder.leizhen@huawei.com kpsingh@kernel.org john.fastabend@gmail.com iii@linux.ibm.com songliubraving@fb.com quentin@isovalent.com netdev@vger.kernel.org kafai@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 92 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
bpf/vmtest-bpf-next | success | VM_Test |
bpf/vmtest-bpf-next-PR | success | PR summary |
On Mon, Sep 13, 2021 at 8:51 AM Yonghong Song <yhs@fb.com> 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. > > Currently, the tags are not emitted with > bpftool btf dump file <path> format c > and they are silently ignored. The tag information is > mostly used in the kernel for verification purpose and the kernel > uses its own btf to check. With adding these tags > to vmlinux.h, tags will be encoded in program's btf but > they will not be used by the kernel, at least for now. > So let us delay adding these tags to format C header files > until there is a real need. > > Signed-off-by: Yonghong Song <yhs@fb.com> > --- Acked-by: Andrii Nakryiko <andrii@kernel.org> > tools/bpf/bpftool/btf.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > index f7e5ff3586c9..49743ad96851 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,17 @@ 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); > + > + if (json_output) { > + jsonw_uint_field(w, "type_id", t->type); > + jsonw_int_field(w, "component_idx", tag->component_idx); > + } else { > + printf(" type_id=%u component_idx=%d", t->type, tag->component_idx); > + } > + break; > + } > default: > break; > } > -- > 2.30.2 >
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index f7e5ff3586c9..49743ad96851 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,17 @@ 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); + + if (json_output) { + jsonw_uint_field(w, "type_id", t->type); + jsonw_int_field(w, "component_idx", tag->component_idx); + } else { + printf(" type_id=%u component_idx=%d", t->type, tag->component_idx); + } + break; + } default: break; }
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. Currently, the tags are not emitted with bpftool btf dump file <path> format c and they are silently ignored. The tag information is mostly used in the kernel for verification purpose and the kernel uses its own btf to check. With adding these tags to vmlinux.h, tags will be encoded in program's btf but they will not be used by the kernel, at least for now. So let us delay adding these tags to format C header files until there is a real need. Signed-off-by: Yonghong Song <yhs@fb.com> --- tools/bpf/bpftool/btf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)