Re: [PATCH bpf-next 1/2] libbpf: don't require full struct enum64 in UAPI headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrii Nakryiko <andrii@xxxxxxxxxx> writes:

> Drop the requirement for system-wide kernel UAPI headers to provide full
> struct btf_enum64 definition. This is an unexpected requirement that
> slipped in libbpf 1.0 and put unnecessary pressure ([0]) on users to have
> a bleeding-edge kernel UAPI header from unreleased Linux 6.0.
>
> To achieve this, we forward declare struct btf_enum64. But that's not
> enough as there is btf_enum64_value() helper that expects to know the
> layout of struct btf_enum64. So we get a bit creative with
> reinterpreting memory layout as array of __u32 and accesing lo32/hi32
> fields as array elements. Alternative way would be to have a local
> pointer variable for anonymous struct with exactly the same layout as
> struct btf_enum64, but that gets us into C++ compiler errors complaining
> about invalid type casts. So play it safe, if ugly.
>
>   [0] Closes: https://github.com/libbpf/libbpf/issues/562
>
> Reported-by: Toke Høiland-Jørgensen <toke@xxxxxxx>
> Fixes: d90ec262b35b ("libbpf: Add enum64 support for btf_dump")
> Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

This seems like a reasonable (and only a bit ugly) workaround; thanks!

Acked-by: Toke Høiland-Jørgensen <toke@xxxxxxx>




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux