[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190226223651.3166820-1-javierhonduco@fb.com>
Date: Tue, 26 Feb 2019 14:36:48 -0800
From: Javier Honduvilla Coto <javierhonduco@...com>
To: <netdev@...r.kernel.org>
CC: <yhs@...com>, <kernel-team@...com>
Subject: [PATCH bpf-next 0/3] bpf: add progenyof helper
Hi all,
This patch add the bpf_progenyof helper which receives a PID and returns
1 if the process currently being executed is in the process hierarchy,
including itself or 0 if not.
This is very useful in tracing programs when we want to filter by a
given PID and all the children it might have. The current workarounds
most people implement for this purpose have issues:
- Attaching to process spawning syscalls and dynamically add those PIDs
to some bpf map that would be used to filter is cumbersome and
potentially racy.
- Unrolling some loop to perform what this helper is doing consumes lots
of instructions. That and the impossibility to jump backwards makes it
really hard to be correct in really large process chains.
Let me know what do you think!
Thanks,
Javier Honduvilla Coto (3):
bpf: add bpf_progenyof helper
bpf: sync kernel uapi headers
bpf: add tests for bpf_progenyof
include/linux/bpf.h | 1 +
include/uapi/linux/bpf.h | 3 +-
kernel/bpf/core.c | 1 +
kernel/bpf/helpers.c | 29 ++
kernel/trace/bpf_trace.c | 2 +
tools/include/uapi/linux/bpf.h | 11 +-
tools/testing/selftests/bpf/.gitignore | 1 +
tools/testing/selftests/bpf/Makefile | 2 +-
tools/testing/selftests/bpf/bpf_helpers.h | 1 +
.../selftests/bpf/progs/test_progenyof_kern.c | 46 ++++
.../selftests/bpf/test_progenyof_user.c | 249 ++++++++++++++++++
11 files changed, 343 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/test_progenyof_kern.c
create mode 100644 tools/testing/selftests/bpf/test_progenyof_user.c
--
2.17.1
Powered by blists - more mailing lists