From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcqbm-0001aE-KX for qemu-devel@nongnu.org; Fri, 18 Sep 2015 04:01:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcqbl-000182-Nd for qemu-devel@nongnu.org; Fri, 18 Sep 2015 04:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcqbl-00017E-IU for qemu-devel@nongnu.org; Fri, 18 Sep 2015 04:01:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E3789C0B918E for ; Fri, 18 Sep 2015 08:01:24 +0000 (UTC) From: Jason Wang Date: Fri, 18 Sep 2015 16:01:10 +0800 Message-Id: <1442563270-11615-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1442563270-11615-1-git-send-email-jasowang@redhat.com> References: <1442563270-11615-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] virtio-net: correctly drop truncated packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com, qemu-devel@nongnu.org Cc: Jason Wang , ppandit@redhat.com 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 Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f72eebf..038a18b 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; } -- 2.1.4