From: Quentin Monnet <qmo@kernel.org>
To: Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org
Cc: tj@kernel.org, void@manifault.com
Subject: Re: [PATCH bpf-next] bpftool: allow compile-time checks of BPF map auto-attach support in skeleton
Date: Tue, 18 Jun 2024 20:56:44 +0100 [thread overview]
Message-ID: <073d8c8c-14bf-49c0-bc14-1e1d53b3e603@kernel.org> (raw)
In-Reply-To: <20240618183832.2535876-1-andrii@kernel.org>
On 18/06/2024 19:38, Andrii Nakryiko wrote:
> New versions of bpftool now emit additional link placeholders for BPF
> maps (struct_ops maps are the only maps right now that support
> attachment), and set up BPF skeleton in such a way that libbpf will
> auto-attach BPF maps automatically, assumming libbpf is recent enough
> (v1.5+). Old libbpf will do nothing with those links and won't attempt
> to auto-attach maps. This allows user code to handle both pre-v1.5 and
> v1.5+ versions of libbpf at runtime, if necessary.
>
> But if users don't have (or don't want to) control bpftool version that
> generates skeleton, then they can't just assume that skeleton will have
> link placeholders. To make this detection possible and easy, let's add
> the following to generated skeleton header file:
>
> #define BPF_SKEL_SUPPORTS_MAP_AUTO_ATTACH 1
>
> This can be used during compilation time to guard code that accesses
> skel->links.<map> slots.
>
> Note, if auto-attachment is undesirable, libbpf allows to disable this
> through bpf_map__set_autoattach(map, false). This is necessary only on
> libbpf v1.5+, older libbpf doesn't support map auto-attach anyways.
>
> Libbpf version can be detected at compilation time using
> LIBBPF_MAJOR_VERSION and LIBBPF_MINOR_VERSION macros, or at runtime with
> libbpf_major_version() and libbpf_minor_version() APIs.
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Looks good, thanks.
Acked-by: Quentin Monnet <qmo@kernel.org>
next prev parent reply other threads:[~2024-06-18 19:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 18:38 [PATCH bpf-next] bpftool: allow compile-time checks of BPF map auto-attach support in skeleton Andrii Nakryiko
2024-06-18 19:56 ` Quentin Monnet [this message]
2024-06-21 18:00 ` patchwork-bot+netdevbpf
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=073d8c8c-14bf-49c0-bc14-1e1d53b3e603@kernel.org \
--to=qmo@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=martin.lau@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox