bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Pass a map to a global BPF function
       [not found] <CAC1LvL0670CWq183g54w3HGsByjcBaBL2rrTP1PyTbbYfm76iw@mail.gmail.com>
@ 2021-09-21 20:04 ` Alexei Starovoitov
  0 siblings, 0 replies; only message in thread
From: Alexei Starovoitov @ 2021-09-21 20:04 UTC (permalink / raw)
  To: Zvi Effron, bpf; +Cc: Xdp

On Mon, Sep 13, 2021 at 10:44 AM Zvi Effron <zeffron@riotgames.com> wrote:
>
> Hi all,
>
> We have some map-of-arrays that we use for tracking labeled metrics in
> our XDP code. The inner map tracks the metrics for a given label,
> which is the key in the outer map.
>
> Our XDP code calls several global BPF functions (freplaced, so can't
> be inlined). Currently, each global function has to make a lookup to
> get the inner map to record its metrics. Now that non-context pointers
> can be passed to global BPF functions, is it possible to pass maps to
> these global functions?

The program can pass a pointer to struct bpf_map and the verifier
will recognize it as PTR_TO_BTF_ID.
It won't be a CONST_PTR_TO_MAP, so secondary lookup won't be
allowed, but if that's the desired use case then the verifier can be extended
to recognize it.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-21 20:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAC1LvL0670CWq183g54w3HGsByjcBaBL2rrTP1PyTbbYfm76iw@mail.gmail.com>
2021-09-21 20:04 ` Pass a map to a global BPF function Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).