summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2015-09-25 13:21:30 +0800
committerMichael Roth <mdroth@linux.vnet.ibm.com>2015-10-21 13:40:28 -0500
commit696317f1895e836d53b670c7b77b7be93302ba08 (patch)
tree42e066c211595e8e78f40f720cac33ab6219651b
parentc2a550d3dfa1f22eac77842aceed6047f6db2320 (diff)
downloadqemu-696317f1895e836d53b670c7b77b7be93302ba08.tar.gz
virtio-net: correctly drop truncated packets
When packet is truncated during receiving, we drop the packets but neither discard the descriptor nor add and signal used descriptor. This will lead several issues: - sg mappings are leaked - rx will be stalled if a lots of packets were truncated In order to be consistent with vhost, fix by discarding the descriptor in this case. Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> (cherry picked from commit 0cf33fb6b49a19de32859e2cdc6021334f448fb3) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--hw/net/virtio-net.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 887a836229..4aa93fb931 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1086,13 +1086,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
* must have consumed the complete packet.
* Otherwise, drop it. */
if (!n->mergeable_rx_bufs && offset < size) {
-#if 0
- error_report("virtio-net truncated non-mergeable packet: "
- "i %zd mergeable %d offset %zd, size %zd, "
- "guest hdr len %zd, host hdr len %zd",
- i, n->mergeable_rx_bufs,
- offset, size, n->guest_hdr_len, n->host_hdr_len);
-#endif
+ virtqueue_discard(q->rx_vq, &elem, total);
return size;
}