[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <afd9317561b1823da2fa473f29723da83247767e.camel@chromium.org>
Date: Tue, 08 Dec 2020 20:40:08 +0100
From: Florent Revest <revest@...omium.org>
To: Martin KaFai Lau <kafai@...com>
Cc: bpf@...r.kernel.org, ast@...nel.org, daniel@...earbox.net,
andrii@...nel.org, kpsingh@...omium.org, revest@...gle.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 1/3] bpf: Expose bpf_get_socket_cookie to
tracing programs
On Fri, 2020-12-04 at 11:47 -0800, Martin KaFai Lau wrote:
> On Thu, Dec 03, 2020 at 10:33:28PM +0100, Florent Revest wrote:
> > +const struct bpf_func_proto
> > bpf_get_socket_cookie_sock_tracing_proto = {
> > + .func = bpf_get_socket_cookie_sock,
> > + .gpl_only = false,
> > + .ret_type = RET_INTEGER,
> > + .arg1_type = ARG_PTR_TO_BTF_ID_SOCK_COMMON,
>
> In tracing where it gets a sk pointer, the sk could be NULL.
> A NULL check is required in the helper. Please refer to
> bpf_skc_to_tcp_sock[_proto] as an example.
Ah, good catch! :)
> This proto is in general also useful for non tracing context where
> it can get a hold of a sk pointer. (e.g. another similar usage that
> will have a hold on a sk pointer for BPF_PROG_TYPE_SK_REUSEPORT [0]).
Agreed.
> In case if you don't need sleepable at this point as Daniel
> mentioned in another thread. Does it make sense to rename this
> proto to something like bpf_get_socket_pointer_cookie_proto?
My understanding is that I could have two helpers definitions and
protos, one calling sock_gen_cookie and the other one calling
__sock_gen_cookie. Then I could just use:
return prog->aux->sleepable
? bpf_get_socket_pointer_cookie_sleepable_proto
: bpf_get_socket_pointer_cookie_proto;
Would that work ?
Powered by blists - more mailing lists