mbox series

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

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

Message

Xu Kuohai Feb. 24, 2022, 12:09 p.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.

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

Andrii Nakryiko March 1, 2022, 1:31 a.m. UTC | #1
On Thu, Feb 24, 2022 at 3:59 AM Xu Kuohai <xukuohai@huawei.com> 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
>
>     $ 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.
>

seems like I replied about test failures on v2 instead of v3 (there
are test failures for v3, though), please check the link in that
reply. But I wanted to also mention that it would be great to keep a
succinct version log in the cover letter with what was changed or
fixed between versions (see other submissions on the mailing list).

> 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(-)
>
> --
> 2.30.2
>
Xu Kuohai March 1, 2022, 2:28 a.m. UTC | #2
On 2022/3/1 9:31, Andrii Nakryiko wrote:
> On Thu, Feb 24, 2022 at 3:59 AM Xu Kuohai <xukuohai@huawei.com> 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
>>
>>      $ 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.
>>
> 
> seems like I replied about test failures on v2 instead of v3 (there
> are test failures for v3, though), please check the link in that
> reply. But I wanted to also mention that it would be great to keep a
> succinct version log in the cover letter with what was changed or
> fixed between versions (see other submissions on the mailing list).
> 

Sorry for not describing the change log clearly, will add it in the v4.