From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
brouer@redhat.com, Jonathan Lemon <jonathan.lemon@gmail.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH net-next 2/2] devmap: Allow map lookups from eBPF
Date: Tue, 04 Jun 2019 20:42:49 +0200 [thread overview]
Message-ID: <87blzdfaza.fsf@toke.dk> (raw)
In-Reply-To: <20190604183559.10db09d2@carbon>
Jesper Dangaard Brouer <brouer@redhat.com> writes:
> On Tue, 04 Jun 2019 17:24:10 +0200
> Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
>> We don't currently allow lookups into a devmap from eBPF, because the map
>> lookup returns a pointer directly to the dev->ifindex, which shouldn't be
>> modifiable from eBPF.
>>
>> However, being able to do lookups in devmaps is useful to know (e.g.)
>> whether forwarding to a specific interface is enabled. Currently, programs
>> work around this by keeping a shadow map of another type which indicates
>> whether a map index is valid.
>>
>> To allow lookups, simply copy the ifindex into a scratch variable and
>> return a pointer to this. If an eBPF program does modify it, this doesn't
>> matter since it will be overridden on the next lookup anyway. While this
>> does add a write to every lookup, the overhead of this is negligible
>> because the cache line is hot when both the write and the subsequent
>> read happens.
>
> When we choose the return value, here the ifindex, then this basically
> becomes UABI, right?
Well, we already have UABI on the insert side, where the value being
inserted has to be an ifindex. And we enforce value_size==4 when
creating the map. So IMO I'm just keeping to the already established
UAPI here.
That being said...
> Can we somehow use BTF to help us to make this extensible?
... this would not necessarily be a bad thing, it just needs to be done
on both the insert and lookup sides.
But I think this is a separate issue, which we need to solve anyway. And
I'm still not convinced that the map value is the right place to specify
what resources we want ;)
-Toke
next prev parent reply other threads:[~2019-06-04 18:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 15:24 [PATCH net-next 0/2] xdp: Allow lookup into devmaps before redirect Toke Høiland-Jørgensen
2019-06-04 15:24 ` [PATCH net-next 2/2] devmap: Allow map lookups from eBPF Toke Høiland-Jørgensen
2019-06-04 16:35 ` Jesper Dangaard Brouer
2019-06-04 18:42 ` Toke Høiland-Jørgensen [this message]
2019-06-04 19:41 ` Jonathan Lemon
2019-06-04 20:00 ` Toke Høiland-Jørgensen
2019-06-04 20:22 ` Toke Høiland-Jørgensen
2019-06-04 15:24 ` [PATCH net-next 1/2] bpf_xdp_redirect_map: Add flag to return XDP_PASS on map lookup failure Toke Høiland-Jørgensen
2019-06-05 10:39 ` Jesper Dangaard Brouer
2019-06-05 15:09 ` Jonathan Lemon
2019-06-06 10:01 ` Toke Høiland-Jørgensen
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=87blzdfaza.fsf@toke.dk \
--to=toke@redhat.com \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jolsa@redhat.com \
--cc=jonathan.lemon@gmail.com \
--cc=netdev@vger.kernel.org \
/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.