public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Ivan Babrou <ivan@cloudflare.com>
Cc: bpf <bpf@vger.kernel.org>,
	kernel-team <kernel-team@cloudflare.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Stanislav Fomichev <sdf@google.com>,
	Martin KaFai Lau <kafai@fb.com>
Subject: Re: bpf_sk_cgroup_id is not available in tracepoints
Date: Tue, 1 Aug 2023 16:17:49 -0700	[thread overview]
Message-ID: <97511804-ea81-67aa-3120-92415b0be5df@linux.dev> (raw)
In-Reply-To: <CABWYdi1KERLa9dOK8mxxdNvT746R8adFHxuN53VMvWMS=yyq_w@mail.gmail.com>

On 8/1/23 2:59 PM, Ivan Babrou wrote:
> I noticed that bpf_sk_cgroup_id is not available in a tracepoint (it
> is only available in cgroup related skb filters), even though I can
> easily do what it does manually:
> 
> u64 cgroup_id = sk->sk_cgrp_data.cgroup->kn->id;
> 
> It seems to me that bpf_sk_cgroup_id and similar functions should be
> added to bpf_base_func_proto (unless there's a better place).

This will make it available to all tracing progs. How to ensure doing 
'sk->sk_cgrp_data.cgroup->kn->id' is safe in all traceable context? so please 
don't do that.

bpf will handle the exception when the bpf prog reads 'sk->...' (eg. in case sk 
is an invalid ptr), so please keep using it for tracing programs.


      reply	other threads:[~2023-08-01 23:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 21:59 bpf_sk_cgroup_id is not available in tracepoints Ivan Babrou
2023-08-01 23:17 ` Martin KaFai Lau [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=97511804-ea81-67aa-3120-92415b0be5df@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ivan@cloudflare.com \
    --cc=kafai@fb.com \
    --cc=kernel-team@cloudflare.com \
    --cc=sdf@google.com \
    /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
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