Skip to content

Commit

Permalink
Merge branch 'vsock-virtio-fixes-about-packet-delivery-to-monitoring-…
Browse files Browse the repository at this point in the history
…devices'

Stefano Garzarella says:

====================
vsock/virtio: fixes about packet delivery to monitoring devices

During the review of v1, Stefan pointed out an issue introduced by
that patch, where replies can appear in the packet capture before
the transmitted packet.

While fixing my patch, reverting it and adding a new flag in
'struct virtio_vsock_pkt' (patch 2/2), I found that we already had
that issue in vhost-vsock, so I fixed it (patch 1/2).

v1 -> v2:
- reverted the v1 patch, to avoid that replies can appear in the
  packet capture before the transmitted packet [Stefan]
- added patch to fix packet delivering to monitoring devices in
  vhost-vsock
- added patch to check if the packet is already delivered to
  monitoring devices

v1: https://patchwork.ozlabs.org/project/netdev/patch/20200421092527.41651-1-sgarzare@redhat.com/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
davem330 committed Apr 27, 2020
2 parents 52a9061 + a78d163 commit 18e6719
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/vhost/vsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,27 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
break;
}

vhost_add_used(vq, head, sizeof(pkt->hdr) + payload_len);
added = true;

/* Deliver to monitoring devices all correctly transmitted
* packets.
/* Deliver to monitoring devices all packets that we
* will transmit.
*/
virtio_transport_deliver_tap_pkt(pkt);

vhost_add_used(vq, head, sizeof(pkt->hdr) + payload_len);
added = true;

pkt->off += payload_len;
total_len += payload_len;

/* If we didn't send all the payload we can requeue the packet
* to send it with the next available buffer.
*/
if (pkt->off < pkt->len) {
/* We are queueing the same virtio_vsock_pkt to handle
* the remaining bytes, and we want to deliver it
* to monitoring devices in the next iteration.
*/
pkt->tap_delivered = false;

spin_lock_bh(&vsock->send_pkt_list_lock);
list_add(&pkt->list, &vsock->send_pkt_list);
spin_unlock_bh(&vsock->send_pkt_list_lock);
Expand Down
1 change: 1 addition & 0 deletions include/linux/virtio_vsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct virtio_vsock_pkt {
u32 len;
u32 off;
bool reply;
bool tap_delivered;
};

struct virtio_vsock_pkt_info {
Expand Down
4 changes: 4 additions & 0 deletions net/vmw_vsock/virtio_transport_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque)

void virtio_transport_deliver_tap_pkt(struct virtio_vsock_pkt *pkt)
{
if (pkt->tap_delivered)
return;

vsock_deliver_tap(virtio_transport_build_skb, pkt);
pkt->tap_delivered = true;
}
EXPORT_SYMBOL_GPL(virtio_transport_deliver_tap_pkt);

Expand Down

0 comments on commit 18e6719

Please sign in to comment.