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