From: "Toke Høiland-Jørgensen" <toke@redhat•com>
To: Jonathan Lemon <jonathan.lemon@gmail•com>,
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>,
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 22:00:34 +0200 [thread overview]
Message-ID: <877ea1f7dp.fsf@toke.dk> (raw)
In-Reply-To: <A5CA54A9-34A0-4583-84E8-0530BAEE215B@gmail.com>
Jonathan Lemon <jonathan.lemon@gmail•com> writes:
> On 4 Jun 2019, at 9:35, Jesper Dangaard Brouer wrote:
>
>> 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?
>>
>> Can we somehow use BTF to help us to make this extensible?
>>
>> As Toke mention in the cover letter, we really want to know if the
>> chosen egress have actually enabled/allocated resources for XDP
>> transmitting, but as we currently don't have in-kernel way to query
>> thus (thus, we cannot expose such info).
>
> Would it be better to add a helper like bpf_map_element_present(), which
> just returns a boolean value indicating whether the entry is NULL or not?
>
> This would solve this problem (and my xskmap problem).
Ah, totally missed that other thread; will go reply there :)
-Toke
next prev parent reply other threads:[~2019-06-04 20:00 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
2019-06-04 19:41 ` Jonathan Lemon
2019-06-04 20:00 ` Toke Høiland-Jørgensen [this message]
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=877ea1f7dp.fsf@toke.dk \
--to=toke@redhat$(echo .)com \
--cc=acme@redhat$(echo .)com \
--cc=ast@kernel$(echo .)org \
--cc=brouer@redhat$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=davem@davemloft$(echo .)net \
--cc=jolsa@redhat$(echo .)com \
--cc=jonathan.lemon@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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