From patchwork Mon May 17 21:16:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Stevens X-Patchwork-Id: 100216 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4HLGt1p032745 for ; Mon, 17 May 2010 21:16:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753883Ab0EQVQo (ORCPT ); Mon, 17 May 2010 17:16:44 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:50052 "EHLO e3.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425Ab0EQVQn (ORCPT ); Mon, 17 May 2010 17:16:43 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e3.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o4HL3nmI013062; Mon, 17 May 2010 17:03:49 -0400 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4HLGf2K055704; Mon, 17 May 2010 17:16:41 -0400 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o4HLJUCo016100; Mon, 17 May 2010 15:19:31 -0600 Received: from [9.47.18.17] (w-dls.beaverton.ibm.com [9.47.18.17]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o4HLJUtf016063; Mon, 17 May 2010 15:19:30 -0600 Subject: [PATCH] [resend] fix non-mergeable buffers packet too large error handling From: David L Stevens Reply-To: dlstevens@us.ibm.com To: mst@redhat.com Cc: netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.osdl.org Organization: IBM Date: Mon, 17 May 2010 14:16:36 -0700 Message-ID: <1274130996.8492.7.camel@w-dls.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 17 May 2010 21:16:56 +0000 (UTC) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 309c570..c346304 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -361,13 +361,21 @@ static void handle_rx(struct vhost_net *net) break; } /* TODO: Should check and handle checksum. */ - if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF) && - memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount, - offsetof(typeof(hdr), num_buffers), - sizeof hdr.num_buffers)) { - vq_err(vq, "Failed num_buffers write"); + if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF)) { + if (memcpy_toiovecend(vq->hdr, + (unsigned char *)&headcount, + offsetof(typeof(hdr), + num_buffers), + sizeof hdr.num_buffers)) { + vq_err(vq, "Failed num_buffers write"); + vhost_discard_desc(vq, headcount); + break; + } + } else if (headcount > 1) { + vq_err(vq, "rx packet too large (%d) for guest", + sock_len); vhost_discard_desc(vq, headcount); - break; + continue; } vhost_add_used_and_signal_n(&net->dev, vq, vq->heads, headcount);