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: 52817 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4F99AB7DB4 for ; Tue, 18 May 2010 07:16:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753975Ab0EQVQo (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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch enforces single-buffer allocation when mergeable rx buffers is not enabled. Reported-by: Michael S. Tsirkin Signed-off-by: David L Stevens --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);