dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0006-virtio-net-correctly-drop-truncated-packets.patch

b448bf
From: Jason Wang <jasowang@redhat.com>
b448bf
Date: Fri, 25 Sep 2015 13:21:30 +0800
b448bf
Subject: [PATCH] virtio-net: correctly drop truncated packets
b448bf
b448bf
When packet is truncated during receiving, we drop the packets but
b448bf
neither discard the descriptor nor add and signal used
b448bf
descriptor. This will lead several issues:
b448bf
b448bf
- sg mappings are leaked
b448bf
- rx will be stalled if a lots of packets were truncated
b448bf
b448bf
In order to be consistent with vhost, fix by discarding the descriptor
b448bf
in this case.
b448bf
b448bf
Cc: Michael S. Tsirkin <mst@redhat.com>
b448bf
Signed-off-by: Jason Wang <jasowang@redhat.com>
b448bf
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
b448bf
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
b448bf
b448bf
(cherry picked from commit 0cf33fb6b49a19de32859e2cdc6021334f448fb3)
b448bf
---
b448bf
 hw/net/virtio-net.c | 8 +-------
b448bf
 1 file changed, 1 insertion(+), 7 deletions(-)
b448bf
b448bf
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
b448bf
index 1510839..775389b 100644
b448bf
--- a/hw/net/virtio-net.c
b448bf
+++ b/hw/net/virtio-net.c
b448bf
@@ -1086,13 +1086,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
b448bf
          * must have consumed the complete packet.
b448bf
          * Otherwise, drop it. */
b448bf
         if (!n->mergeable_rx_bufs && offset < size) {
b448bf
-#if 0
b448bf
-            error_report("virtio-net truncated non-mergeable packet: "
b448bf
-                         "i %zd mergeable %d offset %zd, size %zd, "
b448bf
-                         "guest hdr len %zd, host hdr len %zd",
b448bf
-                         i, n->mergeable_rx_bufs,
b448bf
-                         offset, size, n->guest_hdr_len, n->host_hdr_len);
b448bf
-#endif
b448bf
+            virtqueue_discard(q->rx_vq, &elem, total);
b448bf
             return size;
b448bf
         }
b448bf