Skip to content

bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup/sk_msg programs

Yonghong Song bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup and sk_msg programskernel/bpf/cgroup.c net/core/filter.c+4 -04 replies
2/5selftests/bpf: Replace CHECK with ASSERT_* in ns_current_pid_tgid testtools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c+19 -170 replies
3/5selftests/bpf: Refactor out some functions in ns_current_pid_tgid testtools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c+41 -220 replies
4/5selftests/bpf: Add a cgroup prog bpf_get_ns_current_pid_tgid() testtools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c+61 -02 replies
5/5selftests/bpf: Add a sk_msg prog bpf_get_ns_current_pid_tgid() testtools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c+76 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/5] bpf: Allow helper bpf_get_ns_current_pid_tgid() in cgroup/sk_msg programs

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(-)
Signature · 1 line
2.43.0