Lines Matching refs:cgroup_fd
15 static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func) in query_prog_cnt() argument
21 ASSERT_OK(bpf_prog_query_opts(cgroup_fd, BPF_LSM_CGROUP, &p), "prog_query"); in query_prog_cnt()
37 ASSERT_OK(bpf_prog_query_opts(cgroup_fd, BPF_LSM_CGROUP, &p), "prog_query"); in query_prog_cnt()
65 int cgroup_fd = -1, cgroup_fd2 = -1, cgroup_fd3 = -1; in test_lsm_cgroup_functional() local
87 cgroup_fd = test__join_cgroup("/sock_policy"); in test_lsm_cgroup_functional()
88 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup")) in test_lsm_cgroup_functional()
102 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count"); in test_lsm_cgroup_functional()
103 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count"); in test_lsm_cgroup_functional()
104 err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0); in test_lsm_cgroup_functional()
111 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count"); in test_lsm_cgroup_functional()
112 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 1, "total prog count"); in test_lsm_cgroup_functional()
114 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_inet_csk_clone"), 0, "prog count"); in test_lsm_cgroup_functional()
115 err = bpf_prog_attach(clone_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0); in test_lsm_cgroup_functional()
118 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_inet_csk_clone"), 1, "prog count"); in test_lsm_cgroup_functional()
119 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 2, "total prog count"); in test_lsm_cgroup_functional()
123 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_post_create"), 0, "prog count"); in test_lsm_cgroup_functional()
124 err = bpf_prog_attach(post_create_prog_fd, cgroup_fd, in test_lsm_cgroup_functional()
128 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_post_create"), 1, "prog count"); in test_lsm_cgroup_functional()
129 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 3, "total prog count"); in test_lsm_cgroup_functional()
132 err = bpf_prog_attach_opts(post_create_prog_fd2, cgroup_fd, in test_lsm_cgroup_functional()
136 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_post_create"), 1, "prog count"); in test_lsm_cgroup_functional()
137 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 3, "total prog count"); in test_lsm_cgroup_functional()
141 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_bind"), 0, "prog count"); in test_lsm_cgroup_functional()
142 bind_link_fd = bpf_link_create(bind_prog_fd, cgroup_fd, in test_lsm_cgroup_functional()
146 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_bind"), 1, "prog count"); in test_lsm_cgroup_functional()
147 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 4, "total prog count"); in test_lsm_cgroup_functional()
155 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_bind"), 1, "prog count"); in test_lsm_cgroup_functional()
156 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 4, "total prog count"); in test_lsm_cgroup_functional()
163 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_socket_bind"), 1, "prog count"); in test_lsm_cgroup_functional()
170 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 4, "total prog count"); in test_lsm_cgroup_functional()
287 ASSERT_GE(bpf_prog_detach2(post_create_prog_fd2, cgroup_fd, in test_lsm_cgroup_functional()
291 ASSERT_GE(bpf_prog_detach2(alloc_prog_fd, cgroup_fd, in test_lsm_cgroup_functional()
293 ASSERT_GE(bpf_prog_detach2(clone_prog_fd, cgroup_fd, in test_lsm_cgroup_functional()
297 close(cgroup_fd); in test_lsm_cgroup_functional()