From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf6SU-0005FP-Vx for qemu-devel@nongnu.org; Thu, 24 Sep 2015 09:21:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf6SU-0006rX-6m for qemu-devel@nongnu.org; Thu, 24 Sep 2015 09:21:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf6SU-0006rK-0s for qemu-devel@nongnu.org; Thu, 24 Sep 2015 09:21:10 -0400 Date: Thu, 24 Sep 2015 16:21:07 +0300 From: "Michael S. Tsirkin" Message-ID: <1443100738-14970-23-git-send-email-mst@redhat.com> References: <1443100738-14970-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443100738-14970-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 22/22] virtio-net: correctly drop truncated packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang From: Jason Wang 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 d388c55..a877614 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1094,13 +1094,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; } -- MST