]> git.baikalelectronics.ru Git - kernel.git/commit
bpftool: Adding support for BTF program names
authorRaman Shukhau <ramasha@fb.com>
Wed, 19 Jan 2022 10:02:55 +0000 (02:02 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 19 Jan 2022 18:04:41 +0000 (10:04 -0800)
commit289fe2e1852883b8e2d1b92978281b0c5029b53d
tree9abb535a224c7dc4899b8a0c734772f4549a8764
parentfe11b96462cf1b2947a96ead251430e10a7ed983
bpftool: Adding support for BTF program names

`bpftool prog list` and other bpftool subcommands that show
BPF program names currently get them from bpf_prog_info.name.
That field is limited to 16 (BPF_OBJ_NAME_LEN) chars which leads
to truncated names since many progs have much longer names.

The idea of this change is to improve all bpftool commands that
output prog name so that bpftool uses info from BTF to print
program names if available.

It tries bpf_prog_info.name first and fall back to btf only if
the name is suspected to be truncated (has 15 chars length).

Right now `bpftool p show id <id>` returns capped prog name

<id>: kprobe  name example_cap_cap  tag 712e...
...

With this change it would return

<id>: kprobe  name example_cap_capable  tag 712e...
...

Note, other commands that print prog names (e.g. "bpftool
cgroup tree") are also addressed in this change.

Signed-off-by: Raman Shukhau <ramasha@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220119100255.1068997-1-ramasha@fb.com
tools/bpf/bpftool/cgroup.c
tools/bpf/bpftool/common.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/prog.c