OSDN Git Service

tools/bpf: fix bpftool map dump with bitfields
authorYonghong Song <yhs@fb.com>
Thu, 10 Jan 2019 19:14:02 +0000 (11:14 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 11 Jan 2019 09:40:54 +0000 (10:40 +0100)
commit298e59d322954e89ed2a556c601a04a4c007d1b3
tree8702529ada7e857caa223af4c4523d5c2e58cb59
parente43207fa2e6130e39e3aca4c55e2ee21cfb46828
tools/bpf: fix bpftool map dump with bitfields

Commit 8772c8bc093b ("tools: bpftool: support pretty print
with kind_flag set") added bpftool map dump with kind_flag
support. When bitfield_size can be retrieved directly from
btf_member, function btf_dumper_bitfield() is called to
dump the bitfield. The implementation passed the
wrong parameter "bit_offset" to the function. The excepted
value is the bit_offset within a byte while the passed-in
value is the struct member offset.

This commit fixed the bug with passing correct "bit_offset"
with adjusted data pointer.

Fixes: 8772c8bc093b ("tools: bpftool: support pretty print with kind_flag set")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/btf_dumper.c