@@ -548,7 +548,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid &&
le64_to_cpu(pkt->hdr.dst_cid) ==
vhost_transport_get_local_cid())
- virtio_transport_recv_pkt(&vhost_transport, pkt);
+ virtio_transport_recv_pkt(&vhost_transport, NULL, pkt);
else
virtio_transport_free_pkt(pkt);
@@ -150,6 +150,7 @@ virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
void virtio_transport_destruct(struct vsock_sock *vsk);
void virtio_transport_recv_pkt(struct virtio_transport *t,
+ struct sock *sk,
struct virtio_vsock_pkt *pkt);
void virtio_transport_free_pkt(struct virtio_vsock_pkt *pkt);
void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct virtio_vsock_pkt *pkt);
@@ -560,7 +560,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
pkt->len = len - sizeof(pkt->hdr);
virtio_transport_deliver_tap_pkt(pkt);
- virtio_transport_recv_pkt(&virtio_transport, pkt);
+ virtio_transport_recv_pkt(&virtio_transport, NULL, pkt);
}
} while (!virtqueue_enable_cb(vq));
@@ -1238,11 +1238,11 @@ static bool virtio_transport_valid_type(u16 type)
* lock.
*/
void virtio_transport_recv_pkt(struct virtio_transport *t,
+ struct sock *sk,
struct virtio_vsock_pkt *pkt)
{
struct sockaddr_vm src, dst;
struct vsock_sock *vsk;
- struct sock *sk;
bool space_available;
vsock_addr_init(&src, le64_to_cpu(pkt->hdr.src_cid),
@@ -1267,12 +1267,14 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
/* The socket must be in connected or bound table
* otherwise send reset back
*/
- sk = vsock_find_connected_socket(&src, &dst);
if (!sk) {
- sk = vsock_find_bound_socket(&dst);
+ sk = vsock_find_connected_socket(&src, &dst);
if (!sk) {
- (void)virtio_transport_reset_no_sock(t, pkt);
- goto free_pkt;
+ sk = vsock_find_bound_socket(&dst);
+ if (!sk) {
+ (void)virtio_transport_reset_no_sock(t, pkt);
+ goto free_pkt;
+ }
}
}
@@ -134,7 +134,7 @@ static void vsock_loopback_work(struct work_struct *work)
list_del_init(&pkt->list);
virtio_transport_deliver_tap_pkt(pkt);
- virtio_transport_recv_pkt(&loopback_transport, pkt);
+ virtio_transport_recv_pkt(&loopback_transport, NULL, pkt);
}
}
Pass destination socket to 'virtio_transport_recv_pkt()'. This is needed, because caller may need socket structure, thus to avoid socket extra lookup in connect/bind lists, socket is passed as parameter(if it is NULL, then lookup is performed in the same way as before). Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> --- drivers/vhost/vsock.c | 2 +- include/linux/virtio_vsock.h | 1 + net/vmw_vsock/virtio_transport.c | 2 +- net/vmw_vsock/virtio_transport_common.c | 12 +++++++----- net/vmw_vsock/vsock_loopback.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-)