bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup/sk_msg programs
@ 2024-03-07 23:26 Yonghong Song
  2024-03-07 23:27 ` [PATCH bpf-next 1/5] bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup and sk_msg programs Yonghong Song
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Yonghong Song @ 2024-03-07 23:26 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	John Fastabend, kernel-team, Martin KaFai Lau, Yury Namgung

Currently bpf_get_current_pid_tgid() is allowed in tracing, cgroup
and sk_msg progs while bpf_get_ns_current_pid_tgid() is only allowed
in tracing progs.

We have an internal use case where for an application running
in a container (with pid namespace), user wants to get
the pid associated with the pid namespace in a cgroup bpf
program. Besides cgroup, the only prog type, supporting
bpf_get_current_pid_tgid() but not bpf_get_ns_current_pid_tgid(),
is sk_msg and this patch set added it as well.

Patch 1 added the kernel support and patches 2-5 added
the test for cgroup and sk_msg.

Yonghong Song (5):
  bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup and sk_msg
    programs
  selftests/bpf: Replace CHECK with ASSERT_* in ns_current_pid_tgid test
  selftests/bpf: Refactor out some functions in ns_current_pid_tgid test
  selftests/bpf: Add a cgroup prog bpf_get_ns_current_pid_tgid() test
  selftests/bpf: Add a sk_msg prog bpf_get_ns_current_pid_tgid() test

 kernel/bpf/cgroup.c                           |   2 +
 net/core/filter.c                             |   2 +
 .../bpf/prog_tests/ns_current_pid_tgid.c      | 195 +++++++++++++++---
 .../bpf/progs/test_ns_current_pid_tgid.c      |  31 ++-
 4 files changed, 196 insertions(+), 34 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2024-03-09 21:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07 23:26 [PATCH bpf-next 0/5] bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup/sk_msg programs Yonghong Song
2024-03-07 23:27 ` [PATCH bpf-next 1/5] bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup and sk_msg programs Yonghong Song
2024-03-09  1:06   ` Andrii Nakryiko
2024-03-09 18:39     ` Yonghong Song
2024-03-09 19:10       ` Alexei Starovoitov
2024-03-09 21:03         ` Yonghong Song
2024-03-07 23:27 ` [PATCH bpf-next 2/5] selftests/bpf: Replace CHECK with ASSERT_* in ns_current_pid_tgid test Yonghong Song
2024-03-07 23:27 ` [PATCH bpf-next 3/5] selftests/bpf: Refactor out some functions " Yonghong Song
2024-03-07 23:27 ` [PATCH bpf-next 4/5] selftests/bpf: Add a cgroup prog bpf_get_ns_current_pid_tgid() test Yonghong Song
2024-03-08 19:08   ` Martin KaFai Lau
2024-03-09  0:04     ` Yonghong Song
2024-03-07 23:27 ` [PATCH bpf-next 5/5] selftests/bpf: Add a sk_msg " Yonghong Song

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