public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* bpf_sk_cgroup_id is not available in tracepoints
@ 2023-08-01 21:59 Ivan Babrou
  2023-08-01 23:17 ` Martin KaFai Lau
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Babrou @ 2023-08-01 21:59 UTC (permalink / raw)
  To: bpf
  Cc: kernel-team, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Stanislav Fomichev, Martin KaFai Lau

Hello,

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).

I'm happy to send a patch if this makes sense.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bpf_sk_cgroup_id is not available in tracepoints
  2023-08-01 21:59 bpf_sk_cgroup_id is not available in tracepoints Ivan Babrou
@ 2023-08-01 23:17 ` Martin KaFai Lau
  0 siblings, 0 replies; 2+ messages in thread
From: Martin KaFai Lau @ 2023-08-01 23:17 UTC (permalink / raw)
  To: Ivan Babrou
  Cc: bpf, kernel-team, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Stanislav Fomichev, Martin KaFai Lau

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-01 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox