summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/cgroup_helpers.c
diff options
context:
space:
mode:
authorKui-Feng Lee <thinker.li@gmail.com>2023-06-23 18:46:00 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2023-06-30 16:09:27 +0200
commit539c7e67aa4a170eea9a401464ec72a18a795a30 (patch)
tree495adb20014b9ddafef1f27fe5029d614e035ac9 /tools/testing/selftests/bpf/cgroup_helpers.c
parent223f5f79f2ce8facd9d77dd44e9f403343630bfc (diff)
downloadlinux-539c7e67aa4a170eea9a401464ec72a18a795a30.tar.gz
linux-539c7e67aa4a170eea9a401464ec72a18a795a30.tar.bz2
linux-539c7e67aa4a170eea9a401464ec72a18a795a30.zip
selftests/bpf: Verify that the cgroup_skb filters receive expected packets.
This test case includes four scenarios: 1. Connect to the server from outside the cgroup and close the connection from outside the cgroup. 2. Connect to the server from outside the cgroup and close the connection from inside the cgroup. 3. Connect to the server from inside the cgroup and close the connection from outside the cgroup. 4. Connect to the server from inside the cgroup and close the connection from inside the cgroup. The test case is to verify that cgroup_skb/{egress, ingress} filters receive expected packets including SYN, SYN/ACK, ACK, FIN, and FIN/ACK. Signed-off-by: Kui-Feng Lee <kuifeng@meta.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20230624014600.576756-3-kuifeng@meta.com
Diffstat (limited to 'tools/testing/selftests/bpf/cgroup_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/cgroup_helpers.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
index 9e95b37a7dff..2caee8423ee0 100644
--- a/tools/testing/selftests/bpf/cgroup_helpers.c
+++ b/tools/testing/selftests/bpf/cgroup_helpers.c
@@ -278,6 +278,18 @@ int join_cgroup(const char *relative_path)
}
/**
+ * join_root_cgroup() - Join the root cgroup
+ *
+ * This function joins the root cgroup.
+ *
+ * On success, it returns 0, otherwise on failure it returns 1.
+ */
+int join_root_cgroup(void)
+{
+ return join_cgroup_from_top(CGROUP_MOUNT_PATH);
+}
+
+/**
* join_parent_cgroup() - Join a cgroup in the parent process workdir
* @relative_path: The cgroup path, relative to parent process workdir, to join
*