Thread (13 messages) 13 messages, 7 authors, 2019-06-05

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

From: Björn Töpel <hidden>
Date: 2019-06-04 18:18:14

On 2019-06-04 19:25, Jonathan Lemon wrote:
On 4 Jun 2019, at 9:43, Jesper Dangaard Brouer wrote:
quoted
On Mon, 3 Jun 2019 09:38:51 -0700
Jonathan Lemon [off-list ref] wrote:
quoted
Currently, the AF_XDP code uses a separate map in order to
determine if an xsk is bound to a queue.  Instead of doing this,
have bpf_map_lookup_elem() return the queue_id, as a way of
indicating that there is a valid entry at the map index.
Just a reminder, that once we choose a return value, there the
queue_id, then it basically becomes UAPI, and we cannot change it.
Yes - Alexei initially wanted to return the sk_cookie instead, but
that's 64 bits and opens up a whole other can of worms.
Hmm, what other info would be useful? ifindex? Or going the the
other way, with read-only and just returning boolean?
quoted
Can we somehow use BTF to allow us to extend this later?

I was also going to point out that, you cannot return a direct pointer
to queue_id, as BPF-prog side can modify this... but Daniel already
pointed this out.
Ugh, good thing Daniel found this!


Björn
So, I see three solutions here (for this and Toke's patchset also,
which is encountering the same problem).

1) add a scratch register (Toke's approach)
2) add a PTR_TO_<type>, which has the access checked.  This is the most
    flexible approach, but does seem a bit overkill at the moment.
3) add another helper function, say, bpf_map_elem_present() which just
    returns a boolean value indicating whether there is a valid map entry
    or not.

I was starting to do 2), but wanted to get some more feedback first.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help