Lines Matching refs:fd

51 	int fd;  in test_stream_connection_reset()  local
53 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_connection_reset()
57 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_connection_reset()
71 close(fd); in test_stream_connection_reset()
87 int fd; in test_stream_bind_only_client() local
92 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_client()
96 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_bind_only_client()
113 close(fd); in test_stream_bind_only_client()
118 int fd; in test_stream_bind_only_server() local
120 fd = vsock_bind(VMADDR_CID_ANY, opts->peer_port, SOCK_STREAM); in test_stream_bind_only_server()
128 close(fd); in test_stream_bind_only_server()
133 int fd; in test_stream_client_close_client() local
135 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_client_close_client()
136 if (fd < 0) { in test_stream_client_close_client()
141 send_byte(fd, 1, 0); in test_stream_client_close_client()
142 close(fd); in test_stream_client_close_client()
147 int fd; in test_stream_client_close_server() local
149 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_client_close_server()
150 if (fd < 0) { in test_stream_client_close_server()
158 vsock_wait_remote_close(fd); in test_stream_client_close_server()
160 send_byte(fd, -EPIPE, 0); in test_stream_client_close_server()
161 recv_byte(fd, 1, 0); in test_stream_client_close_server()
162 recv_byte(fd, 0, 0); in test_stream_client_close_server()
163 close(fd); in test_stream_client_close_server()
168 int fd; in test_stream_server_close_client() local
170 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_server_close_client()
171 if (fd < 0) { in test_stream_server_close_client()
179 vsock_wait_remote_close(fd); in test_stream_server_close_client()
181 send_byte(fd, -EPIPE, 0); in test_stream_server_close_client()
182 recv_byte(fd, 1, 0); in test_stream_server_close_client()
183 recv_byte(fd, 0, 0); in test_stream_server_close_client()
184 close(fd); in test_stream_server_close_client()
189 int fd; in test_stream_server_close_server() local
191 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_server_close_server()
192 if (fd < 0) { in test_stream_server_close_server()
197 send_byte(fd, 1, 0); in test_stream_server_close_server()
198 close(fd); in test_stream_server_close_server()
260 int fd; in test_msg_peek_client() local
264 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_msg_peek_client()
266 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_msg_peek_client()
268 if (fd < 0) { in test_msg_peek_client()
278 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_msg_peek_client()
280 close(fd); in test_msg_peek_client()
289 int fd; in test_msg_peek_server() local
292 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_msg_peek_server()
294 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_msg_peek_server()
296 if (fd < 0) { in test_msg_peek_server()
302 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK | MSG_DONTWAIT, in test_msg_peek_server()
308 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK, sizeof(buf_half)); in test_msg_peek_server()
311 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK, sizeof(buf_peek)); in test_msg_peek_server()
324 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK | MSG_TRUNC, in test_msg_peek_server()
328 recv_buf(fd, buf_normal, sizeof(buf_normal), 0, sizeof(buf_normal)); in test_msg_peek_server()
336 close(fd); in test_msg_peek_server()
358 int fd; in test_seqpacket_msg_bounds_client() local
360 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_msg_bounds_client()
361 if (fd < 0) { in test_seqpacket_msg_bounds_client()
402 send_buf(fd, buf, buf_size, flags, buf_size); in test_seqpacket_msg_bounds_client()
419 close(fd); in test_seqpacket_msg_bounds_client()
427 int fd; in test_seqpacket_msg_bounds_server() local
431 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_msg_bounds_server()
432 if (fd < 0) { in test_seqpacket_msg_bounds_server()
439 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_MAX_SIZE, in test_seqpacket_msg_bounds_server()
443 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_seqpacket_msg_bounds_server()
466 recv_size = recvmsg(fd, &msg, 0); in test_seqpacket_msg_bounds_server()
483 close(fd); in test_seqpacket_msg_bounds_server()
495 int fd; in test_seqpacket_msg_trunc_client() local
498 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_msg_trunc_client()
499 if (fd < 0) { in test_seqpacket_msg_trunc_client()
504 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_seqpacket_msg_trunc_client()
507 close(fd); in test_seqpacket_msg_trunc_client()
512 int fd; in test_seqpacket_msg_trunc_server() local
517 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_msg_trunc_server()
518 if (fd < 0) { in test_seqpacket_msg_trunc_server()
529 ssize_t ret = recvmsg(fd, &msg, MSG_TRUNC); in test_seqpacket_msg_trunc_server()
542 close(fd); in test_seqpacket_msg_trunc_server()
562 int fd; in test_seqpacket_timeout_client() local
568 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_timeout_client()
569 if (fd < 0) { in test_seqpacket_timeout_client()
577 setsockopt_timeval_check(fd, SOL_SOCKET, SO_RCVTIMEO, tv, in test_seqpacket_timeout_client()
582 if (read(fd, &dummy, sizeof(dummy)) != -1) { in test_seqpacket_timeout_client()
604 close(fd); in test_seqpacket_timeout_client()
609 int fd; in test_seqpacket_timeout_server() local
611 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_timeout_server()
612 if (fd < 0) { in test_seqpacket_timeout_server()
618 close(fd); in test_seqpacket_timeout_server()
627 int fd; in test_seqpacket_bigmsg_client() local
631 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_bigmsg_client()
632 if (fd < 0) { in test_seqpacket_bigmsg_client()
637 if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_seqpacket_bigmsg_client()
658 send_buf(fd, data, buf_size, 0, -EMSGSIZE); in test_seqpacket_bigmsg_client()
663 close(fd); in test_seqpacket_bigmsg_client()
668 int fd; in test_seqpacket_bigmsg_server() local
670 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_bigmsg_server()
671 if (fd < 0) { in test_seqpacket_bigmsg_server()
678 close(fd); in test_seqpacket_bigmsg_server()
686 int fd; in test_seqpacket_invalid_rec_buffer_client() local
691 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_invalid_rec_buffer_client()
692 if (fd < 0) { in test_seqpacket_invalid_rec_buffer_client()
712 send_buf(fd, buf1, buf_size, 0, buf_size); in test_seqpacket_invalid_rec_buffer_client()
714 send_buf(fd, buf2, buf_size, 0, buf_size); in test_seqpacket_invalid_rec_buffer_client()
716 close(fd); in test_seqpacket_invalid_rec_buffer_client()
721 int fd; in test_seqpacket_invalid_rec_buffer_server() local
731 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_invalid_rec_buffer_server()
732 if (fd < 0) { in test_seqpacket_invalid_rec_buffer_server()
757 res = read(fd, broken_buf, buf_size); in test_seqpacket_invalid_rec_buffer_server()
771 res = read(fd, valid_buf, buf_size); in test_seqpacket_invalid_rec_buffer_server()
797 close(fd); in test_seqpacket_invalid_rec_buffer_server()
804 int fd; in test_stream_poll_rcvlowat_server() local
807 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_poll_rcvlowat_server()
808 if (fd < 0) { in test_stream_poll_rcvlowat_server()
814 send_byte(fd, 1, 0); in test_stream_poll_rcvlowat_server()
822 send_byte(fd, 1, 0); in test_stream_poll_rcvlowat_server()
827 close(fd); in test_stream_poll_rcvlowat_server()
836 int fd; in test_stream_poll_rcvlowat_client() local
838 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_poll_rcvlowat_client()
839 if (fd < 0) { in test_stream_poll_rcvlowat_client()
844 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_poll_rcvlowat_client()
850 fds.fd = fd; in test_stream_poll_rcvlowat_client()
886 recv_buf(fd, buf, sizeof(buf), MSG_DONTWAIT, RCVLOWAT_BUF_SIZE); in test_stream_poll_rcvlowat_client()
890 close(fd); in test_stream_poll_rcvlowat_client()
899 int fd; in test_inv_buf_client() local
902 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_inv_buf_client()
904 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_inv_buf_client()
906 if (fd < 0) { in test_inv_buf_client()
914 recv_buf(fd, NULL, sizeof(data), 0, -EFAULT); in test_inv_buf_client()
924 recv_buf(fd, data, sizeof(data), MSG_DONTWAIT, expected_ret); in test_inv_buf_client()
928 close(fd); in test_inv_buf_client()
934 int fd; in test_inv_buf_server() local
937 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_inv_buf_server()
939 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_inv_buf_server()
941 if (fd < 0) { in test_inv_buf_server()
946 send_buf(fd, data, sizeof(data), 0, sizeof(data)); in test_inv_buf_server()
952 close(fd); in test_inv_buf_server()
980 int fd; in test_stream_virtio_skb_merge_client() local
982 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_virtio_skb_merge_client()
983 if (fd < 0) { in test_stream_virtio_skb_merge_client()
989 send_buf(fd, HELLO_STR, strlen(HELLO_STR), 0, strlen(HELLO_STR)); in test_stream_virtio_skb_merge_client()
996 send_buf(fd, WORLD_STR, strlen(WORLD_STR), 0, strlen(WORLD_STR)); in test_stream_virtio_skb_merge_client()
1002 close(fd); in test_stream_virtio_skb_merge_client()
1009 int fd; in test_stream_virtio_skb_merge_server() local
1011 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_virtio_skb_merge_server()
1012 if (fd < 0) { in test_stream_virtio_skb_merge_server()
1021 recv_buf(fd, buf + read, to_read, 0, to_read); in test_stream_virtio_skb_merge_server()
1029 recv_buf(fd, buf + read, to_read, 0, to_read); in test_stream_virtio_skb_merge_server()
1034 recv_buf(fd, buf + read, to_read, MSG_DONTWAIT, -EAGAIN); in test_stream_virtio_skb_merge_server()
1043 close(fd); in test_stream_virtio_skb_merge_server()
1065 static void test_stream_check_sigpipe(int fd) in test_stream_check_sigpipe() argument
1079 res = send(fd, "A", 1, 0); in test_stream_check_sigpipe()
1105 res = send(fd, "A", 1, MSG_NOSIGNAL); in test_stream_check_sigpipe()
1126 int fd; in test_stream_shutwr_client() local
1134 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_shutwr_client()
1135 if (fd < 0) { in test_stream_shutwr_client()
1140 if (shutdown(fd, SHUT_WR)) { in test_stream_shutwr_client()
1145 test_stream_check_sigpipe(fd); in test_stream_shutwr_client()
1149 close(fd); in test_stream_shutwr_client()
1154 int fd; in test_stream_shutwr_server() local
1156 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_shutwr_server()
1157 if (fd < 0) { in test_stream_shutwr_server()
1164 close(fd); in test_stream_shutwr_server()
1169 int fd; in test_stream_shutrd_client() local
1177 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_shutrd_client()
1178 if (fd < 0) { in test_stream_shutrd_client()
1185 test_stream_check_sigpipe(fd); in test_stream_shutrd_client()
1189 close(fd); in test_stream_shutrd_client()
1194 int fd; in test_stream_shutrd_server() local
1196 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_shutrd_server()
1197 if (fd < 0) { in test_stream_shutrd_server()
1202 if (shutdown(fd, SHUT_RD)) { in test_stream_shutrd_server()
1210 close(fd); in test_stream_shutrd_server()
1285 int fd; in test_unsent_bytes_client() local
1287 fd = vsock_connect(opts->peer_cid, opts->peer_port, type); in test_unsent_bytes_client()
1288 if (fd < 0) { in test_unsent_bytes_client()
1296 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_unsent_bytes_client()
1305 if (!vsock_wait_sent(fd)) in test_unsent_bytes_client()
1308 close(fd); in test_unsent_bytes_client()
1334 int fd; in test_unread_bytes_client() local
1336 fd = vsock_connect(opts->peer_cid, opts->peer_port, type); in test_unread_bytes_client()
1337 if (fd < 0) { in test_unread_bytes_client()
1346 if (!vsock_ioctl_int(fd, SIOCINQ, MSG_BUF_IOCTL_LEN)) { in test_unread_bytes_client()
1351 recv_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_unread_bytes_client()
1353 vsock_ioctl_int(fd, SIOCINQ, 0); in test_unread_bytes_client()
1356 close(fd); in test_unread_bytes_client()
1411 int fd; in test_stream_rcvlowat_def_cred_upd_client() local
1413 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_rcvlowat_def_cred_upd_client()
1414 if (fd < 0) { in test_stream_rcvlowat_def_cred_upd_client()
1429 recv_byte(fd, 1, 0); in test_stream_rcvlowat_def_cred_upd_client()
1431 if (send(fd, buf, buf_size, 0) != buf_size) { in test_stream_rcvlowat_def_cred_upd_client()
1437 close(fd); in test_stream_rcvlowat_def_cred_upd_client()
1448 int fd; in test_stream_credit_update_test() local
1450 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_credit_update_test()
1451 if (fd < 0) { in test_stream_credit_update_test()
1461 setsockopt_ull_check(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_stream_credit_update_test()
1472 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_credit_update_test()
1482 send_byte(fd, 1, 0); in test_stream_credit_update_test()
1494 res = recv(fd, buf, buf_size, MSG_PEEK); in test_stream_credit_update_test()
1509 recv_buf(fd, buf, recv_buf_size, 0, recv_buf_size); in test_stream_credit_update_test()
1515 setsockopt_int_check(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_credit_update_test()
1519 fds.fd = fd; in test_stream_credit_update_test()
1537 recv_buf(fd, buf, recv_buf_size, MSG_DONTWAIT, recv_buf_size); in test_stream_credit_update_test()
1547 close(fd); in test_stream_credit_update_test()
1577 int fd; in test_stream_leak_acceptq_client() local
1583 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_leak_acceptq_client()
1584 if (fd >= 0) in test_stream_leak_acceptq_client()
1585 close(fd); in test_stream_leak_acceptq_client()
1594 int fd; in test_stream_leak_acceptq_server() local
1597 fd = vsock_stream_listen(VMADDR_CID_ANY, opts->peer_port); in test_stream_leak_acceptq_server()
1599 close(fd); in test_stream_leak_acceptq_server()
1607 int fd; in test_stream_msgzcopy_leak_errq_client() local
1609 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_msgzcopy_leak_errq_client()
1610 if (fd < 0) { in test_stream_msgzcopy_leak_errq_client()
1615 enable_so_zerocopy_check(fd); in test_stream_msgzcopy_leak_errq_client()
1616 send_byte(fd, 1, MSG_ZEROCOPY); in test_stream_msgzcopy_leak_errq_client()
1618 fds.fd = fd; in test_stream_msgzcopy_leak_errq_client()
1625 close(fd); in test_stream_msgzcopy_leak_errq_client()
1630 int fd; in test_stream_msgzcopy_leak_errq_server() local
1632 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_msgzcopy_leak_errq_server()
1633 if (fd < 0) { in test_stream_msgzcopy_leak_errq_server()
1638 recv_byte(fd, 1, 0); in test_stream_msgzcopy_leak_errq_server()
1639 vsock_wait_remote_close(fd); in test_stream_msgzcopy_leak_errq_server()
1640 close(fd); in test_stream_msgzcopy_leak_errq_server()
1719 int fd, res; in test_stream_msgzcopy_leak_zcskb_client() local
1735 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_msgzcopy_leak_zcskb_client()
1736 if (fd < 0) { in test_stream_msgzcopy_leak_zcskb_client()
1741 enable_so_zerocopy_check(fd); in test_stream_msgzcopy_leak_zcskb_client()
1766 res = sendmsg(fd, &msg, MSG_ZEROCOPY); in test_stream_msgzcopy_leak_zcskb_client()
1773 close(fd); in test_stream_msgzcopy_leak_zcskb_client()
1778 int fd; in test_stream_msgzcopy_leak_zcskb_server() local
1780 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_msgzcopy_leak_zcskb_server()
1781 if (fd < 0) { in test_stream_msgzcopy_leak_zcskb_server()
1786 vsock_wait_remote_close(fd); in test_stream_msgzcopy_leak_zcskb_server()
1787 close(fd); in test_stream_msgzcopy_leak_zcskb_server()
1797 int fd, i, c; in test_stream_transport_uaf() local
1804 fd = vsock_bind_try(cid, VMADDR_PORT_ANY, SOCK_STREAM); in test_stream_transport_uaf()
1805 if (fd < 0) { in test_stream_transport_uaf()
1815 if (getsockname(fd, (struct sockaddr *)&addr, &alen)) { in test_stream_transport_uaf()
1824 close(fd); in test_stream_transport_uaf()
1831 fd = socket(AF_VSOCK, SOCK_STREAM | SOCK_NONBLOCK, 0); in test_stream_transport_uaf()
1832 if (fd < 0) { in test_stream_transport_uaf()
1845 if (!connect(fd, (struct sockaddr *)&addr, alen)) { in test_stream_transport_uaf()
1866 (void)connect(fd, (struct sockaddr *)&addr, alen); in test_stream_transport_uaf()
1872 close(fd); in test_stream_transport_uaf()
1901 int fd; in test_stream_connect_retry_client() local
1903 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_connect_retry_client()
1904 if (fd < 0) { in test_stream_connect_retry_client()
1909 if (!vsock_connect_fd(fd, opts->peer_cid, opts->peer_port)) { in test_stream_connect_retry_client()
1917 if (vsock_connect_fd(fd, opts->peer_cid, opts->peer_port)) { in test_stream_connect_retry_client()
1922 close(fd); in test_stream_connect_retry_client()
1927 int fd; in test_stream_connect_retry_server() local
1931 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_connect_retry_server()
1932 if (fd < 0) { in test_stream_connect_retry_server()
1937 vsock_wait_remote_close(fd); in test_stream_connect_retry_server()
1938 close(fd); in test_stream_connect_retry_server()
2117 int fd; in test_stream_linger_client() local
2119 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_linger_client()
2120 if (fd < 0) { in test_stream_linger_client()
2125 enable_so_linger(fd, 1); in test_stream_linger_client()
2126 close(fd); in test_stream_linger_client()
2131 int fd; in test_stream_linger_server() local
2133 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_linger_server()
2134 if (fd < 0) { in test_stream_linger_server()
2139 vsock_wait_remote_close(fd); in test_stream_linger_server()
2140 close(fd); in test_stream_linger_server()
2150 int fd; in test_stream_nolinger_client() local
2152 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_nolinger_client()
2153 if (fd < 0) { in test_stream_nolinger_client()
2158 enable_so_linger(fd, LINGER_TIMEOUT); in test_stream_nolinger_client()
2159 send_byte(fd, 1, 0); /* Left unread to expose incorrect behaviour. */ in test_stream_nolinger_client()
2160 waited = vsock_wait_sent(fd); in test_stream_nolinger_client()
2163 close(fd); in test_stream_nolinger_client()
2178 int fd; in test_stream_nolinger_server() local
2180 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_nolinger_server()
2181 if (fd < 0) { in test_stream_nolinger_server()
2187 close(fd); in test_stream_nolinger_server()