linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florent Revest <revest@chromium.org>
To: Martin KaFai Lau <kafai@fb.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, kpsingh@chromium.org, revest@google.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 1/3] bpf: Expose bpf_get_socket_cookie to tracing programs
Date: Tue, 08 Dec 2020 20:40:08 +0100	[thread overview]
Message-ID: <afd9317561b1823da2fa473f29723da83247767e.camel@chromium.org> (raw)
In-Reply-To: <20201204194748.cqyz7hfx5s5dyszc@kafai-mbp.dhcp.thefacebook.com>

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 ?


      reply	other threads:[~2020-12-08 20:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 21:33 Florent Revest
2020-12-03 21:33 ` [PATCH bpf-next v2 2/3] selftests/bpf: Integrate the socket_cookie test to test_progs Florent Revest
2020-12-03 21:33 ` [PATCH bpf-next v2 3/3] bpf: Add a selftest for the tracing bpf_get_socket_cookie Florent Revest
2020-12-04 18:56 ` [PATCH bpf-next v2 1/3] bpf: Expose bpf_get_socket_cookie to tracing programs Daniel Borkmann
2020-12-04 19:03   ` Daniel Borkmann
2020-12-08 19:30     ` Florent Revest
2020-12-09  8:29       ` Daniel Borkmann
2020-12-04 19:47 ` Martin KaFai Lau
2020-12-08 19:40   ` Florent Revest [this message]

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=afd9317561b1823da2fa473f29723da83247767e.camel@chromium.org \
    --to=revest@chromium.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=revest@google.com \
    --subject='Re: [PATCH bpf-next v2 1/3] bpf: Expose bpf_get_socket_cookie to tracing programs' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).