Stefano Garzarella
2020-Apr-24 15:08 UTC
[PATCH net v2 0/2] 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 at redhat.com/ Stefano Garzarella (2): vhost/vsock: fix packet delivery order to monitoring devices vsock/virtio: fix multiple packet delivery to monitoring devices drivers/vhost/vsock.c | 16 +++++++++++----- include/linux/virtio_vsock.h | 1 + net/vmw_vsock/virtio_transport_common.c | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) -- 2.25.3
Stefano Garzarella
2020-Apr-24 15:08 UTC
[PATCH net v2 1/2] vhost/vsock: fix packet delivery order to monitoring devices
We want to deliver packets to monitoring devices before it is put in the virtqueue, to avoid that replies can appear in the packet capture before the transmitted packet. Signed-off-by: Stefano Garzarella <sgarzare at redhat.com> --- drivers/vhost/vsock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 97669484a3f6..18aff350a405 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -181,14 +181,14 @@ 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; -- 2.25.3
Stefano Garzarella
2020-Apr-24 15:08 UTC
[PATCH net v2 2/2] vsock/virtio: fix multiple packet delivery to monitoring devices
In virtio_transport.c, if the virtqueue is full, the transmitting packet is queued up and it will be sent in the next iteration. This causes the same packet to be delivered multiple times to monitoring devices. We want to continue to deliver packets to monitoring devices before it is put in the virtqueue, to avoid that replies can appear in the packet capture before the transmitted packet. This patch fixes the issue, adding a new flag (tap_delivered) in struct virtio_vsock_pkt, to check if the packet is already delivered to monitoring devices. In vhost/vsock.c, we are splitting packets, so we must set 'tap_delivered' to false when we queue up the same virtio_vsock_pkt to handle the remaining bytes. Signed-off-by: Stefano Garzarella <sgarzare at redhat.com> --- drivers/vhost/vsock.c | 6 ++++++ include/linux/virtio_vsock.h | 1 + net/vmw_vsock/virtio_transport_common.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 18aff350a405..11f066c76a25 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -196,6 +196,12 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, * 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); diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h index 71c81e0dc8f2..dc636b727179 100644 --- a/include/linux/virtio_vsock.h +++ b/include/linux/virtio_vsock.h @@ -48,6 +48,7 @@ struct virtio_vsock_pkt { u32 len; u32 off; bool reply; + bool tap_delivered; }; struct virtio_vsock_pkt_info { diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 709038a4783e..69efc891885f 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -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); -- 2.25.3
David Miller
2020-Apr-27 17:18 UTC
[PATCH net v2 0/2] vsock/virtio: fixes about packet delivery to monitoring devices
From: Stefano Garzarella <sgarzare at redhat.com> Date: Fri, 24 Apr 2020 17:08:28 +0200> 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 at redhat.com/Series applied, thank you.
Reasonably Related Threads
- [PATCH v3 0/5] vsock/virtio: optimizations to increase the throughput
- [PATCH net-next v5 0/5] vsock/virtio: optimizations to increase the throughput
- [PATCH net-next v5 0/5] vsock/virtio: optimizations to increase the throughput
- [PATCH v4 0/5] vsock/virtio: optimizations to increase the throughput
- [PATCH v4 0/5] vsock/virtio: optimizations to increase the throughput