Lines Matching refs:vsk
171 #define vsock_connected_sockets_vsk(vsk) \ argument
172 vsock_connected_sockets(&(vsk)->remote_addr, &(vsk)->local_addr)
182 static int vsock_auto_bind(struct vsock_sock *vsk) in vsock_auto_bind() argument
184 struct sock *sk = sk_vsock(vsk); in vsock_auto_bind()
187 if (vsock_addr_bound(&vsk->local_addr)) in vsock_auto_bind()
205 struct vsock_sock *vsk) in __vsock_insert_bound() argument
207 sock_hold(&vsk->sk); in __vsock_insert_bound()
208 list_add(&vsk->bound_table, list); in __vsock_insert_bound()
212 struct vsock_sock *vsk) in __vsock_insert_connected() argument
214 sock_hold(&vsk->sk); in __vsock_insert_connected()
215 list_add(&vsk->connected_table, list); in __vsock_insert_connected()
218 static void __vsock_remove_bound(struct vsock_sock *vsk) in __vsock_remove_bound() argument
220 list_del_init(&vsk->bound_table); in __vsock_remove_bound()
221 sock_put(&vsk->sk); in __vsock_remove_bound()
224 static void __vsock_remove_connected(struct vsock_sock *vsk) in __vsock_remove_connected() argument
226 list_del_init(&vsk->connected_table); in __vsock_remove_connected()
227 sock_put(&vsk->sk); in __vsock_remove_connected()
232 struct vsock_sock *vsk; in __vsock_find_bound_socket() local
234 list_for_each_entry(vsk, vsock_bound_sockets(addr), bound_table) { in __vsock_find_bound_socket()
235 if (vsock_addr_equals_addr(addr, &vsk->local_addr)) in __vsock_find_bound_socket()
236 return sk_vsock(vsk); in __vsock_find_bound_socket()
238 if (addr->svm_port == vsk->local_addr.svm_port && in __vsock_find_bound_socket()
239 (vsk->local_addr.svm_cid == VMADDR_CID_ANY || in __vsock_find_bound_socket()
241 return sk_vsock(vsk); in __vsock_find_bound_socket()
250 struct vsock_sock *vsk; in __vsock_find_connected_socket() local
252 list_for_each_entry(vsk, vsock_connected_sockets(src, dst), in __vsock_find_connected_socket()
254 if (vsock_addr_equals_addr(src, &vsk->remote_addr) && in __vsock_find_connected_socket()
255 dst->svm_port == vsk->local_addr.svm_port) { in __vsock_find_connected_socket()
256 return sk_vsock(vsk); in __vsock_find_connected_socket()
263 static void vsock_insert_unbound(struct vsock_sock *vsk) in vsock_insert_unbound() argument
266 __vsock_insert_bound(vsock_unbound_sockets, vsk); in vsock_insert_unbound()
270 void vsock_insert_connected(struct vsock_sock *vsk) in vsock_insert_connected() argument
273 &vsk->remote_addr, &vsk->local_addr); in vsock_insert_connected()
276 __vsock_insert_connected(list, vsk); in vsock_insert_connected()
281 void vsock_remove_bound(struct vsock_sock *vsk) in vsock_remove_bound() argument
284 if (__vsock_in_bound_table(vsk)) in vsock_remove_bound()
285 __vsock_remove_bound(vsk); in vsock_remove_bound()
290 void vsock_remove_connected(struct vsock_sock *vsk) in vsock_remove_connected() argument
293 if (__vsock_in_connected_table(vsk)) in vsock_remove_connected()
294 __vsock_remove_connected(vsk); in vsock_remove_connected()
330 void vsock_remove_sock(struct vsock_sock *vsk) in vsock_remove_sock() argument
332 vsock_remove_bound(vsk); in vsock_remove_sock()
333 vsock_remove_connected(vsk); in vsock_remove_sock()
345 struct vsock_sock *vsk; in vsock_for_each_connected_socket() local
346 list_for_each_entry(vsk, &vsock_connected_table[i], in vsock_for_each_connected_socket()
348 if (vsk->transport != transport) in vsock_for_each_connected_socket()
351 fn(sk_vsock(vsk)); in vsock_for_each_connected_socket()
412 static void vsock_deassign_transport(struct vsock_sock *vsk) in vsock_deassign_transport() argument
414 if (!vsk->transport) in vsock_deassign_transport()
417 vsk->transport->destruct(vsk); in vsock_deassign_transport()
418 module_put(vsk->transport->module); in vsock_deassign_transport()
419 vsk->transport = NULL; in vsock_deassign_transport()
434 int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) in vsock_assign_transport() argument
437 struct sock *sk = sk_vsock(vsk); in vsock_assign_transport()
438 unsigned int remote_cid = vsk->remote_addr.svm_cid; in vsock_assign_transport()
450 if (psk && vsk->local_addr.svm_cid > VMADDR_CID_HOST && in vsock_assign_transport()
451 vsk->remote_addr.svm_cid > VMADDR_CID_HOST) in vsock_assign_transport()
452 vsk->remote_addr.svm_flags |= VMADDR_FLAG_TO_HOST; in vsock_assign_transport()
454 remote_flags = vsk->remote_addr.svm_flags; in vsock_assign_transport()
474 if (vsk->transport) { in vsock_assign_transport()
475 if (vsk->transport == new_transport) in vsock_assign_transport()
484 vsk->transport->release(vsk); in vsock_assign_transport()
485 vsock_deassign_transport(vsk); in vsock_assign_transport()
502 ret = new_transport->init(vsk, psk); in vsock_assign_transport()
508 vsk->transport = new_transport; in vsock_assign_transport()
553 struct vsock_sock *vsk = vsock_sk(sk); in vsock_is_accept_queue_empty() local
554 return list_empty(&vsk->accept_queue); in vsock_is_accept_queue_empty()
559 struct vsock_sock *vsk = vsock_sk(sk); in vsock_is_pending() local
560 return !list_empty(&vsk->pending_links); in vsock_is_pending()
565 struct vsock_sock *vsk = vsock_sk(sk); in vsock_send_shutdown() local
567 if (!vsk->transport) in vsock_send_shutdown()
570 return vsk->transport->shutdown(vsk, mode); in vsock_send_shutdown()
577 struct vsock_sock *vsk; in vsock_pending_work() local
580 vsk = container_of(work, struct vsock_sock, pending_work.work); in vsock_pending_work()
581 sk = sk_vsock(vsk); in vsock_pending_work()
582 listener = vsk->listener; in vsock_pending_work()
592 } else if (!vsk->rejected) { in vsock_pending_work()
606 vsock_remove_connected(vsk); in vsock_pending_work()
622 static int __vsock_bind_connectible(struct vsock_sock *vsk, in __vsock_bind_connectible() argument
665 vsock_addr_init(&vsk->local_addr, new_addr.svm_cid, new_addr.svm_port); in __vsock_bind_connectible()
672 __vsock_remove_bound(vsk); in __vsock_bind_connectible()
673 __vsock_insert_bound(vsock_bound_sockets(&vsk->local_addr), vsk); in __vsock_bind_connectible()
678 static int __vsock_bind_dgram(struct vsock_sock *vsk, in __vsock_bind_dgram() argument
681 return vsk->transport->dgram_bind(vsk, addr); in __vsock_bind_dgram()
686 struct vsock_sock *vsk = vsock_sk(sk); in __vsock_bind() local
690 if (vsock_addr_bound(&vsk->local_addr)) in __vsock_bind()
705 retval = __vsock_bind_connectible(vsk, addr); in __vsock_bind()
710 retval = __vsock_bind_dgram(vsk, addr); in __vsock_bind()
732 struct vsock_sock *vsk; in __vsock_create() local
747 vsk = vsock_sk(sk); in __vsock_create()
748 vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY); in __vsock_create()
749 vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY); in __vsock_create()
755 INIT_LIST_HEAD(&vsk->bound_table); in __vsock_create()
756 INIT_LIST_HEAD(&vsk->connected_table); in __vsock_create()
757 vsk->listener = NULL; in __vsock_create()
758 INIT_LIST_HEAD(&vsk->pending_links); in __vsock_create()
759 INIT_LIST_HEAD(&vsk->accept_queue); in __vsock_create()
760 vsk->rejected = false; in __vsock_create()
761 vsk->sent_request = false; in __vsock_create()
762 vsk->ignore_connecting_rst = false; in __vsock_create()
763 vsk->peer_shutdown = 0; in __vsock_create()
764 INIT_DELAYED_WORK(&vsk->connect_work, vsock_connect_timeout); in __vsock_create()
765 INIT_DELAYED_WORK(&vsk->pending_work, vsock_pending_work); in __vsock_create()
769 vsk->trusted = psk->trusted; in __vsock_create()
770 vsk->owner = get_cred(psk->owner); in __vsock_create()
771 vsk->connect_timeout = psk->connect_timeout; in __vsock_create()
772 vsk->buffer_size = psk->buffer_size; in __vsock_create()
773 vsk->buffer_min_size = psk->buffer_min_size; in __vsock_create()
774 vsk->buffer_max_size = psk->buffer_max_size; in __vsock_create()
777 vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN); in __vsock_create()
778 vsk->owner = get_current_cred(); in __vsock_create()
779 vsk->connect_timeout = VSOCK_DEFAULT_CONNECT_TIMEOUT; in __vsock_create()
780 vsk->buffer_size = VSOCK_DEFAULT_BUFFER_SIZE; in __vsock_create()
781 vsk->buffer_min_size = VSOCK_DEFAULT_BUFFER_MIN_SIZE; in __vsock_create()
782 vsk->buffer_max_size = VSOCK_DEFAULT_BUFFER_MAX_SIZE; in __vsock_create()
797 struct vsock_sock *vsk; in __vsock_release() local
799 vsk = vsock_sk(sk); in __vsock_release()
809 if (vsk->transport) in __vsock_release()
810 vsk->transport->release(vsk); in __vsock_release()
812 vsock_remove_sock(vsk); in __vsock_release()
832 struct vsock_sock *vsk = vsock_sk(sk); in vsock_sk_destruct() local
834 vsock_deassign_transport(vsk); in vsock_sk_destruct()
839 vsock_addr_init(&vsk->local_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY); in vsock_sk_destruct()
840 vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, VMADDR_PORT_ANY); in vsock_sk_destruct()
842 put_cred(vsk->owner); in vsock_sk_destruct()
863 s64 vsock_stream_has_data(struct vsock_sock *vsk) in vsock_stream_has_data() argument
865 return vsk->transport->stream_has_data(vsk); in vsock_stream_has_data()
869 static s64 vsock_connectible_has_data(struct vsock_sock *vsk) in vsock_connectible_has_data() argument
871 struct sock *sk = sk_vsock(vsk); in vsock_connectible_has_data()
874 return vsk->transport->seqpacket_has_data(vsk); in vsock_connectible_has_data()
876 return vsock_stream_has_data(vsk); in vsock_connectible_has_data()
879 s64 vsock_stream_has_space(struct vsock_sock *vsk) in vsock_stream_has_space() argument
881 return vsk->transport->stream_has_space(vsk); in vsock_stream_has_space()
887 struct vsock_sock *vsk = vsock_sk(sk); in vsock_data_ready() local
889 if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat || in vsock_data_ready()
928 struct vsock_sock *vsk; in vsock_getname() local
932 vsk = vsock_sk(sk); in vsock_getname()
942 vm_addr = &vsk->remote_addr; in vsock_getname()
944 vm_addr = &vsk->local_addr; in vsock_getname()
1022 struct vsock_sock *vsk; in vsock_poll() local
1025 vsk = vsock_sk(sk); in vsock_poll()
1039 (vsk->peer_shutdown & SEND_SHUTDOWN))) { in vsock_poll()
1044 vsk->peer_shutdown & SEND_SHUTDOWN) { in vsock_poll()
1066 transport = vsk->transport; in vsock_poll()
1076 if (transport && transport->stream_is_active(vsk) && in vsock_poll()
1081 vsk, target, &data_ready_now); in vsock_poll()
1096 vsk->peer_shutdown & SEND_SHUTDOWN) { in vsock_poll()
1105 vsk, 1, &space_avail_now); in vsock_poll()
1140 struct vsock_sock *vsk; in vsock_dgram_sendmsg() local
1150 vsk = vsock_sk(sk); in vsock_dgram_sendmsg()
1154 transport = vsk->transport; in vsock_dgram_sendmsg()
1156 err = vsock_auto_bind(vsk); in vsock_dgram_sendmsg()
1179 remote_addr = &vsk->remote_addr; in vsock_dgram_sendmsg()
1187 if (!vsock_addr_bound(&vsk->remote_addr)) { in vsock_dgram_sendmsg()
1202 err = transport->dgram_enqueue(vsk, remote_addr, msg, len); in vsock_dgram_sendmsg()
1214 struct vsock_sock *vsk; in vsock_dgram_connect() local
1218 vsk = vsock_sk(sk); in vsock_dgram_connect()
1223 vsock_addr_init(&vsk->remote_addr, VMADDR_CID_ANY, in vsock_dgram_connect()
1233 err = vsock_auto_bind(vsk); in vsock_dgram_connect()
1237 if (!vsk->transport->dgram_allow(remote_addr->svm_cid, in vsock_dgram_connect()
1243 memcpy(&vsk->remote_addr, remote_addr, sizeof(vsk->remote_addr)); in vsock_dgram_connect()
1254 struct vsock_sock *vsk = vsock_sk(sock->sk); in vsock_dgram_recvmsg() local
1256 return vsk->transport->dgram_dequeue(vsk, msg, len, flags); in vsock_dgram_recvmsg()
1278 static int vsock_transport_cancel_pkt(struct vsock_sock *vsk) in vsock_transport_cancel_pkt() argument
1280 const struct vsock_transport *transport = vsk->transport; in vsock_transport_cancel_pkt()
1285 return transport->cancel_pkt(vsk); in vsock_transport_cancel_pkt()
1291 struct vsock_sock *vsk; in vsock_connect_timeout() local
1293 vsk = container_of(work, struct vsock_sock, connect_work.work); in vsock_connect_timeout()
1294 sk = sk_vsock(vsk); in vsock_connect_timeout()
1303 vsock_transport_cancel_pkt(vsk); in vsock_connect_timeout()
1315 struct vsock_sock *vsk; in vsock_connect() local
1323 vsk = vsock_sk(sk); in vsock_connect()
1354 memcpy(&vsk->remote_addr, remote_addr, in vsock_connect()
1355 sizeof(vsk->remote_addr)); in vsock_connect()
1357 err = vsock_assign_transport(vsk, NULL); in vsock_connect()
1361 transport = vsk->transport; in vsock_connect()
1373 err = vsock_auto_bind(vsk); in vsock_connect()
1379 err = transport->connect(vsk); in vsock_connect()
1394 timeout = vsk->connect_timeout; in vsock_connect()
1411 if (mod_delayed_work(system_wq, &vsk->connect_work, in vsock_connect()
1427 vsock_transport_cancel_pkt(vsk); in vsock_connect()
1428 vsock_remove_connected(vsk); in vsock_connect()
1434 vsock_transport_cancel_pkt(vsk); in vsock_connect()
1542 struct vsock_sock *vsk; in vsock_listen() local
1558 vsk = vsock_sk(sk); in vsock_listen()
1560 if (!vsock_addr_bound(&vsk->local_addr)) { in vsock_listen()
1575 static void vsock_update_buffer_size(struct vsock_sock *vsk, in vsock_update_buffer_size() argument
1579 if (val > vsk->buffer_max_size) in vsock_update_buffer_size()
1580 val = vsk->buffer_max_size; in vsock_update_buffer_size()
1582 if (val < vsk->buffer_min_size) in vsock_update_buffer_size()
1583 val = vsk->buffer_min_size; in vsock_update_buffer_size()
1585 if (val != vsk->buffer_size && in vsock_update_buffer_size()
1587 transport->notify_buffer_size(vsk, &val); in vsock_update_buffer_size()
1589 vsk->buffer_size = val; in vsock_update_buffer_size()
1600 struct vsock_sock *vsk; in vsock_connectible_setsockopt() local
1621 vsk = vsock_sk(sk); in vsock_connectible_setsockopt()
1625 transport = vsk->transport; in vsock_connectible_setsockopt()
1630 vsock_update_buffer_size(vsk, transport, val); in vsock_connectible_setsockopt()
1635 vsk->buffer_max_size = val; in vsock_connectible_setsockopt()
1636 vsock_update_buffer_size(vsk, transport, vsk->buffer_size); in vsock_connectible_setsockopt()
1641 vsk->buffer_min_size = val; in vsock_connectible_setsockopt()
1642 vsock_update_buffer_size(vsk, transport, vsk->buffer_size); in vsock_connectible_setsockopt()
1655 vsk->connect_timeout = tv.tv_sec * HZ + in vsock_connectible_setsockopt()
1657 if (vsk->connect_timeout == 0) in vsock_connectible_setsockopt()
1658 vsk->connect_timeout = in vsock_connectible_setsockopt()
1685 struct vsock_sock *vsk = vsock_sk(sk); in vsock_connectible_getsockopt() local
1707 v.val64 = vsk->buffer_size; in vsock_connectible_getsockopt()
1711 v.val64 = vsk->buffer_max_size; in vsock_connectible_getsockopt()
1715 v.val64 = vsk->buffer_min_size; in vsock_connectible_getsockopt()
1720 lv = sock_get_timeout(vsk->connect_timeout, &v, in vsock_connectible_getsockopt()
1745 struct vsock_sock *vsk; in vsock_connectible_sendmsg() local
1754 vsk = vsock_sk(sk); in vsock_connectible_sendmsg()
1763 transport = vsk->transport; in vsock_connectible_sendmsg()
1775 vsk->peer_shutdown & RCV_SHUTDOWN) { in vsock_connectible_sendmsg()
1781 !vsock_addr_bound(&vsk->local_addr)) { in vsock_connectible_sendmsg()
1786 if (!vsock_addr_bound(&vsk->remote_addr)) { in vsock_connectible_sendmsg()
1794 err = transport->notify_send_init(vsk, &send_data); in vsock_connectible_sendmsg()
1802 while (vsock_stream_has_space(vsk) == 0 && in vsock_connectible_sendmsg()
1805 !(vsk->peer_shutdown & RCV_SHUTDOWN)) { in vsock_connectible_sendmsg()
1814 err = transport->notify_send_pre_block(vsk, &send_data); in vsock_connectible_sendmsg()
1843 (vsk->peer_shutdown & RCV_SHUTDOWN)) { in vsock_connectible_sendmsg()
1848 err = transport->notify_send_pre_enqueue(vsk, &send_data); in vsock_connectible_sendmsg()
1859 written = transport->seqpacket_enqueue(vsk, in vsock_connectible_sendmsg()
1862 written = transport->stream_enqueue(vsk, in vsock_connectible_sendmsg()
1873 vsk, written, &send_data); in vsock_connectible_sendmsg()
1900 struct vsock_sock *vsk; in vsock_connectible_wait_data() local
1904 vsk = vsock_sk(sk); in vsock_connectible_wait_data()
1906 transport = vsk->transport; in vsock_connectible_wait_data()
1910 data = vsock_connectible_has_data(vsk); in vsock_connectible_wait_data()
1916 (vsk->peer_shutdown & SEND_SHUTDOWN)) { in vsock_connectible_wait_data()
1927 err = transport->notify_recv_pre_block(vsk, target, recv_data); in vsock_connectible_wait_data()
1965 struct vsock_sock *vsk; in __vsock_stream_recvmsg() local
1973 vsk = vsock_sk(sk); in __vsock_stream_recvmsg()
1974 transport = vsk->transport; in __vsock_stream_recvmsg()
1983 if (target >= transport->stream_rcvhiwat(vsk)) { in __vsock_stream_recvmsg()
1990 err = transport->notify_recv_init(vsk, target, &recv_data); in __vsock_stream_recvmsg()
2003 err = transport->notify_recv_pre_dequeue(vsk, target, in __vsock_stream_recvmsg()
2008 read = transport->stream_dequeue(vsk, msg, len - copied, flags); in __vsock_stream_recvmsg()
2016 err = transport->notify_recv_post_dequeue(vsk, target, read, in __vsock_stream_recvmsg()
2043 struct vsock_sock *vsk; in __vsock_seqpacket_recvmsg() local
2049 vsk = vsock_sk(sk); in __vsock_seqpacket_recvmsg()
2050 transport = vsk->transport; in __vsock_seqpacket_recvmsg()
2058 msg_len = transport->seqpacket_dequeue(vsk, msg, flags); in __vsock_seqpacket_recvmsg()
2094 struct vsock_sock *vsk; in vsock_connectible_recvmsg() local
2099 vsk = vsock_sk(sk); in vsock_connectible_recvmsg()
2104 transport = vsk->transport; in vsock_connectible_recvmsg()
2155 struct vsock_sock *vsk; in vsock_set_rcvlowat() local
2157 vsk = vsock_sk(sk); in vsock_set_rcvlowat()
2159 if (val > vsk->buffer_size) in vsock_set_rcvlowat()
2162 transport = vsk->transport; in vsock_set_rcvlowat()
2165 return transport->set_rcvlowat(vsk, val); in vsock_set_rcvlowat()
2217 struct vsock_sock *vsk; in vsock_create() local
2247 vsk = vsock_sk(sk); in vsock_create()
2250 ret = vsock_assign_transport(vsk, NULL); in vsock_create()
2257 vsock_insert_unbound(vsk); in vsock_create()
2368 const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk) in vsock_core_get_transport() argument
2370 return vsk->transport; in vsock_core_get_transport()