mbox series

[bpf-next,v4,0/2] Fix btf dump error caused by declaration

Message ID 20220301053250.1464204-1-xukuohai@huawei.com (mailing list archive)
Headers show
Series Fix btf dump error caused by declaration | expand

Message

Xu Kuohai March 1, 2022, 5:32 a.m. UTC
This series fixes a btf dump error caused by forward declaration.

Currently if a declaration appears in the BTF before the definition,
the definition is dumped as a conflicting name, eg:

    $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'"
    [81287] FWD 'unix_sock' fwd_kind=struct
    [89336] STRUCT 'unix_sock' size=1024 vlen=14

    $ bpftool btf dump file vmlinux format c | grep "struct unix_sock"
    struct unix_sock;
    struct unix_sock___2 {	<--- conflict, the "___2" is unexpected
		    struct unix_sock___2 *unix_sk;

This causes a "definition not found" compilation error if the dump output
is used as a header file.


v3->v4:
  - Fix failure test case
v2->v3:
  - Fix the truncated email header
v1->v2:
  - Add fix for enum forward declaration

Xu Kuohai (2):
  libbpf: Skip forward declaration when counting duplicated type names
  selftests/bpf: Update btf_dump case for conflicting names

 tools/lib/bpf/btf_dump.c                      |  5 ++
 .../selftests/bpf/prog_tests/btf_dump.c       | 54 ++++++++++++++-----
 2 files changed, 46 insertions(+), 13 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 1, 2022, 12:50 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 1 Mar 2022 00:32:48 -0500 you wrote:
> This series fixes a btf dump error caused by forward declaration.
> 
> Currently if a declaration appears in the BTF before the definition,
> the definition is dumped as a conflicting name, eg:
> 
>     $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'"
>     [81287] FWD 'unix_sock' fwd_kind=struct
>     [89336] STRUCT 'unix_sock' size=1024 vlen=14
> 
> [...]

Here is the summary with links:
  - [bpf-next,v4,1/2] libbpf: Skip forward declaration when counting duplicated type names
    https://git.kernel.org/bpf/bpf-next/c/4226961b0019
  - [bpf-next,v4,2/2] selftests/bpf: Update btf_dump case for conflicting names
    https://git.kernel.org/bpf/bpf-next/c/bd004cad78c0

You are awesome, thank you!