[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5db3044f82e10_36802aec12c585b83b@john-XPS-13-9370.notmuch>
Date: Fri, 25 Oct 2019 07:18:55 -0700
From: John Fastabend <john.fastabend@...il.com>
To: Jakub Sitnicki <jakub@...udflare.com>,
John Fastabend <john.fastabend@...il.com>
Cc: bpf@...r.kernel.org, Martin KaFai Lau <kafai@...com>,
netdev@...r.kernel.org, kernel-team@...udflare.com
Subject: Re: [RFC bpf-next 0/5] Extend SOCKMAP to store listening sockets
Jakub Sitnicki wrote:
> On Thu, Oct 24, 2019 at 06:56 PM CEST, John Fastabend wrote:
> > Jakub Sitnicki wrote:
>
> [...]
>
> >> I'm looking for feedback if there's anything fundamentally wrong with
> >> extending SOCKMAP map type like this that I might have missed.
> >
> > I think this looks good. The main reason I blocked it off before is mostly
> > because I had no use-case for it and the complication with what to do with
> > child sockets. Clearing the psock state seems OK to me if user wants to
> > add it back to a map they can simply grab it again from a sockops
> > event.
>
> Thanks for taking a look at the code.
>
> > By the way I would eventually like to see the lookup hook return the
> > correct type (PTR_TO_SOCKET_OR_NULL) so that the verifier "knows" the type
> > and the socket can be used the same as if it was pulled from a sk_lookup
> > helper.
>
> Wait... you had me scratching my head there for a minute.
>
> I haven't whitelisted bpf_map_lookup_elem for SOCKMAP in
> check_map_func_compatibility so verifier won't allow lookups from BPF.
>
> If we wanted to do that, I don't actually have a use-case for it, I
> think would have to extend get_func_proto for SK_SKB and SK_REUSEPORT
> prog types. At least that's what docs for bpf_map_lookup_elem suggest:
Right, so its not required for your series just letting you know I will
probably look to do this shortly. It would be useful for some use cases
we have.
>
> /* If kernel subsystem is allowing eBPF programs to call this function,
> * inside its own verifier_ops->get_func_proto() callback it should return
> * bpf_map_lookup_elem_proto, so that verifier can properly check the arguments
> *
> * Different map implementations will rely on rcu in map methods
> * lookup/update/delete, therefore eBPF programs must run under rcu lock
> * if program is allowed to access maps, so check rcu_read_lock_held in
> * all three functions.
> */
> BPF_CALL_2(bpf_map_lookup_elem, struct bpf_map *, map, void *, key)
> {
> WARN_ON_ONCE(!rcu_read_lock_held());
> return (unsigned long) map->ops->map_lookup_elem(map, key);
> }
>
> -Jakub
Powered by blists - more mailing lists