]> git.baikalelectronics.ru Git - kernel.git/commit
tools: bpftool: detect sub-programs from the eBPF sequence
authorJiong Wang <jiong.wang@netronome.com>
Fri, 2 Mar 2018 02:01:18 +0000 (18:01 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 2 Mar 2018 02:29:48 +0000 (18:29 -0800)
commit95eee4768cebbe23c50f4ff39129034cdae6b46e
treedb1ddf7b1a0bbc1fb377c9e1f192d3ad192d298f
parent39efa0ea745d53c3146bb25e0843af36a57d515f
tools: bpftool: detect sub-programs from the eBPF sequence

This patch detect all sub-programs from the eBPF sequence and keep the
information in the new CFG data structure.

The detection algorithm is basically the same as the one in verifier except
we need to use insn->off instead of insn->imm to get the pc-relative call
offset. Because verifier has modified insn->off/insn->imm during finishing
the verification.

Also, we don't need to do some sanity checks as verifier has done them.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/cfg.c [new file with mode: 0644]
tools/bpf/bpftool/cfg.h [new file with mode: 0644]