Lines Matching refs:vsk
60 static bool vmci_check_transport(struct vsock_sock *vsk);
286 struct vsock_sock *vsk; in vmci_transport_send_control_pkt() local
288 vsk = vsock_sk(sk); in vmci_transport_send_control_pkt()
290 if (!vsock_addr_bound(&vsk->local_addr)) in vmci_transport_send_control_pkt()
293 if (!vsock_addr_bound(&vsk->remote_addr)) in vmci_transport_send_control_pkt()
296 return vmci_transport_alloc_send_control_pkt(&vsk->local_addr, in vmci_transport_send_control_pkt()
297 &vsk->remote_addr, in vmci_transport_send_control_pkt()
319 struct vsock_sock *vsk; in vmci_transport_send_reset() local
324 vsk = vsock_sk(sk); in vmci_transport_send_reset()
326 if (!vsock_addr_bound(&vsk->local_addr)) in vmci_transport_send_reset()
329 if (vsock_addr_bound(&vsk->remote_addr)) { in vmci_transport_send_reset()
330 dst_ptr = &vsk->remote_addr; in vmci_transport_send_reset()
336 return vmci_transport_alloc_send_control_pkt(&vsk->local_addr, dst_ptr, in vmci_transport_send_reset()
450 static int vmci_transport_shutdown(struct vsock_sock *vsk, int mode) in vmci_transport_shutdown() argument
453 &vsk->sk, in vmci_transport_shutdown()
616 struct vsock_sock *vsk; in vmci_transport_recv_dgram_cb() local
629 vsk = vsock_sk(sk); in vmci_transport_recv_dgram_cb()
630 if (!vmci_transport_allow_dgram(vsk, dg->src.context)) in vmci_transport_recv_dgram_cb()
677 struct vsock_sock *vsk; in vmci_transport_recv_stream_cb() local
746 vsk = vsock_sk(sk); in vmci_transport_recv_stream_cb()
747 if (!vmci_transport_allow_dgram(vsk, pkt->dg.src.context)) { in vmci_transport_recv_stream_cb()
761 vsk->local_addr.svm_cid = dst.svm_cid; in vmci_transport_recv_stream_cb()
764 vmci_trans(vsk)->notify_ops->handle_notify_pkt( in vmci_transport_recv_stream_cb()
805 struct vsock_sock *vsk; in vmci_transport_handle_detach() local
807 vsk = vsock_sk(sk); in vmci_transport_handle_detach()
808 if (!vmci_handle_is_invalid(vmci_trans(vsk)->qp_handle)) { in vmci_transport_handle_detach()
814 vsk->peer_shutdown = SHUTDOWN_MASK; in vmci_transport_handle_detach()
823 if (vsk->local_addr.svm_cid == VMADDR_CID_HOST || in vmci_transport_handle_detach()
824 vsock_stream_has_data(vsk) <= 0) { in vmci_transport_handle_detach()
1280 struct vsock_sock *vsk; in vmci_transport_recv_connecting_client() local
1284 vsk = vsock_sk(sk); in vmci_transport_recv_connecting_client()
1290 vmci_trans(vsk)->qp_handle)) { in vmci_transport_recv_connecting_client()
1303 vsock_insert_connected(vsk); in vmci_transport_recv_connecting_client()
1310 || pkt->dg.src.context != vsk->remote_addr.svm_cid in vmci_transport_recv_connecting_client()
1311 || pkt->src_port != vsk->remote_addr.svm_port in vmci_transport_recv_connecting_client()
1312 || !vmci_handle_is_invalid(vmci_trans(vsk)->qp_handle) in vmci_transport_recv_connecting_client()
1313 || vmci_trans(vsk)->qpair in vmci_transport_recv_connecting_client()
1314 || vmci_trans(vsk)->produce_size != 0 in vmci_transport_recv_connecting_client()
1315 || vmci_trans(vsk)->consume_size != 0 in vmci_transport_recv_connecting_client()
1316 || vmci_trans(vsk)->detach_sub_id != VMCI_INVALID_ID) { in vmci_transport_recv_connecting_client()
1348 if (vsk->ignore_connecting_rst) { in vmci_transport_recv_connecting_client()
1349 vsk->ignore_connecting_rst = false; in vmci_transport_recv_connecting_client()
1380 struct vsock_sock *vsk; in vmci_transport_recv_connecting_client_negotiate() local
1390 vsk = vsock_sk(sk); in vmci_transport_recv_connecting_client_negotiate()
1397 vsk->sent_request = false; in vmci_transport_recv_connecting_client_negotiate()
1398 vsk->ignore_connecting_rst = false; in vmci_transport_recv_connecting_client_negotiate()
1401 if (pkt->u.size < vsk->buffer_min_size || in vmci_transport_recv_connecting_client_negotiate()
1402 pkt->u.size > vsk->buffer_max_size) { in vmci_transport_recv_connecting_client_negotiate()
1409 if (vsk->local_addr.svm_cid == VMADDR_CID_ANY) in vmci_transport_recv_connecting_client_negotiate()
1410 vsk->local_addr.svm_cid = pkt->dg.dst.context; in vmci_transport_recv_connecting_client_negotiate()
1444 vmci_trans(vsk), &detach_sub_id); in vmci_transport_recv_connecting_client_negotiate()
1452 is_local = vsk->remote_addr.svm_cid == vsk->local_addr.svm_cid; in vmci_transport_recv_connecting_client_negotiate()
1459 vsk->remote_addr.svm_cid, in vmci_transport_recv_connecting_client_negotiate()
1462 vsk, in vmci_transport_recv_connecting_client_negotiate()
1463 vsk-> in vmci_transport_recv_connecting_client_negotiate()
1474 vmci_trans(vsk)->qp_handle = handle; in vmci_transport_recv_connecting_client_negotiate()
1475 vmci_trans(vsk)->qpair = qpair; in vmci_transport_recv_connecting_client_negotiate()
1477 vmci_trans(vsk)->produce_size = vmci_trans(vsk)->consume_size = in vmci_transport_recv_connecting_client_negotiate()
1480 vmci_trans(vsk)->detach_sub_id = detach_sub_id; in vmci_transport_recv_connecting_client_negotiate()
1482 vmci_trans(vsk)->notify_ops->process_negotiate(sk); in vmci_transport_recv_connecting_client_negotiate()
1501 struct vsock_sock *vsk = vsock_sk(sk); in vmci_transport_recv_connecting_client_invalid() local
1503 if (vsk->sent_request) { in vmci_transport_recv_connecting_client_invalid()
1504 vsk->sent_request = false; in vmci_transport_recv_connecting_client_invalid()
1505 vsk->ignore_connecting_rst = true; in vmci_transport_recv_connecting_client_invalid()
1507 err = vmci_transport_send_conn_request(sk, vsk->buffer_size); in vmci_transport_recv_connecting_client_invalid()
1521 struct vsock_sock *vsk; in vmci_transport_recv_connected() local
1535 vsk = vsock_sk(sk); in vmci_transport_recv_connected()
1537 vsk->peer_shutdown |= pkt->u.mode; in vmci_transport_recv_connected()
1543 vsk = vsock_sk(sk); in vmci_transport_recv_connected()
1554 vsk->peer_shutdown = SHUTDOWN_MASK; in vmci_transport_recv_connected()
1555 if (vsock_stream_has_data(vsk) <= 0) in vmci_transport_recv_connected()
1562 vsk = vsock_sk(sk); in vmci_transport_recv_connected()
1563 vmci_trans(vsk)->notify_ops->handle_notify_pkt( in vmci_transport_recv_connected()
1575 static int vmci_transport_socket_init(struct vsock_sock *vsk, in vmci_transport_socket_init() argument
1578 vsk->trans = kmalloc(sizeof(struct vmci_transport), GFP_KERNEL); in vmci_transport_socket_init()
1579 if (!vsk->trans) in vmci_transport_socket_init()
1582 vmci_trans(vsk)->dg_handle = VMCI_INVALID_HANDLE; in vmci_transport_socket_init()
1583 vmci_trans(vsk)->qp_handle = VMCI_INVALID_HANDLE; in vmci_transport_socket_init()
1584 vmci_trans(vsk)->qpair = NULL; in vmci_transport_socket_init()
1585 vmci_trans(vsk)->produce_size = vmci_trans(vsk)->consume_size = 0; in vmci_transport_socket_init()
1586 vmci_trans(vsk)->detach_sub_id = VMCI_INVALID_ID; in vmci_transport_socket_init()
1587 vmci_trans(vsk)->notify_ops = NULL; in vmci_transport_socket_init()
1588 INIT_LIST_HEAD(&vmci_trans(vsk)->elem); in vmci_transport_socket_init()
1589 vmci_trans(vsk)->sk = &vsk->sk; in vmci_transport_socket_init()
1590 spin_lock_init(&vmci_trans(vsk)->lock); in vmci_transport_socket_init()
1629 static void vmci_transport_destruct(struct vsock_sock *vsk) in vmci_transport_destruct() argument
1632 if (!vmci_trans(vsk)) in vmci_transport_destruct()
1638 spin_lock_bh(&vmci_trans(vsk)->lock); in vmci_transport_destruct()
1639 vmci_trans(vsk)->sk = NULL; in vmci_transport_destruct()
1640 spin_unlock_bh(&vmci_trans(vsk)->lock); in vmci_transport_destruct()
1642 if (vmci_trans(vsk)->notify_ops) in vmci_transport_destruct()
1643 vmci_trans(vsk)->notify_ops->socket_destruct(vsk); in vmci_transport_destruct()
1646 list_add(&vmci_trans(vsk)->elem, &vmci_transport_cleanup_list); in vmci_transport_destruct()
1650 vsk->trans = NULL; in vmci_transport_destruct()
1653 static void vmci_transport_release(struct vsock_sock *vsk) in vmci_transport_release() argument
1655 vsock_remove_sock(vsk); in vmci_transport_release()
1657 if (!vmci_handle_is_invalid(vmci_trans(vsk)->dg_handle)) { in vmci_transport_release()
1658 vmci_datagram_destroy_handle(vmci_trans(vsk)->dg_handle); in vmci_transport_release()
1659 vmci_trans(vsk)->dg_handle = VMCI_INVALID_HANDLE; in vmci_transport_release()
1663 static int vmci_transport_dgram_bind(struct vsock_sock *vsk, in vmci_transport_dgram_bind() argument
1684 &vsk->sk, in vmci_transport_dgram_bind()
1685 &vmci_trans(vsk)->dg_handle); in vmci_transport_dgram_bind()
1688 vsock_addr_init(&vsk->local_addr, addr->svm_cid, in vmci_transport_dgram_bind()
1689 vmci_trans(vsk)->dg_handle.resource); in vmci_transport_dgram_bind()
1695 struct vsock_sock *vsk, in vmci_transport_dgram_enqueue() argument
1706 if (!vmci_transport_allow_dgram(vsk, remote_addr->svm_cid)) in vmci_transport_dgram_enqueue()
1718 dg->src = vmci_make_handle(vsk->local_addr.svm_cid, in vmci_transport_dgram_enqueue()
1719 vsk->local_addr.svm_port); in vmci_transport_dgram_enqueue()
1730 static int vmci_transport_dgram_dequeue(struct vsock_sock *vsk, in vmci_transport_dgram_dequeue() argument
1744 skb = skb_recv_datagram(&vsk->sk, flags, &err); in vmci_transport_dgram_dequeue()
1779 skb_free_datagram(&vsk->sk, skb); in vmci_transport_dgram_dequeue()
1795 static int vmci_transport_connect(struct vsock_sock *vsk) in vmci_transport_connect() argument
1799 struct sock *sk = &vsk->sk; in vmci_transport_connect()
1803 err = vmci_transport_send_conn_request(sk, vsk->buffer_size); in vmci_transport_connect()
1811 err = vmci_transport_send_conn_request2(sk, vsk->buffer_size, in vmci_transport_connect()
1818 vsk->sent_request = true; in vmci_transport_connect()
1825 struct vsock_sock *vsk, in vmci_transport_stream_dequeue() argument
1831 return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0); in vmci_transport_stream_dequeue()
1833 return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0); in vmci_transport_stream_dequeue()
1837 struct vsock_sock *vsk, in vmci_transport_stream_enqueue() argument
1841 return vmci_qpair_enquev(vmci_trans(vsk)->qpair, msg, len, 0); in vmci_transport_stream_enqueue()
1844 static s64 vmci_transport_stream_has_data(struct vsock_sock *vsk) in vmci_transport_stream_has_data() argument
1846 return vmci_qpair_consume_buf_ready(vmci_trans(vsk)->qpair); in vmci_transport_stream_has_data()
1849 static s64 vmci_transport_stream_has_space(struct vsock_sock *vsk) in vmci_transport_stream_has_space() argument
1851 return vmci_qpair_produce_free_space(vmci_trans(vsk)->qpair); in vmci_transport_stream_has_space()
1854 static u64 vmci_transport_stream_rcvhiwat(struct vsock_sock *vsk) in vmci_transport_stream_rcvhiwat() argument
1856 return vmci_trans(vsk)->consume_size; in vmci_transport_stream_rcvhiwat()
1859 static bool vmci_transport_stream_is_active(struct vsock_sock *vsk) in vmci_transport_stream_is_active() argument
1861 return !vmci_handle_is_invalid(vmci_trans(vsk)->qp_handle); in vmci_transport_stream_is_active()
1865 struct vsock_sock *vsk, in vmci_transport_notify_poll_in() argument
1869 return vmci_trans(vsk)->notify_ops->poll_in( in vmci_transport_notify_poll_in()
1870 &vsk->sk, target, data_ready_now); in vmci_transport_notify_poll_in()
1874 struct vsock_sock *vsk, in vmci_transport_notify_poll_out() argument
1878 return vmci_trans(vsk)->notify_ops->poll_out( in vmci_transport_notify_poll_out()
1879 &vsk->sk, target, space_available_now); in vmci_transport_notify_poll_out()
1883 struct vsock_sock *vsk, in vmci_transport_notify_recv_init() argument
1887 return vmci_trans(vsk)->notify_ops->recv_init( in vmci_transport_notify_recv_init()
1888 &vsk->sk, target, in vmci_transport_notify_recv_init()
1893 struct vsock_sock *vsk, in vmci_transport_notify_recv_pre_block() argument
1897 return vmci_trans(vsk)->notify_ops->recv_pre_block( in vmci_transport_notify_recv_pre_block()
1898 &vsk->sk, target, in vmci_transport_notify_recv_pre_block()
1903 struct vsock_sock *vsk, in vmci_transport_notify_recv_pre_dequeue() argument
1907 return vmci_trans(vsk)->notify_ops->recv_pre_dequeue( in vmci_transport_notify_recv_pre_dequeue()
1908 &vsk->sk, target, in vmci_transport_notify_recv_pre_dequeue()
1913 struct vsock_sock *vsk, in vmci_transport_notify_recv_post_dequeue() argument
1919 return vmci_trans(vsk)->notify_ops->recv_post_dequeue( in vmci_transport_notify_recv_post_dequeue()
1920 &vsk->sk, target, copied, data_read, in vmci_transport_notify_recv_post_dequeue()
1925 struct vsock_sock *vsk, in vmci_transport_notify_send_init() argument
1928 return vmci_trans(vsk)->notify_ops->send_init( in vmci_transport_notify_send_init()
1929 &vsk->sk, in vmci_transport_notify_send_init()
1934 struct vsock_sock *vsk, in vmci_transport_notify_send_pre_block() argument
1937 return vmci_trans(vsk)->notify_ops->send_pre_block( in vmci_transport_notify_send_pre_block()
1938 &vsk->sk, in vmci_transport_notify_send_pre_block()
1943 struct vsock_sock *vsk, in vmci_transport_notify_send_pre_enqueue() argument
1946 return vmci_trans(vsk)->notify_ops->send_pre_enqueue( in vmci_transport_notify_send_pre_enqueue()
1947 &vsk->sk, in vmci_transport_notify_send_pre_enqueue()
1952 struct vsock_sock *vsk, in vmci_transport_notify_send_post_enqueue() argument
1956 return vmci_trans(vsk)->notify_ops->send_post_enqueue( in vmci_transport_notify_send_post_enqueue()
1957 &vsk->sk, written, in vmci_transport_notify_send_post_enqueue()
1980 struct vsock_sock *vsk = vsock_sk(sk); in vmci_transport_proto_to_notify_struct() local
1987 vmci_trans(vsk)->notify_ops = &vmci_transport_notify_pkt_ops; in vmci_transport_proto_to_notify_struct()
1993 vmci_trans(vsk)->notify_ops = in vmci_transport_proto_to_notify_struct()
2002 vmci_trans(vsk)->notify_ops->socket_init(sk); in vmci_transport_proto_to_notify_struct()
2050 static bool vmci_check_transport(struct vsock_sock *vsk) in vmci_check_transport() argument
2052 return vsk->transport == &vmci_transport; in vmci_check_transport()