From patchwork Fri Sep 25 05:21:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 522637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5BEDF14027C for ; Fri, 25 Sep 2015 15:23:23 +1000 (AEST) Received: from localhost ([::1]:36594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfLTd-0001Il-CD for incoming@patchwork.ozlabs.org; Fri, 25 Sep 2015 01:23:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfLS1-0007Dh-Gm for qemu-devel@nongnu.org; Fri, 25 Sep 2015 01:21:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfLS0-0001co-T4 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 01:21:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfLS0-0001ci-Fm for qemu-devel@nongnu.org; Fri, 25 Sep 2015 01:21:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 14E83AE5C4 for ; Fri, 25 Sep 2015 05:21:40 +0000 (UTC) Received: from jason-ThinkPad-T430s.nay.redhat.com (dhcp-14-122.nay.redhat.com [10.66.14.122]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8P5LRrQ011009; Fri, 25 Sep 2015 01:21:37 -0400 From: Jason Wang To: mst@redhat.com, qemu-devel@nongnu.org Date: Fri, 25 Sep 2015 13:21:30 +0800 Message-Id: <1443158490-16469-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1443158490-16469-1-git-send-email-jasowang@redhat.com> References: <1443158490-16469-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , ppandit@redhat.com Subject: [Qemu-devel] [PATCH V2 3/3] virtio-net: correctly drop truncated packets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }