]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
selftests/bpf: Add test for CGROUP_STORAGE map on multiple attaches
authorYiFei Zhu <zhuyifei@google.com>
Fri, 24 Jul 2020 04:47:41 +0000 (23:47 -0500)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 26 Jul 2020 03:16:35 +0000 (20:16 -0700)
commitd4a89c1eb81431479664029bcdec593dbf23385f
tree1e46a4faa110564e441aca6bc98a6ecb75125644
parent90065c0647efd6e2ec8983a702c4ba813af51b93
selftests/bpf: Add test for CGROUP_STORAGE map on multiple attaches

This test creates a parent cgroup, and a child of that cgroup.
It attaches a cgroup_skb/egress program that simply counts packets,
to a global variable (ARRAY map), and to a CGROUP_STORAGE map.
The program is first attached to the parent cgroup only, then to
parent and child.

The test cases sends a message within the child cgroup, and because
the program is inherited across parent / child cgroups, it will
trigger the egress program for both the parent and child, if they
exist. The program, when looking up a CGROUP_STORAGE map, uses the
cgroup and attach type of the attachment parameters; therefore,
both attaches uses different cgroup storages.

We assert that all packet counts returns what we expects.

Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/5a20206afa4606144691c7caa0d1b997cd60dec0.1595565795.git.zhuyifei@google.com
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/cg_storage_multi_egress_only.c [new file with mode: 0644]