All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net
Cc: andrii@kernel.org, kernel-team@fb.com
Subject: Re: [PATCH bpf-next 1/2] libbpf: don't require full struct enum64 in UAPI headers
Date: Tue, 27 Sep 2022 13:43:45 +0200	[thread overview]
Message-ID: <87zgelrqj2.fsf@toke.dk> (raw)
In-Reply-To: <20220927042940.147185-1-andrii@kernel.org>

Andrii Nakryiko <andrii@kernel.org> 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@toke.dk>
> Fixes: d90ec262b35b ("libbpf: Add enum64 support for btf_dump")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

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

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

      parent reply	other threads:[~2022-09-27 11:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  4:29 [PATCH bpf-next 1/2] libbpf: don't require full struct enum64 in UAPI headers Andrii Nakryiko
2022-09-27  4:29 ` [PATCH bpf-next 2/2] selftests/bpf: enforce C++11 mode for test_cpp test Andrii Nakryiko
2022-09-27 13:28   ` Daniel Borkmann
2022-09-27 11:43 ` Toke Høiland-Jørgensen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgelrqj2.fsf@toke.dk \
    --to=toke@toke.dk \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.