summaryrefslogtreecommitdiff
path: root/samples/bpf/bpf_helpers.h
diff options
context:
space:
mode:
authorSargun Dhillon <sargun@sargun.me>2016-08-12 18:57:04 +0300
committerDavid S. Miller <davem@davemloft.net>2016-08-13 07:49:42 +0300
commit9e6e60ecbd7323d4ac3f98dcdc1bd2c527a736ef (patch)
tree249b8cc8c37b46570ca05305aaa0c5ab79c28cee /samples/bpf/bpf_helpers.h
parent60d20f9195b260bdf0ac10c275ae9f6016f9c069 (diff)
downloadlinux-9e6e60ecbd7323d4ac3f98dcdc1bd2c527a736ef.tar.xz
samples/bpf: Add test_current_task_under_cgroup test
This test has a BPF program which writes the last known pid to call the sync syscall within a given cgroup to a map. The user mode program creates its own mount namespace, and mounts the cgroupsv2 hierarchy in there, as on all current test systems (Ubuntu 16.04, Debian), the cgroupsv2 vfs is unmounted by default. Once it does this, it proceeds to test. The test checks for positive and negative condition. It ensures that when it's part of a given cgroup, its pid is captured in the map, and that when it leaves the cgroup, this doesn't happen. It populate a cgroups arraymap prior to execution in userspace. This means that the program must be run in the same cgroups namespace as the programs that are being traced. Signed-off-by: Sargun Dhillon <sargun@sargun.me> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Tejun Heo <tj@kernel.org> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/bpf_helpers.h')
-rw-r--r--samples/bpf/bpf_helpers.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index cbc52df165b4..5e4c41e256b8 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -45,6 +45,8 @@ static int (*bpf_get_stackid)(void *ctx, void *map, int flags) =
(void *) BPF_FUNC_get_stackid;
static int (*bpf_probe_write_user)(void *dst, void *src, int size) =
(void *) BPF_FUNC_probe_write_user;
+static int (*bpf_current_task_under_cgroup)(void *map, int index) =
+ (void *) BPF_FUNC_current_task_under_cgroup;
/* llvm builtin functions that eBPF C program may use to
* emit BPF_LD_ABS and BPF_LD_IND instructions