/linux-6.6.21/tools/testing/selftests/bpf/prog_tests/ |
D | lsm_cgroup.c | 19 static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func) in query_prog_cnt() argument 25 ASSERT_OK(bpf_prog_query_opts(cgroup_fd, BPF_LSM_CGROUP, &p), "prog_query"); in query_prog_cnt() 41 ASSERT_OK(bpf_prog_query_opts(cgroup_fd, BPF_LSM_CGROUP, &p), "prog_query"); in query_prog_cnt() 69 int cgroup_fd = -1, cgroup_fd2 = -1, cgroup_fd3 = -1; in test_lsm_cgroup_functional() local 91 cgroup_fd = test__join_cgroup("/sock_policy"); in test_lsm_cgroup_functional() 92 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup")) in test_lsm_cgroup_functional() 106 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count"); in test_lsm_cgroup_functional() 107 ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count"); in test_lsm_cgroup_functional() 108 err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0); in test_lsm_cgroup_functional() 115 ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count"); in test_lsm_cgroup_functional() [all …]
|
D | cgroup_getset_retval.c | 19 static void test_setsockopt_set(int cgroup_fd, int sock_fd) in test_setsockopt_set() argument 34 cgroup_fd); in test_setsockopt_set() 55 static void test_setsockopt_set_and_get(int cgroup_fd, int sock_fd) in test_setsockopt_set_and_get() argument 70 cgroup_fd); in test_setsockopt_set_and_get() 74 cgroup_fd); in test_setsockopt_set_and_get() 98 static void test_setsockopt_default_zero(int cgroup_fd, int sock_fd) in test_setsockopt_default_zero() argument 113 cgroup_fd); in test_setsockopt_default_zero() 134 static void test_setsockopt_default_zero_and_set(int cgroup_fd, int sock_fd) in test_setsockopt_default_zero_and_set() argument 150 cgroup_fd); in test_setsockopt_default_zero_and_set() 154 cgroup_fd); in test_setsockopt_default_zero_and_set() [all …]
|
D | cgrp_local_storage.c | 22 static void test_tp_btf(int cgroup_fd) in test_tp_btf() argument 33 err = bpf_map_update_elem(bpf_map__fd(skel->maps.map_b), &cgroup_fd, &val1, BPF_ANY); in test_tp_btf() 38 err = bpf_map_lookup_elem(bpf_map__fd(skel->maps.map_b), &cgroup_fd, &val2); in test_tp_btf() 45 err = bpf_map_delete_elem(bpf_map__fd(skel->maps.map_b), &cgroup_fd); in test_tp_btf() 68 static void test_attach_cgroup(int cgroup_fd) in test_attach_cgroup() argument 82 skel->progs.set_cookie, cgroup_fd); in test_attach_cgroup() 87 skel->progs.update_cookie_sockops, cgroup_fd); in test_attach_cgroup() 105 &cgroup_fd, &val); in test_attach_cgroup() 124 static void test_recursion(int cgroup_fd) in test_recursion() argument 155 static void test_cgroup_iter_sleepable(int cgroup_fd, __u64 cgroup_id) in test_cgroup_iter_sleepable() argument [all …]
|
D | cgroup_v1v2.c | 10 static int run_test(int cgroup_fd, int server_fd, bool classid) in run_test() argument 24 cgroup_fd); in run_test() 48 int server_fd, client_fd, cgroup_fd; in test_cgroup_v1v2() local 64 cgroup_fd = test__join_cgroup("/connect_dropper"); in test_cgroup_v1v2() 65 if (!ASSERT_GE(cgroup_fd, 0, "cgroup_fd")) in test_cgroup_v1v2() 69 close(cgroup_fd); in test_cgroup_v1v2() 72 ASSERT_OK(run_test(cgroup_fd, server_fd, false), "cgroup-v2-only"); in test_cgroup_v1v2() 75 ASSERT_OK(run_test(cgroup_fd, server_fd, true), "cgroup-v1v2"); in test_cgroup_v1v2() 78 close(cgroup_fd); in test_cgroup_v1v2()
|
D | connect_force_port.c | 49 static int run_test(int cgroup_fd, int server_fd, int family, int type) in run_test() argument 78 err = bpf_prog_attach(bpf_program__fd(prog), cgroup_fd, v4 ? in run_test() 94 err = bpf_prog_attach(bpf_program__fd(prog), cgroup_fd, v4 ? in run_test() 110 err = bpf_prog_attach(bpf_program__fd(prog), cgroup_fd, v4 ? in run_test() 135 int server_fd, cgroup_fd; in test_connect_force_port() local 137 cgroup_fd = test__join_cgroup("/connect_force_port"); in test_connect_force_port() 138 if (CHECK_FAIL(cgroup_fd < 0)) in test_connect_force_port() 144 CHECK_FAIL(run_test(cgroup_fd, server_fd, AF_INET, SOCK_STREAM)); in test_connect_force_port() 150 CHECK_FAIL(run_test(cgroup_fd, server_fd, AF_INET6, SOCK_STREAM)); in test_connect_force_port() 156 CHECK_FAIL(run_test(cgroup_fd, server_fd, AF_INET, SOCK_DGRAM)); in test_connect_force_port() [all …]
|
D | connect_ping.c | 20 static void subtest(int cgroup_fd, struct connect_ping *skel, in subtest() argument 99 int cgroup_fd; in test_connect_ping() local 126 cgroup_fd = test__join_cgroup("/connect_ping"); in test_connect_ping() 127 if (!ASSERT_GE(cgroup_fd, 0, "cg-create")) in test_connect_ping() 134 bpf_program__attach_cgroup(skel->progs.connect_v4_prog, cgroup_fd); in test_connect_ping() 138 bpf_program__attach_cgroup(skel->progs.connect_v6_prog, cgroup_fd); in test_connect_ping() 147 subtest(cgroup_fd, skel, AF_INET, 0); in test_connect_ping() 154 subtest(cgroup_fd, skel, AF_INET, 1); in test_connect_ping() 161 subtest(cgroup_fd, skel, AF_INET6, 0); in test_connect_ping() 168 subtest(cgroup_fd, skel, AF_INET6, 1); in test_connect_ping() [all …]
|
D | mptcp.c | 156 static int run_test(int cgroup_fd, int server_fd, bool is_mptcp) in run_test() argument 171 err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0); in run_test() 194 int server_fd, cgroup_fd; in test_base() local 196 cgroup_fd = test__join_cgroup("/mptcp"); in test_base() 197 if (!ASSERT_GE(cgroup_fd, 0, "test__join_cgroup")) in test_base() 209 ASSERT_OK(run_test(cgroup_fd, server_fd, false), "run_test tcp"); in test_base() 219 ASSERT_OK(run_test(cgroup_fd, server_fd, true), "run_test mptcp"); in test_base() 225 close(cgroup_fd); in test_base() 267 static int run_mptcpify(int cgroup_fd) in run_mptcpify() argument 308 int cgroup_fd; in test_mptcpify() local [all …]
|
D | udp_limit.c | 12 int cgroup_fd; in test_udp_limit() local 14 cgroup_fd = test__join_cgroup("/udp_limit"); in test_udp_limit() 15 if (!ASSERT_GE(cgroup_fd, 0, "cg-join")) in test_udp_limit() 22 skel->links.sock = bpf_program__attach_cgroup(skel->progs.sock, cgroup_fd); in test_udp_limit() 25 skel->links.sock_release = bpf_program__attach_cgroup(skel->progs.sock_release, cgroup_fd); in test_udp_limit() 69 close(cgroup_fd); in test_udp_limit()
|
D | socket_cookie.c | 18 int server_fd = 0, client_fd = 0, cgroup_fd = 0, err = 0; in test_socket_cookie() local 29 cgroup_fd = test__join_cgroup("/socket_cookie"); in test_socket_cookie() 30 if (CHECK(cgroup_fd < 0, "join_cgroup", "cgroup creation failed\n")) in test_socket_cookie() 34 skel->progs.set_cookie, cgroup_fd); in test_socket_cookie() 39 skel->progs.update_cookie_sockops, cgroup_fd); in test_socket_cookie() 73 close(cgroup_fd); in test_socket_cookie()
|
D | tcp_rtt.c | 90 static int run_test(int cgroup_fd, int server_fd) in run_test() argument 105 err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0); in run_test() 148 int server_fd, cgroup_fd; in test_tcp_rtt() local 150 cgroup_fd = test__join_cgroup("/tcp_rtt"); in test_tcp_rtt() 151 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup /tcp_rtt")) in test_tcp_rtt() 158 ASSERT_OK(run_test(cgroup_fd, server_fd), "run_test"); in test_tcp_rtt() 163 close(cgroup_fd); in test_tcp_rtt()
|
D | bind_perm.c | 57 int cgroup_fd; in test_bind_perm() local 62 cgroup_fd = test__join_cgroup("/bind_perm"); in test_bind_perm() 63 if (CHECK(cgroup_fd < 0, "cg-join", "errno %d", errno)) in test_bind_perm() 70 skel->links.bind_v4_prog = bpf_program__attach_cgroup(skel->progs.bind_v4_prog, cgroup_fd); in test_bind_perm() 74 skel->links.bind_v6_prog = bpf_program__attach_cgroup(skel->progs.bind_v6_prog, cgroup_fd); in test_bind_perm() 94 close(cgroup_fd); in test_bind_perm()
|
D | netns_cookie.c | 15 int server_fd = -1, client_fd = -1, cgroup_fd = -1; in test_netns_cookie() local 26 cgroup_fd = test__join_cgroup("/netns_cookie"); in test_netns_cookie() 27 if (CHECK(cgroup_fd < 0, "join_cgroup", "cgroup creation failed\n")) in test_netns_cookie() 31 skel->progs.get_netns_cookie_sockops, cgroup_fd); in test_netns_cookie() 77 if (cgroup_fd != -1) in test_netns_cookie() 78 close(cgroup_fd); in test_netns_cookie()
|
D | load_bytes_relative.c | 12 int server_fd, cgroup_fd, prog_fd, map_fd, client_fd; in test_load_bytes_relative() local 22 cgroup_fd = test__join_cgroup("/load_bytes_relative"); in test_load_bytes_relative() 23 if (CHECK_FAIL(cgroup_fd < 0)) in test_load_bytes_relative() 47 err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_INET_EGRESS, in test_load_bytes_relative() 70 close(cgroup_fd); in test_load_bytes_relative()
|
D | sockopt_inherit.c | 137 static void run_test(int cgroup_fd) in run_test() argument 154 cgroup_fd); in run_test() 159 cgroup_fd); in run_test() 202 int cgroup_fd; in test_sockopt_inherit() local 204 cgroup_fd = test__join_cgroup("/sockopt_inherit"); in test_sockopt_inherit() 205 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup")) in test_sockopt_inherit() 208 run_test(cgroup_fd); in test_sockopt_inherit() 209 close(cgroup_fd); in test_sockopt_inherit()
|
D | cgroup_tcp_skb.c | 16 static int install_filters(int cgroup_fd, in install_filters() argument 28 cgroup_fd); in install_filters() 33 cgroup_fd); in install_filters() 242 int cgroup_fd = -1; in test_cgroup_tcp_skb() local 253 cgroup_fd = create_and_get_cgroup(CGROUP_TCP_SKB_PATH); in test_cgroup_tcp_skb() 254 if (!ASSERT_GE(cgroup_fd, 0, "cgroup_fd")) in test_cgroup_tcp_skb() 258 err = install_filters(cgroup_fd, &egress_link, &ingress_link, in test_cgroup_tcp_skb() 279 err = install_filters(cgroup_fd, &egress_link, &ingress_link, in test_cgroup_tcp_skb() 298 err = install_filters(cgroup_fd, &egress_link, &ingress_link, in test_cgroup_tcp_skb() 317 err = install_filters(cgroup_fd, &egress_link, &ingress_link, in test_cgroup_tcp_skb() [all …]
|
D | sockopt_sk.c | 223 static void run_test(int cgroup_fd) in run_test() argument 234 bpf_program__attach_cgroup(skel->progs._setsockopt, cgroup_fd); in run_test() 239 bpf_program__attach_cgroup(skel->progs._getsockopt, cgroup_fd); in run_test() 251 int cgroup_fd; in test_sockopt_sk() local 253 cgroup_fd = test__join_cgroup("/sockopt_sk"); in test_sockopt_sk() 254 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup /sockopt_sk")) in test_sockopt_sk() 257 run_test(cgroup_fd); in test_sockopt_sk() 258 close(cgroup_fd); in test_sockopt_sk()
|
D | test_ldsx_insn.c | 49 int err, fd, cgroup_fd; in test_ctx_member_sign_ext() local 53 cgroup_fd = test__join_cgroup("/ldsx_test"); in test_ctx_member_sign_ext() 54 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup /ldsx_test")) in test_ctx_member_sign_ext() 73 bpf_program__attach_cgroup(skel->progs._getsockopt, cgroup_fd); in test_ctx_member_sign_ext() 91 close(cgroup_fd); in test_ctx_member_sign_ext()
|
D | sock_destroy.c | 181 int cgroup_fd; in test_sock_destroy() local 187 cgroup_fd = test__join_cgroup("/sock_destroy"); in test_sock_destroy() 188 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup")) in test_sock_destroy() 192 skel->progs.sock_connect, cgroup_fd); in test_sock_destroy() 218 if (cgroup_fd >= 0) in test_sock_destroy() 219 close(cgroup_fd); in test_sock_destroy()
|
D | rcu_read_lock.c | 131 int cgroup_fd; in test_rcu_read_lock() local 133 cgroup_fd = test__join_cgroup("/rcu_read_lock"); in test_rcu_read_lock() 134 if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup /rcu_read_lock")) in test_rcu_read_lock() 146 close(cgroup_fd); in test_rcu_read_lock()
|
D | cgroup_iter.c | 50 static void read_from_cgroup_iter(struct bpf_program *prog, int cgroup_fd, in read_from_cgroup_iter() argument 62 linfo.cgroup.cgroup_fd = cgroup_fd; in read_from_cgroup_iter() 102 linfo.cgroup.cgroup_fd = (__u32)-1; in test_invalid_cgroup() 119 linfo.cgroup.cgroup_fd = (__u32)cg_fd[PARENT]; in test_invalid_cgroup_spec() 213 linfo.cgroup.cgroup_fd = cgrp_fd; in test_walk_dead_self_only()
|
/linux-6.6.21/tools/bpf/bpftool/ |
D | cgroup.c | 169 static int count_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type) in count_attached_bpf_progs() argument 174 ret = bpf_prog_query(cgroup_fd, type, query_flags, NULL, in count_attached_bpf_progs() 182 static int cgroup_has_attached_progs(int cgroup_fd) in cgroup_has_attached_progs() argument 188 int count = count_attached_bpf_progs(cgroup_fd, type); in cgroup_has_attached_progs() 202 static int show_effective_bpf_progs(int cgroup_fd, enum bpf_attach_type type, in show_effective_bpf_progs() argument 214 ret = bpf_prog_query_opts(cgroup_fd, type, &p); in show_effective_bpf_progs() 227 static int show_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type, in show_attached_bpf_progs() argument 243 ret = bpf_prog_query_opts(cgroup_fd, type, &p); in show_attached_bpf_progs() 277 static int show_bpf_progs(int cgroup_fd, enum bpf_attach_type type, in show_bpf_progs() argument 281 show_effective_bpf_progs(cgroup_fd, type, level) : in show_bpf_progs() [all …]
|
/linux-6.6.21/tools/testing/selftests/bpf/ |
D | test_dev_cgroup.c | 27 int prog_fd, cgroup_fd; in main() local 39 cgroup_fd = cgroup_setup_and_join(TEST_CGROUP); in main() 40 if (cgroup_fd < 0) { in main() 46 if (bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_DEVICE, 0)) { in main() 51 if (bpf_prog_query(cgroup_fd, BPF_CGROUP_DEVICE, 0, NULL, NULL, in main()
|
D | get_cgroup_id_user.c | 53 int cgroup_fd, cgidmap_fd, pidmap_fd; in main() local 65 cgroup_fd = cgroup_setup_and_join(TEST_CGROUP); in main() 66 if (CHECK(cgroup_fd < 0, "cgroup_setup_and_join", "err %d errno %d\n", cgroup_fd, errno)) in main()
|
D | test_cgroup_storage.c | 41 int map_fd, percpu_map_fd, prog_fd, cgroup_fd; in main() local 81 cgroup_fd = cgroup_setup_and_join(TEST_CGROUP); in main() 84 if (bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_INET_EGRESS, 0)) { in main()
|
/linux-6.6.21/tools/testing/selftests/cgroup/ |
D | cgroup_util.c | 348 pid_t clone_into_cgroup(int cgroup_fd) in clone_into_cgroup() argument 356 .cgroup = cgroup_fd, in clone_into_cgroup() 425 int cgroup_fd; in clone_into_cgroup_run_nowait() local 428 cgroup_fd = dirfd_open_opath(cgroup); in clone_into_cgroup_run_nowait() 429 if (cgroup_fd < 0) in clone_into_cgroup_run_nowait() 432 pid = clone_into_cgroup(cgroup_fd); in clone_into_cgroup_run_nowait() 433 close_prot_errno(cgroup_fd); in clone_into_cgroup_run_nowait() 584 int cgroup_fd; in clone_into_cgroup_run_wait() local 587 cgroup_fd = dirfd_open_opath(cgroup); in clone_into_cgroup_run_wait() 588 if (cgroup_fd < 0) in clone_into_cgroup_run_wait() [all …]
|