Lines Matching full:transport

5  * Client-side transport implementation for sockets.
16 * IP socket transport implementation, (C) 2005 Chuck Lever <cel@netapp.com>
65 static void xs_reset_srcport(struct sock_xprt *transport);
66 static void xs_set_srcport(struct sock_xprt *transport, struct socket *sock);
181 * transport connection with the server. Some servers like to drop a TCP
188 * TCP idle timeout; client drops the transport socket if it is idle
528 xs_read_header(struct sock_xprt *transport, struct xdr_buf *buf) in xs_read_header() argument
530 if (!transport->recv.copied) { in xs_read_header()
531 if (buf->head[0].iov_len >= transport->recv.offset) in xs_read_header()
533 &transport->recv.xid, in xs_read_header()
534 transport->recv.offset); in xs_read_header()
535 transport->recv.copied = transport->recv.offset; in xs_read_header()
540 xs_read_stream_request_done(struct sock_xprt *transport) in xs_read_stream_request_done() argument
542 return transport->recv.fraghdr & cpu_to_be32(RPC_LAST_STREAM_FRAGMENT); in xs_read_stream_request_done()
546 xs_read_stream_check_eor(struct sock_xprt *transport, in xs_read_stream_check_eor() argument
549 if (xs_read_stream_request_done(transport)) in xs_read_stream_check_eor()
554 xs_read_stream_request(struct sock_xprt *transport, struct msghdr *msg, in xs_read_stream_request() argument
561 xs_read_header(transport, buf); in xs_read_stream_request()
563 want = transport->recv.len - transport->recv.offset; in xs_read_stream_request()
565 ret = xs_read_xdr_buf(transport->sock, msg, flags, buf, in xs_read_stream_request()
566 transport->recv.copied + want, in xs_read_stream_request()
567 transport->recv.copied, in xs_read_stream_request()
569 transport->recv.offset += read; in xs_read_stream_request()
570 transport->recv.copied += read; in xs_read_stream_request()
573 if (transport->recv.offset == transport->recv.len) in xs_read_stream_request()
574 xs_read_stream_check_eor(transport, msg); in xs_read_stream_request()
601 xs_read_stream_header(struct sock_xprt *transport, struct msghdr *msg, in xs_read_stream_header() argument
605 .iov_base = &transport->recv.fraghdr, in xs_read_stream_header()
608 return xs_read_kvec(transport->sock, msg, flags, &kvec, want, seek); in xs_read_stream_header()
613 xs_read_stream_call(struct sock_xprt *transport, struct msghdr *msg, int flags) in xs_read_stream_call() argument
615 struct rpc_xprt *xprt = &transport->xprt; in xs_read_stream_call()
619 /* Is this transport associated with the backchannel? */ in xs_read_stream_call()
624 req = xprt_lookup_bc_request(xprt, transport->recv.xid); in xs_read_stream_call()
629 if (transport->recv.copied && !req->rq_private_buf.len) in xs_read_stream_call()
632 ret = xs_read_stream_request(transport, msg, flags, req); in xs_read_stream_call()
634 xprt_complete_bc_request(req, transport->recv.copied); in xs_read_stream_call()
636 req->rq_private_buf.len = transport->recv.copied; in xs_read_stream_call()
642 xs_read_stream_call(struct sock_xprt *transport, struct msghdr *msg, int flags) in xs_read_stream_call() argument
649 xs_read_stream_reply(struct sock_xprt *transport, struct msghdr *msg, int flags) in xs_read_stream_reply() argument
651 struct rpc_xprt *xprt = &transport->xprt; in xs_read_stream_reply()
657 req = xprt_lookup_rqst(xprt, transport->recv.xid); in xs_read_stream_reply()
658 if (!req || (transport->recv.copied && !req->rq_private_buf.len)) { in xs_read_stream_reply()
665 ret = xs_read_stream_request(transport, msg, flags, req); in xs_read_stream_reply()
669 xprt_complete_rqst(req->rq_task, transport->recv.copied); in xs_read_stream_reply()
671 req->rq_private_buf.len = transport->recv.copied; in xs_read_stream_reply()
679 xs_read_stream(struct sock_xprt *transport, int flags) in xs_read_stream() argument
685 if (transport->recv.len == 0) { in xs_read_stream()
686 want = xs_read_stream_headersize(transport->recv.copied != 0); in xs_read_stream()
687 ret = xs_read_stream_header(transport, &msg, flags, want, in xs_read_stream()
688 transport->recv.offset); in xs_read_stream()
691 transport->recv.offset = ret; in xs_read_stream()
692 if (transport->recv.offset != want) in xs_read_stream()
693 return transport->recv.offset; in xs_read_stream()
694 transport->recv.len = be32_to_cpu(transport->recv.fraghdr) & in xs_read_stream()
696 transport->recv.offset -= sizeof(transport->recv.fraghdr); in xs_read_stream()
700 switch (be32_to_cpu(transport->recv.calldir)) { in xs_read_stream()
705 ret = xs_read_stream_call(transport, &msg, flags); in xs_read_stream()
708 ret = xs_read_stream_reply(transport, &msg, flags); in xs_read_stream()
711 transport->recv.calldir = cpu_to_be32(-1); in xs_read_stream()
712 transport->recv.copied = -1; in xs_read_stream()
717 if (transport->recv.offset < transport->recv.len) { in xs_read_stream()
721 ret = xs_read_discard(transport->sock, &msg, flags, in xs_read_stream()
722 transport->recv.len - transport->recv.offset); in xs_read_stream()
725 transport->recv.offset += ret; in xs_read_stream()
727 if (transport->recv.offset != transport->recv.len) in xs_read_stream()
730 if (xs_read_stream_request_done(transport)) { in xs_read_stream()
731 trace_xs_stream_read_request(transport); in xs_read_stream()
732 transport->recv.copied = 0; in xs_read_stream()
734 transport->recv.offset = 0; in xs_read_stream()
735 transport->recv.len = 0; in xs_read_stream()
741 static __poll_t xs_poll_socket(struct sock_xprt *transport) in xs_poll_socket() argument
743 return transport->sock->ops->poll(transport->file, transport->sock, in xs_poll_socket()
747 static bool xs_poll_socket_readable(struct sock_xprt *transport) in xs_poll_socket_readable() argument
749 __poll_t events = xs_poll_socket(transport); in xs_poll_socket_readable()
754 static void xs_poll_check_readable(struct sock_xprt *transport) in xs_poll_check_readable() argument
757 clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); in xs_poll_check_readable()
758 if (test_bit(XPRT_SOCK_IGNORE_RECV, &transport->sock_state)) in xs_poll_check_readable()
760 if (!xs_poll_socket_readable(transport)) in xs_poll_check_readable()
762 if (!test_and_set_bit(XPRT_SOCK_DATA_READY, &transport->sock_state)) in xs_poll_check_readable()
763 queue_work(xprtiod_workqueue, &transport->recv_worker); in xs_poll_check_readable()
766 static void xs_stream_data_receive(struct sock_xprt *transport) in xs_stream_data_receive() argument
771 mutex_lock(&transport->recv_mutex); in xs_stream_data_receive()
772 if (transport->sock == NULL) in xs_stream_data_receive()
775 ret = xs_read_stream(transport, MSG_DONTWAIT); in xs_stream_data_receive()
782 kernel_sock_shutdown(transport->sock, SHUT_RDWR); in xs_stream_data_receive()
784 xprt_wake_pending_tasks(&transport->xprt, -EACCES); in xs_stream_data_receive()
786 xs_poll_check_readable(transport); in xs_stream_data_receive()
788 mutex_unlock(&transport->recv_mutex); in xs_stream_data_receive()
789 trace_xs_stream_read_data(&transport->xprt, ret, read); in xs_stream_data_receive()
794 struct sock_xprt *transport = in xs_stream_data_receive_workfn() local
798 xs_stream_data_receive(transport); in xs_stream_data_receive_workfn()
803 xs_stream_reset_connect(struct sock_xprt *transport) in xs_stream_reset_connect() argument
805 transport->recv.offset = 0; in xs_stream_reset_connect()
806 transport->recv.len = 0; in xs_stream_reset_connect()
807 transport->recv.copied = 0; in xs_stream_reset_connect()
808 transport->xmit.offset = 0; in xs_stream_reset_connect()
812 xs_stream_start_connect(struct sock_xprt *transport) in xs_stream_start_connect() argument
814 transport->xprt.stat.connect_count++; in xs_stream_start_connect()
815 transport->xprt.stat.connect_start = jiffies; in xs_stream_start_connect()
823 * @transport: pointer to struct sock_xprt
826 static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport) in xs_nospace() argument
828 struct rpc_xprt *xprt = &transport->xprt; in xs_nospace()
829 struct sock *sk = transport->inet; in xs_nospace()
832 trace_rpc_socket_nospace(req, transport); in xs_nospace()
840 set_bit(XPRT_SOCK_NOSPACE, &transport->sock_state); in xs_nospace()
853 struct sock_xprt *transport = in xs_sock_nospace() local
855 struct sock *sk = transport->inet; in xs_sock_nospace()
860 ret = xs_nospace(req, transport); in xs_sock_nospace()
867 struct sock_xprt *transport = in xs_stream_nospace() local
869 struct sock *sk = transport->inet; in xs_stream_nospace()
876 ret = xs_nospace(req, transport); in xs_stream_nospace()
889 struct sock_xprt *transport = in xs_stream_abort_send_request() local
892 if (transport->xmit.offset != 0 && in xs_stream_abort_send_request()
902 xs_send_request_was_aborted(struct sock_xprt *transport, struct rpc_rqst *req) in xs_send_request_was_aborted() argument
904 return transport->xmit.offset != 0 && req->rq_bytes_sent == 0; in xs_send_request_was_aborted()
932 struct sock_xprt *transport = in xs_local_send_request() local
945 if (xs_send_request_was_aborted(transport, req)) { in xs_local_send_request()
953 vm_wait = sk_stream_is_writeable(transport->inet) ? true : false; in xs_local_send_request()
956 status = xprt_sock_sendmsg(transport->sock, &msg, xdr, in xs_local_send_request()
957 transport->xmit.offset, rm, &sent); in xs_local_send_request()
959 __func__, xdr->len - transport->xmit.offset, status); in xs_local_send_request()
962 transport->xmit.offset += sent; in xs_local_send_request()
963 req->rq_bytes_sent = transport->xmit.offset; in xs_local_send_request()
965 req->rq_xmit_bytes_sent += transport->xmit.offset; in xs_local_send_request()
966 transport->xmit.offset = 0; in xs_local_send_request()
1003 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_udp_send_request() local
1027 status = xprt_sock_sendmsg(transport->sock, &msg, xdr, 0, 0, &sent); in xs_udp_send_request()
1036 if (status == -EAGAIN && sock_writeable(transport->inet)) in xs_udp_send_request()
1089 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_send_request() local
1101 if (xs_send_request_was_aborted(transport, req)) { in xs_tcp_send_request()
1102 if (transport->sock != NULL) in xs_tcp_send_request()
1103 kernel_sock_shutdown(transport->sock, SHUT_RDWR); in xs_tcp_send_request()
1106 if (!transport->inet) in xs_tcp_send_request()
1113 if (test_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state)) in xs_tcp_send_request()
1114 xs_tcp_set_socket_timeouts(xprt, transport->sock); in xs_tcp_send_request()
1116 xs_set_srcport(transport, transport->sock); in xs_tcp_send_request()
1122 tcp_sock_set_cork(transport->inet, true); in xs_tcp_send_request()
1124 vm_wait = sk_stream_is_writeable(transport->inet) ? true : false; in xs_tcp_send_request()
1127 status = xprt_sock_sendmsg(transport->sock, &msg, xdr, in xs_tcp_send_request()
1128 transport->xmit.offset, rm, &sent); in xs_tcp_send_request()
1131 xdr->len - transport->xmit.offset, status); in xs_tcp_send_request()
1135 transport->xmit.offset += sent; in xs_tcp_send_request()
1136 req->rq_bytes_sent = transport->xmit.offset; in xs_tcp_send_request()
1138 req->rq_xmit_bytes_sent += transport->xmit.offset; in xs_tcp_send_request()
1139 transport->xmit.offset = 0; in xs_tcp_send_request()
1141 tcp_sock_set_cork(transport->inet, false); in xs_tcp_send_request()
1175 static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk) in xs_save_old_callbacks() argument
1177 transport->old_data_ready = sk->sk_data_ready; in xs_save_old_callbacks()
1178 transport->old_state_change = sk->sk_state_change; in xs_save_old_callbacks()
1179 transport->old_write_space = sk->sk_write_space; in xs_save_old_callbacks()
1180 transport->old_error_report = sk->sk_error_report; in xs_save_old_callbacks()
1183 static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk) in xs_restore_old_callbacks() argument
1185 sk->sk_data_ready = transport->old_data_ready; in xs_restore_old_callbacks()
1186 sk->sk_state_change = transport->old_state_change; in xs_restore_old_callbacks()
1187 sk->sk_write_space = transport->old_write_space; in xs_restore_old_callbacks()
1188 sk->sk_error_report = transport->old_error_report; in xs_restore_old_callbacks()
1193 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_sock_reset_state_flags() local
1195 transport->xprt_err = 0; in xs_sock_reset_state_flags()
1196 clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state); in xs_sock_reset_state_flags()
1197 clear_bit(XPRT_SOCK_WAKE_ERROR, &transport->sock_state); in xs_sock_reset_state_flags()
1198 clear_bit(XPRT_SOCK_WAKE_WRITE, &transport->sock_state); in xs_sock_reset_state_flags()
1199 clear_bit(XPRT_SOCK_WAKE_DISCONNECT, &transport->sock_state); in xs_sock_reset_state_flags()
1200 clear_bit(XPRT_SOCK_NOSPACE, &transport->sock_state); in xs_sock_reset_state_flags()
1201 clear_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state); in xs_sock_reset_state_flags()
1204 static void xs_run_error_worker(struct sock_xprt *transport, unsigned int nr) in xs_run_error_worker() argument
1206 set_bit(nr, &transport->sock_state); in xs_run_error_worker()
1207 queue_work(xprtiod_workqueue, &transport->error_worker); in xs_run_error_worker()
1229 struct sock_xprt *transport; in xs_error_report() local
1235 transport = container_of(xprt, struct sock_xprt, xprt); in xs_error_report()
1236 transport->xprt_err = -sk->sk_err; in xs_error_report()
1237 if (transport->xprt_err == 0) in xs_error_report()
1240 xprt, -transport->xprt_err); in xs_error_report()
1241 trace_rpc_socket_error(xprt, sk->sk_socket, transport->xprt_err); in xs_error_report()
1245 xs_run_error_worker(transport, XPRT_SOCK_WAKE_ERROR); in xs_error_report()
1248 static void xs_reset_transport(struct sock_xprt *transport) in xs_reset_transport() argument
1250 struct socket *sock = transport->sock; in xs_reset_transport()
1251 struct sock *sk = transport->inet; in xs_reset_transport()
1252 struct rpc_xprt *xprt = &transport->xprt; in xs_reset_transport()
1253 struct file *filp = transport->file; in xs_reset_transport()
1268 if (atomic_read(&transport->xprt.swapper)) in xs_reset_transport()
1275 mutex_lock(&transport->recv_mutex); in xs_reset_transport()
1277 transport->inet = NULL; in xs_reset_transport()
1278 transport->sock = NULL; in xs_reset_transport()
1279 transport->file = NULL; in xs_reset_transport()
1284 xs_restore_old_callbacks(transport, sk); in xs_reset_transport()
1288 xs_stream_reset_connect(transport); in xs_reset_transport()
1290 mutex_unlock(&transport->recv_mutex); in xs_reset_transport()
1300 * @xprt: transport
1310 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_close() local
1314 if (transport->sock) in xs_close()
1315 tls_handshake_close(transport->sock); in xs_close()
1316 xs_reset_transport(transport); in xs_close()
1322 dprintk("RPC: injecting transport disconnect on xprt=%p\n", in xs_inject_disconnect()
1334 * xs_destroy - prepare to shutdown a transport
1335 * @xprt: doomed transport
1340 struct sock_xprt *transport = container_of(xprt, in xs_destroy() local
1344 cancel_delayed_work_sync(&transport->connect_worker); in xs_destroy()
1346 cancel_work_sync(&transport->recv_worker); in xs_destroy()
1347 cancel_work_sync(&transport->error_worker); in xs_destroy()
1354 * @xprt: transport
1413 static void xs_udp_data_receive(struct sock_xprt *transport) in xs_udp_data_receive() argument
1419 mutex_lock(&transport->recv_mutex); in xs_udp_data_receive()
1420 sk = transport->inet; in xs_udp_data_receive()
1427 xs_udp_data_read_skb(&transport->xprt, sk, skb); in xs_udp_data_receive()
1431 xs_poll_check_readable(transport); in xs_udp_data_receive()
1433 mutex_unlock(&transport->recv_mutex); in xs_udp_data_receive()
1438 struct sock_xprt *transport = in xs_udp_data_receive_workfn() local
1442 xs_udp_data_receive(transport); in xs_udp_data_receive_workfn()
1459 struct sock_xprt *transport = container_of(xprt, in xs_data_ready() local
1464 transport->old_data_ready(sk); in xs_data_ready()
1466 if (test_bit(XPRT_SOCK_IGNORE_RECV, &transport->sock_state)) in xs_data_ready()
1474 if (!test_and_set_bit(XPRT_SOCK_DATA_READY, &transport->sock_state)) in xs_data_ready()
1475 queue_work(xprtiod_workqueue, &transport->recv_worker); in xs_data_ready()
1503 struct sock_xprt *transport; in xs_local_state_change() local
1507 transport = container_of(xprt, struct sock_xprt, xprt); in xs_local_state_change()
1511 xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT); in xs_local_state_change()
1523 struct sock_xprt *transport; in xs_tcp_state_change() local
1534 transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_state_change()
1540 clear_bit(XPRT_SOCK_CONNECTING, &transport->sock_state); in xs_tcp_state_change()
1546 xs_run_error_worker(transport, XPRT_SOCK_WAKE_PENDING); in xs_tcp_state_change()
1563 xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT); in xs_tcp_state_change()
1581 &transport->sock_state)) { in xs_tcp_state_change()
1582 xs_reset_srcport(transport); in xs_tcp_state_change()
1587 xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT); in xs_tcp_state_change()
1593 struct sock_xprt *transport; in xs_write_space() local
1602 transport = container_of(xprt, struct sock_xprt, xprt); in xs_write_space()
1603 if (!test_and_clear_bit(XPRT_SOCK_NOSPACE, &transport->sock_state)) in xs_write_space()
1605 xs_run_error_worker(transport, XPRT_SOCK_WAKE_WRITE); in xs_write_space()
1645 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_udp_do_set_buffer_size() local
1646 struct sock *sk = transport->inet; in xs_udp_do_set_buffer_size()
1648 if (transport->rcvsize) { in xs_udp_do_set_buffer_size()
1650 sk->sk_rcvbuf = transport->rcvsize * xprt->max_reqs * 2; in xs_udp_do_set_buffer_size()
1652 if (transport->sndsize) { in xs_udp_do_set_buffer_size()
1654 sk->sk_sndbuf = transport->sndsize * xprt->max_reqs * 2; in xs_udp_do_set_buffer_size()
1661 * @xprt: generic transport
1669 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_udp_set_buffer_size() local
1671 transport->sndsize = 0; in xs_udp_set_buffer_size()
1673 transport->sndsize = sndsize + 1024; in xs_udp_set_buffer_size()
1674 transport->rcvsize = 0; in xs_udp_set_buffer_size()
1676 transport->rcvsize = rcvsize + 1024; in xs_udp_set_buffer_size()
1682 * xs_udp_timer - called when a retransmit timeout occurs on a UDP transport
1683 * @xprt: controlling transport
1728 * @xprt: generic transport
1740 static void xs_reset_srcport(struct sock_xprt *transport) in xs_reset_srcport() argument
1742 transport->srcport = 0; in xs_reset_srcport()
1745 static void xs_set_srcport(struct sock_xprt *transport, struct socket *sock) in xs_set_srcport() argument
1747 if (transport->srcport == 0 && transport->xprt.reuseport) in xs_set_srcport()
1748 transport->srcport = xs_sock_getport(sock); in xs_set_srcport()
1751 static int xs_get_srcport(struct sock_xprt *transport) in xs_get_srcport() argument
1753 int port = transport->srcport; in xs_get_srcport()
1755 if (port == 0 && transport->xprt.resvport) in xs_get_srcport()
1790 static unsigned short xs_next_srcport(struct sock_xprt *transport, unsigned short port) in xs_next_srcport() argument
1792 if (transport->srcport != 0) in xs_next_srcport()
1793 transport->srcport = 0; in xs_next_srcport()
1794 if (!transport->xprt.resvport) in xs_next_srcport()
1800 static int xs_bind(struct sock_xprt *transport, struct socket *sock) in xs_bind() argument
1804 int port = xs_get_srcport(transport); in xs_bind()
1809 * transport->xprt.resvport == 0), don't bind. Let the local in xs_bind()
1819 * transport->xprt.resvport == 1) xs_get_srcport above will in xs_bind()
1825 memcpy(&myaddr, &transport->srcaddr, transport->xprt.addrlen); in xs_bind()
1829 transport->xprt.addrlen); in xs_bind()
1831 if (transport->xprt.reuseport) in xs_bind()
1832 transport->srcport = port; in xs_bind()
1836 port = xs_next_srcport(transport, port); in xs_bind()
1920 struct sock_xprt *transport, int family, int type, in xs_create_sock() argument
1929 dprintk("RPC: can't create %d transport socket (%d).\n", in xs_create_sock()
1938 err = xs_bind(transport, sock); in xs_create_sock()
1954 transport->file = filp; in xs_create_sock()
1964 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, in xs_local_finish_connecting() local
1967 if (!transport->inet) { in xs_local_finish_connecting()
1972 xs_save_old_callbacks(transport, sk); in xs_local_finish_connecting()
1984 transport->sock = sock; in xs_local_finish_connecting()
1985 transport->inet = sk; in xs_local_finish_connecting()
1990 xs_stream_start_connect(transport); in xs_local_finish_connecting()
1997 * @transport: socket transport to connect
1999 static int xs_local_setup_socket(struct sock_xprt *transport) in xs_local_setup_socket() argument
2001 struct rpc_xprt *xprt = &transport->xprt; in xs_local_setup_socket()
2010 "transport socket (%d).\n", -status); in xs_local_setup_socket()
2020 transport->file = filp; in xs_local_setup_socket()
2060 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_local_connect() local
2063 if (transport->file) in xs_local_connect()
2079 ret = xs_local_setup_socket(transport); in xs_local_connect()
2098 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, in xs_set_memalloc() local
2105 if (!transport->inet) in xs_set_memalloc()
2108 sk_set_memalloc(transport->inet); in xs_set_memalloc()
2112 * xs_enable_swap - Tag this transport as being used for swap.
2113 * @xprt: transport to tag
2115 * Take a reference to this transport on behalf of the rpc_clnt, and
2132 * xs_disable_swap - Untag this transport as being used for swap.
2133 * @xprt: transport to tag
2168 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_udp_finish_connecting() local
2170 if (!transport->inet) { in xs_udp_finish_connecting()
2175 xs_save_old_callbacks(transport, sk); in xs_udp_finish_connecting()
2185 transport->sock = sock; in xs_udp_finish_connecting()
2186 transport->inet = sk; in xs_udp_finish_connecting()
2199 struct sock_xprt *transport = in xs_udp_setup_socket() local
2201 struct rpc_xprt *xprt = &transport->xprt; in xs_udp_setup_socket()
2208 sock = xs_create_sock(xprt, transport, in xs_udp_setup_socket()
2225 xprt_unlock_connect(xprt, transport); in xs_udp_setup_socket()
2232 * @xprt: transport
2239 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_shutdown() local
2240 struct socket *sock = transport->sock; in xs_tcp_shutdown()
2241 int skst = transport->inet ? transport->inet->sk_state : TCP_CLOSE; in xs_tcp_shutdown()
2260 xs_reset_transport(transport); in xs_tcp_shutdown()
2267 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_set_socket_timeouts() local
2281 clear_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state); in xs_tcp_set_socket_timeouts()
2307 struct sock_xprt *transport = in xs_tcp_do_set_connect_timeout() local
2318 memcpy(&transport->tcp_timeout, &to, sizeof(transport->tcp_timeout)); in xs_tcp_do_set_connect_timeout()
2319 xprt->timeout = &transport->tcp_timeout; in xs_tcp_do_set_connect_timeout()
2327 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_set_connect_timeout() local
2334 set_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state); in xs_tcp_set_connect_timeout()
2340 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_finish_connecting() local
2342 if (!transport->inet) { in xs_tcp_finish_connecting()
2362 xs_save_old_callbacks(transport, sk); in xs_tcp_finish_connecting()
2377 transport->sock = sock; in xs_tcp_finish_connecting()
2378 transport->inet = sk; in xs_tcp_finish_connecting()
2388 xs_stream_start_connect(transport); in xs_tcp_finish_connecting()
2391 set_bit(XPRT_SOCK_CONNECTING, &transport->sock_state); in xs_tcp_finish_connecting()
2403 struct sock_xprt *transport = in xs_tcp_setup_socket() local
2405 struct socket *sock = transport->sock; in xs_tcp_setup_socket()
2406 struct rpc_xprt *xprt = &transport->xprt; in xs_tcp_setup_socket()
2416 &transport->sock_state) || in xs_tcp_setup_socket()
2418 xs_reset_transport(transport); in xs_tcp_setup_socket()
2419 sock = xs_create_sock(xprt, transport, xs_addr(xprt)->sa_family, in xs_tcp_setup_socket()
2442 set_bit(XPRT_SOCK_CONNECT_SENT, &transport->sock_state); in xs_tcp_setup_socket()
2450 transport->srcport = 0; in xs_tcp_setup_socket()
2487 xprt_unlock_connect(xprt, transport); in xs_tcp_setup_socket()
2760 * @xprt: pointer to transport structure
2774 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_connect() local
2777 WARN_ON_ONCE(!xprt_lock_connect(xprt, task, transport)); in xs_connect()
2779 if (transport->sock != NULL) { in xs_connect()
2789 transport->clnt = task->tk_client; in xs_connect()
2791 &transport->connect_worker, in xs_connect()
2795 static void xs_wake_disconnect(struct sock_xprt *transport) in xs_wake_disconnect() argument
2797 if (test_and_clear_bit(XPRT_SOCK_WAKE_DISCONNECT, &transport->sock_state)) in xs_wake_disconnect()
2798 xs_tcp_force_close(&transport->xprt); in xs_wake_disconnect()
2801 static void xs_wake_write(struct sock_xprt *transport) in xs_wake_write() argument
2803 if (test_and_clear_bit(XPRT_SOCK_WAKE_WRITE, &transport->sock_state)) in xs_wake_write()
2804 xprt_write_space(&transport->xprt); in xs_wake_write()
2807 static void xs_wake_error(struct sock_xprt *transport) in xs_wake_error() argument
2811 if (!test_and_clear_bit(XPRT_SOCK_WAKE_ERROR, &transport->sock_state)) in xs_wake_error()
2813 sockerr = xchg(&transport->xprt_err, 0); in xs_wake_error()
2815 xprt_wake_pending_tasks(&transport->xprt, sockerr); in xs_wake_error()
2816 xs_tcp_force_close(&transport->xprt); in xs_wake_error()
2820 static void xs_wake_pending(struct sock_xprt *transport) in xs_wake_pending() argument
2822 if (test_and_clear_bit(XPRT_SOCK_WAKE_PENDING, &transport->sock_state)) in xs_wake_pending()
2823 xprt_wake_pending_tasks(&transport->xprt, -EAGAIN); in xs_wake_pending()
2828 struct sock_xprt *transport = container_of(work, in xs_error_handle() local
2831 xs_wake_disconnect(transport); in xs_error_handle()
2832 xs_wake_write(transport); in xs_error_handle()
2833 xs_wake_error(transport); in xs_error_handle()
2834 xs_wake_pending(transport); in xs_error_handle()
2874 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_udp_print_stats() local
2878 transport->srcport, in xs_udp_print_stats()
2898 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); in xs_tcp_print_stats() local
2906 transport->srcport, in xs_tcp_print_stats()
2966 struct sock_xprt *transport = in bc_sendto() local
2980 err = xprt_sock_sendmsg(transport->sock, &msg, xdr, 0, marker, &sent); in bc_sendto()
3210 * xs_setup_local - Set up transport to use an AF_LOCAL socket
3211 * @args: rpc transport creation arguments
3213 * AF_LOCAL is a "tpi_cots_ord" transport, just like TCP
3218 struct sock_xprt *transport; in xs_setup_local() local
3226 transport = container_of(xprt, struct sock_xprt, xprt); in xs_setup_local()
3239 INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); in xs_setup_local()
3240 INIT_WORK(&transport->error_worker, xs_error_handle); in xs_setup_local()
3241 INIT_DELAYED_WORK(&transport->connect_worker, xs_dummy_setup_socket); in xs_setup_local()
3278 * xs_setup_udp - Set up transport to use a UDP socket
3279 * @args: rpc transport creation arguments
3286 struct sock_xprt *transport; in xs_setup_udp() local
3293 transport = container_of(xprt, struct sock_xprt, xprt); in xs_setup_udp()
3308 INIT_WORK(&transport->recv_worker, xs_udp_data_receive_workfn); in xs_setup_udp()
3309 INIT_WORK(&transport->error_worker, xs_error_handle); in xs_setup_udp()
3310 INIT_DELAYED_WORK(&transport->connect_worker, xs_udp_setup_socket); in xs_setup_udp()
3355 * xs_setup_tcp - Set up transport to use a TCP socket
3356 * @args: rpc transport creation arguments
3363 struct sock_xprt *transport; in xs_setup_tcp() local
3374 transport = container_of(xprt, struct sock_xprt, xprt); in xs_setup_tcp()
3396 INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); in xs_setup_tcp()
3397 INIT_WORK(&transport->error_worker, xs_error_handle); in xs_setup_tcp()
3398 INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket); in xs_setup_tcp()
3437 * xs_setup_tcp_tls - Set up transport to use a TCP with TLS
3438 * @args: rpc transport creation arguments
3445 struct sock_xprt *transport; in xs_setup_tcp_tls() local
3456 transport = container_of(xprt, struct sock_xprt, xprt); in xs_setup_tcp_tls()
3473 INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); in xs_setup_tcp_tls()
3474 INIT_WORK(&transport->error_worker, xs_error_handle); in xs_setup_tcp_tls()
3480 INIT_DELAYED_WORK(&transport->connect_worker, in xs_setup_tcp_tls()
3525 * xs_setup_bc_tcp - Set up transport to use a TCP backchannel socket
3526 * @args: rpc transport creation arguments
3533 struct sock_xprt *transport; in xs_setup_bc_tcp() local
3541 transport = container_of(xprt, struct sock_xprt, xprt); in xs_setup_bc_tcp()
3585 transport->sock = bc_sock->sk_sock; in xs_setup_bc_tcp()
3586 transport->inet = bc_sock->sk_sk; in xs_setup_bc_tcp()