Lines Matching full:fd

44 	int fd;  in test_stream_connection_reset()  local
46 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_connection_reset()
50 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_connection_reset()
64 close(fd); in test_stream_connection_reset()
80 int fd; in test_stream_bind_only_client() local
85 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_client()
89 ret = connect(fd, &addr.sa, sizeof(addr.svm)); in test_stream_bind_only_client()
106 close(fd); in test_stream_bind_only_client()
121 int fd; in test_stream_bind_only_server() local
123 fd = socket(AF_VSOCK, SOCK_STREAM, 0); in test_stream_bind_only_server()
125 if (bind(fd, &addr.sa, sizeof(addr.svm)) < 0) { in test_stream_bind_only_server()
136 close(fd); in test_stream_bind_only_server()
141 int fd; in test_stream_client_close_client() local
143 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_client_close_client()
144 if (fd < 0) { in test_stream_client_close_client()
149 send_byte(fd, 1, 0); in test_stream_client_close_client()
150 close(fd); in test_stream_client_close_client()
155 int fd; in test_stream_client_close_server() local
157 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_client_close_server()
158 if (fd < 0) { in test_stream_client_close_server()
166 vsock_wait_remote_close(fd); in test_stream_client_close_server()
168 send_byte(fd, -EPIPE, 0); in test_stream_client_close_server()
169 recv_byte(fd, 1, 0); in test_stream_client_close_server()
170 recv_byte(fd, 0, 0); in test_stream_client_close_server()
171 close(fd); in test_stream_client_close_server()
176 int fd; in test_stream_server_close_client() local
178 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_server_close_client()
179 if (fd < 0) { in test_stream_server_close_client()
187 vsock_wait_remote_close(fd); in test_stream_server_close_client()
189 send_byte(fd, -EPIPE, 0); in test_stream_server_close_client()
190 recv_byte(fd, 1, 0); in test_stream_server_close_client()
191 recv_byte(fd, 0, 0); in test_stream_server_close_client()
192 close(fd); in test_stream_server_close_client()
197 int fd; in test_stream_server_close_server() local
199 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_server_close_server()
200 if (fd < 0) { in test_stream_server_close_server()
205 send_byte(fd, 1, 0); in test_stream_server_close_server()
206 close(fd); in test_stream_server_close_server()
268 int fd; in test_msg_peek_client() local
272 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_msg_peek_client()
274 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_msg_peek_client()
276 if (fd < 0) { in test_msg_peek_client()
286 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_msg_peek_client()
288 close(fd); in test_msg_peek_client()
297 int fd; in test_msg_peek_server() local
300 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_msg_peek_server()
302 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_msg_peek_server()
304 if (fd < 0) { in test_msg_peek_server()
310 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK | MSG_DONTWAIT, in test_msg_peek_server()
316 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK, sizeof(buf_half)); in test_msg_peek_server()
319 recv_buf(fd, buf_peek, sizeof(buf_peek), MSG_PEEK, sizeof(buf_peek)); in test_msg_peek_server()
332 recv_buf(fd, buf_half, sizeof(buf_half), MSG_PEEK | MSG_TRUNC, in test_msg_peek_server()
336 recv_buf(fd, buf_normal, sizeof(buf_normal), 0, sizeof(buf_normal)); in test_msg_peek_server()
344 close(fd); in test_msg_peek_server()
366 int fd; in test_seqpacket_msg_bounds_client() local
368 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_msg_bounds_client()
369 if (fd < 0) { in test_seqpacket_msg_bounds_client()
410 send_buf(fd, buf, buf_size, flags, buf_size); in test_seqpacket_msg_bounds_client()
427 close(fd); in test_seqpacket_msg_bounds_client()
435 int fd; in test_seqpacket_msg_bounds_server() local
439 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_msg_bounds_server()
440 if (fd < 0) { in test_seqpacket_msg_bounds_server()
447 if (setsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_MAX_SIZE, in test_seqpacket_msg_bounds_server()
453 if (setsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_seqpacket_msg_bounds_server()
478 recv_size = recvmsg(fd, &msg, 0); in test_seqpacket_msg_bounds_server()
495 close(fd); in test_seqpacket_msg_bounds_server()
507 int fd; in test_seqpacket_msg_trunc_client() local
510 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_msg_trunc_client()
511 if (fd < 0) { in test_seqpacket_msg_trunc_client()
516 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_seqpacket_msg_trunc_client()
519 close(fd); in test_seqpacket_msg_trunc_client()
524 int fd; in test_seqpacket_msg_trunc_server() local
529 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_msg_trunc_server()
530 if (fd < 0) { in test_seqpacket_msg_trunc_server()
541 ssize_t ret = recvmsg(fd, &msg, MSG_TRUNC); in test_seqpacket_msg_trunc_server()
554 close(fd); in test_seqpacket_msg_trunc_server()
574 int fd; in test_seqpacket_timeout_client() local
580 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_timeout_client()
581 if (fd < 0) { in test_seqpacket_timeout_client()
589 if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)) == -1) { in test_seqpacket_timeout_client()
596 if (read(fd, &dummy, sizeof(dummy)) != -1) { in test_seqpacket_timeout_client()
618 close(fd); in test_seqpacket_timeout_client()
623 int fd; in test_seqpacket_timeout_server() local
625 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_timeout_server()
626 if (fd < 0) { in test_seqpacket_timeout_server()
632 close(fd); in test_seqpacket_timeout_server()
640 int fd; in test_seqpacket_bigmsg_client() local
644 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_bigmsg_client()
645 if (fd < 0) { in test_seqpacket_bigmsg_client()
650 if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_seqpacket_bigmsg_client()
664 send_buf(fd, data, sock_buf_size, 0, -EMSGSIZE); in test_seqpacket_bigmsg_client()
669 close(fd); in test_seqpacket_bigmsg_client()
674 int fd; in test_seqpacket_bigmsg_server() local
676 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_bigmsg_server()
677 if (fd < 0) { in test_seqpacket_bigmsg_server()
684 close(fd); in test_seqpacket_bigmsg_server()
692 int fd; in test_seqpacket_invalid_rec_buffer_client() local
697 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_seqpacket_invalid_rec_buffer_client()
698 if (fd < 0) { in test_seqpacket_invalid_rec_buffer_client()
718 send_buf(fd, buf1, buf_size, 0, buf_size); in test_seqpacket_invalid_rec_buffer_client()
720 send_buf(fd, buf2, buf_size, 0, buf_size); in test_seqpacket_invalid_rec_buffer_client()
722 close(fd); in test_seqpacket_invalid_rec_buffer_client()
727 int fd; in test_seqpacket_invalid_rec_buffer_server() local
737 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_seqpacket_invalid_rec_buffer_server()
738 if (fd < 0) { in test_seqpacket_invalid_rec_buffer_server()
763 res = read(fd, broken_buf, buf_size); in test_seqpacket_invalid_rec_buffer_server()
777 res = read(fd, valid_buf, buf_size); in test_seqpacket_invalid_rec_buffer_server()
803 close(fd); in test_seqpacket_invalid_rec_buffer_server()
810 int fd; in test_stream_poll_rcvlowat_server() local
813 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_poll_rcvlowat_server()
814 if (fd < 0) { in test_stream_poll_rcvlowat_server()
820 send_byte(fd, 1, 0); in test_stream_poll_rcvlowat_server()
828 send_byte(fd, 1, 0); in test_stream_poll_rcvlowat_server()
833 close(fd); in test_stream_poll_rcvlowat_server()
842 int fd; in test_stream_poll_rcvlowat_client() local
844 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_poll_rcvlowat_client()
845 if (fd < 0) { in test_stream_poll_rcvlowat_client()
850 if (setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_poll_rcvlowat_client()
859 fds.fd = fd; in test_stream_poll_rcvlowat_client()
895 recv_buf(fd, buf, sizeof(buf), MSG_DONTWAIT, RCVLOWAT_BUF_SIZE); in test_stream_poll_rcvlowat_client()
899 close(fd); in test_stream_poll_rcvlowat_client()
908 int fd; in test_inv_buf_client() local
911 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_inv_buf_client()
913 fd = vsock_seqpacket_connect(opts->peer_cid, opts->peer_port); in test_inv_buf_client()
915 if (fd < 0) { in test_inv_buf_client()
923 recv_buf(fd, NULL, sizeof(data), 0, -EFAULT); in test_inv_buf_client()
933 recv_buf(fd, data, sizeof(data), MSG_DONTWAIT, expected_ret); in test_inv_buf_client()
937 close(fd); in test_inv_buf_client()
943 int fd; in test_inv_buf_server() local
946 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_inv_buf_server()
948 fd = vsock_seqpacket_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_inv_buf_server()
950 if (fd < 0) { in test_inv_buf_server()
955 send_buf(fd, data, sizeof(data), 0, sizeof(data)); in test_inv_buf_server()
961 close(fd); in test_inv_buf_server()
989 int fd; in test_stream_virtio_skb_merge_client() local
991 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_virtio_skb_merge_client()
992 if (fd < 0) { in test_stream_virtio_skb_merge_client()
998 send_buf(fd, HELLO_STR, strlen(HELLO_STR), 0, strlen(HELLO_STR)); in test_stream_virtio_skb_merge_client()
1005 send_buf(fd, WORLD_STR, strlen(WORLD_STR), 0, strlen(WORLD_STR)); in test_stream_virtio_skb_merge_client()
1011 close(fd); in test_stream_virtio_skb_merge_client()
1018 int fd; in test_stream_virtio_skb_merge_server() local
1020 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_virtio_skb_merge_server()
1021 if (fd < 0) { in test_stream_virtio_skb_merge_server()
1030 recv_buf(fd, buf + read, to_read, 0, to_read); in test_stream_virtio_skb_merge_server()
1038 recv_buf(fd, buf + read, to_read, 0, to_read); in test_stream_virtio_skb_merge_server()
1043 recv_buf(fd, buf + read, to_read, MSG_DONTWAIT, -EAGAIN); in test_stream_virtio_skb_merge_server()
1052 close(fd); in test_stream_virtio_skb_merge_server()
1072 static void test_stream_check_sigpipe(int fd) in test_stream_check_sigpipe() argument
1078 res = send(fd, "A", 1, 0); in test_stream_check_sigpipe()
1091 res = send(fd, "A", 1, MSG_NOSIGNAL); in test_stream_check_sigpipe()
1105 int fd; in test_stream_shutwr_client() local
1113 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_shutwr_client()
1114 if (fd < 0) { in test_stream_shutwr_client()
1119 if (shutdown(fd, SHUT_WR)) { in test_stream_shutwr_client()
1124 test_stream_check_sigpipe(fd); in test_stream_shutwr_client()
1128 close(fd); in test_stream_shutwr_client()
1133 int fd; in test_stream_shutwr_server() local
1135 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_shutwr_server()
1136 if (fd < 0) { in test_stream_shutwr_server()
1143 close(fd); in test_stream_shutwr_server()
1148 int fd; in test_stream_shutrd_client() local
1156 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_shutrd_client()
1157 if (fd < 0) { in test_stream_shutrd_client()
1164 test_stream_check_sigpipe(fd); in test_stream_shutrd_client()
1168 close(fd); in test_stream_shutrd_client()
1173 int fd; in test_stream_shutrd_server() local
1175 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_shutrd_server()
1176 if (fd < 0) { in test_stream_shutrd_server()
1181 if (shutdown(fd, SHUT_RD)) { in test_stream_shutrd_server()
1189 close(fd); in test_stream_shutrd_server()
1264 int ret, fd, sock_bytes_unsent; in test_unsent_bytes_client() local
1266 fd = vsock_connect(opts->peer_cid, opts->peer_port, type); in test_unsent_bytes_client()
1267 if (fd < 0) { in test_unsent_bytes_client()
1275 send_buf(fd, buf, sizeof(buf), 0, sizeof(buf)); in test_unsent_bytes_client()
1278 ret = ioctl(fd, SIOCOUTQ, &sock_bytes_unsent); in test_unsent_bytes_client()
1293 close(fd); in test_unsent_bytes_client()
1328 int fd; in test_stream_rcvlowat_def_cred_upd_client() local
1330 fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); in test_stream_rcvlowat_def_cred_upd_client()
1331 if (fd < 0) { in test_stream_rcvlowat_def_cred_upd_client()
1346 recv_byte(fd, 1, 0); in test_stream_rcvlowat_def_cred_upd_client()
1348 if (send(fd, buf, buf_size, 0) != buf_size) { in test_stream_rcvlowat_def_cred_upd_client()
1354 close(fd); in test_stream_rcvlowat_def_cred_upd_client()
1364 int fd; in test_stream_credit_update_test() local
1366 fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); in test_stream_credit_update_test()
1367 if (fd < 0) { in test_stream_credit_update_test()
1374 if (setsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, in test_stream_credit_update_test()
1387 if (setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_credit_update_test()
1400 send_byte(fd, 1, 0); in test_stream_credit_update_test()
1412 res = recv(fd, buf, buf_size, MSG_PEEK); in test_stream_credit_update_test()
1427 recv_buf(fd, buf, recv_buf_size, 0, recv_buf_size); in test_stream_credit_update_test()
1433 if (setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, in test_stream_credit_update_test()
1440 fds.fd = fd; in test_stream_credit_update_test()
1458 recv_buf(fd, buf, recv_buf_size, MSG_DONTWAIT, recv_buf_size); in test_stream_credit_update_test()
1468 close(fd); in test_stream_credit_update_test()