BPF List
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Martynas Pumputis <m@lambda.lt>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, m@lambda.lt
Subject: RE: [PATCH v2 bpf-next] libbpf: fix reuse of pinned map on older kernel
Date: Mon, 12 Jul 2021 12:19:52 -0700	[thread overview]
Message-ID: <60ec95d89c590_50e1d208fc@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20210712125552.58705-1-m@lambda.lt>

Martynas Pumputis wrote:
> When loading a BPF program with a pinned map, the loader checks whether
> the pinned map can be reused, i.e. their properties match. To derive
> such of the pinned map, the loader invokes BPF_OBJ_GET_INFO_BY_FD and
> then does the comparison.
> 
> Unfortunately, on < 4.12 kernels the BPF_OBJ_GET_INFO_BY_FD is not
> available, so loading the program fails with the following error:
> 
> 	libbpf: failed to get map info for map FD 5: Invalid argument
> 	libbpf: couldn't reuse pinned map at
> 		'/sys/fs/bpf/tc/globals/cilium_call_policy': parameter
> 		mismatch"
> 	libbpf: map 'cilium_call_policy': error reusing pinned map
> 	libbpf: map 'cilium_call_policy': failed to create:
> 		Invalid argument(-22)
> 	libbpf: failed to load object 'bpf_overlay.o'
> 
> To fix this, fallback to derivation of the map properties via
> /proc/$PID/fdinfo/$MAP_FD if BPF_OBJ_GET_INFO_BY_FD fails with EINVAL,
> which can be used as an indicator that the kernel doesn't support
> the latter.
> 
> Signed-off-by: Martynas Pumputis <m@lambda.lt>
> ---

LGTM.

Acked-by: John Fastabend <john.fastabend@gmail.com>

      reply	other threads:[~2021-07-12 19:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 12:55 [PATCH v2 bpf-next] libbpf: fix reuse of pinned map on older kernel Martynas Pumputis
2021-07-12 19:19 ` John Fastabend [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=60ec95d89c590_50e1d208fc@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=m@lambda.lt \
    /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