Lines Matching refs:test
54 typedef int (*load_fn)(const struct sock_addr_test *test);
84 static int bind4_prog_load(const struct sock_addr_test *test);
85 static int bind6_prog_load(const struct sock_addr_test *test);
86 static int connect4_prog_load(const struct sock_addr_test *test);
87 static int connect6_prog_load(const struct sock_addr_test *test);
88 static int sendmsg_deny_prog_load(const struct sock_addr_test *test);
89 static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test);
90 static int sendmsg4_rw_c_prog_load(const struct sock_addr_test *test);
91 static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test);
92 static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test);
93 static int sendmsg6_rw_v4mapped_prog_load(const struct sock_addr_test *test);
519 static int load_insns(const struct sock_addr_test *test, in load_insns() argument
527 load_attr.expected_attach_type = test->expected_attach_type; in load_insns()
533 if (ret < 0 && test->expected_result != LOAD_REJECT) { in load_insns()
552 static int bind4_prog_load(const struct sock_addr_test *test) in bind4_prog_load() argument
618 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); in bind4_prog_load()
621 static int bind6_prog_load(const struct sock_addr_test *test) in bind6_prog_load() argument
684 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); in bind6_prog_load()
687 static int load_path(const struct sock_addr_test *test, const char *path) in load_path() argument
696 attr.expected_attach_type = test->expected_attach_type; in load_path()
699 if (test->expected_result != LOAD_REJECT) in load_path()
707 static int connect4_prog_load(const struct sock_addr_test *test) in connect4_prog_load() argument
709 return load_path(test, CONNECT4_PROG_PATH); in connect4_prog_load()
712 static int connect6_prog_load(const struct sock_addr_test *test) in connect6_prog_load() argument
714 return load_path(test, CONNECT6_PROG_PATH); in connect6_prog_load()
717 static int sendmsg_deny_prog_load(const struct sock_addr_test *test) in sendmsg_deny_prog_load() argument
724 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); in sendmsg_deny_prog_load()
727 static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test) in sendmsg4_rw_asm_prog_load() argument
776 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); in sendmsg4_rw_asm_prog_load()
779 static int sendmsg4_rw_c_prog_load(const struct sock_addr_test *test) in sendmsg4_rw_c_prog_load() argument
781 return load_path(test, SENDMSG4_PROG_PATH); in sendmsg4_rw_c_prog_load()
784 static int sendmsg6_rw_dst_asm_prog_load(const struct sock_addr_test *test, in sendmsg6_rw_dst_asm_prog_load() argument
834 return load_insns(test, insns, sizeof(insns) / sizeof(struct bpf_insn)); in sendmsg6_rw_dst_asm_prog_load()
837 static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test) in sendmsg6_rw_asm_prog_load() argument
839 return sendmsg6_rw_dst_asm_prog_load(test, SERV6_REWRITE_IP); in sendmsg6_rw_asm_prog_load()
842 static int sendmsg6_rw_v4mapped_prog_load(const struct sock_addr_test *test) in sendmsg6_rw_v4mapped_prog_load() argument
844 return sendmsg6_rw_dst_asm_prog_load(test, SERV6_V4MAPPED_IP); in sendmsg6_rw_v4mapped_prog_load()
847 static int sendmsg6_rw_c_prog_load(const struct sock_addr_test *test) in sendmsg6_rw_c_prog_load() argument
849 return load_path(test, SENDMSG6_PROG_PATH); in sendmsg6_rw_c_prog_load()
1107 static int init_addrs(const struct sock_addr_test *test, in init_addrs() argument
1114 if (mk_sockaddr(test->domain, test->expected_ip, test->expected_port, in init_addrs()
1118 if (mk_sockaddr(test->domain, test->requested_ip, test->requested_port, in init_addrs()
1122 if (test->expected_src_ip && in init_addrs()
1123 mk_sockaddr(test->domain, test->expected_src_ip, 0, in init_addrs()
1132 static int run_bind_test_case(const struct sock_addr_test *test) in run_bind_test_case() argument
1141 if (init_addrs(test, &requested_addr, &expected_addr, NULL)) in run_bind_test_case()
1144 servfd = start_server(test->type, &requested_addr, addr_len); in run_bind_test_case()
1152 clientfd = connect_to_server(test->type, &expected_addr, addr_len); in run_bind_test_case()
1165 static int run_connect_test_case(const struct sock_addr_test *test) in run_connect_test_case() argument
1175 if (init_addrs(test, &requested_addr, &expected_addr, in run_connect_test_case()
1180 servfd = start_server(test->type, &expected_addr, addr_len); in run_connect_test_case()
1184 clientfd = connect_to_server(test->type, &requested_addr, addr_len); in run_connect_test_case()
1195 if (test->type == SOCK_STREAM) { in run_connect_test_case()
1218 static int run_sendmsg_test_case(const struct sock_addr_test *test) in run_sendmsg_test_case() argument
1230 if (test->type != SOCK_DGRAM) in run_sendmsg_test_case()
1233 if (init_addrs(test, &requested_addr, &expected_addr, in run_sendmsg_test_case()
1238 servfd = start_server(test->type, &expected_addr, addr_len); in run_sendmsg_test_case()
1246 clientfd = sendmsg_to_server(test->type, &requested_addr, in run_sendmsg_test_case()
1282 static int run_test_case(int cgfd, const struct sock_addr_test *test) in run_test_case() argument
1287 printf("Test case: %s .. ", test->descr); in run_test_case()
1289 progfd = test->loadfn(test); in run_test_case()
1290 if (test->expected_result == LOAD_REJECT && progfd < 0) in run_test_case()
1292 else if (test->expected_result == LOAD_REJECT || progfd < 0) in run_test_case()
1295 err = bpf_prog_attach(progfd, cgfd, test->attach_type, in run_test_case()
1297 if (test->expected_result == ATTACH_REJECT && err) { in run_test_case()
1300 } else if (test->expected_result == ATTACH_REJECT || err) { in run_test_case()
1304 switch (test->attach_type) { in run_test_case()
1307 err = run_bind_test_case(test); in run_test_case()
1311 err = run_connect_test_case(test); in run_test_case()
1315 err = run_sendmsg_test_case(test); in run_test_case()
1321 if (test->expected_result == SYSCALL_EPERM && err == EPERM) { in run_test_case()
1326 if (test->expected_result == SYSCALL_ENOTSUPP && err == ENOTSUPP) { in run_test_case()
1331 if (err || test->expected_result != SUCCESS) in run_test_case()
1340 bpf_prog_detach(cgfd, test->attach_type); in run_test_case()