From patchwork Fri Sep 14 08:46:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 183843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 87EA42C0080 for ; Fri, 14 Sep 2012 18:47:59 +1000 (EST) Received: from localhost ([::1]:40511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCRZ7-0004w5-If for incoming@patchwork.ozlabs.org; Fri, 14 Sep 2012 04:47:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCRYj-0004aZ-0P for qemu-devel@nongnu.org; Fri, 14 Sep 2012 04:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCRYc-0000tF-DW for qemu-devel@nongnu.org; Fri, 14 Sep 2012 04:47:32 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:48553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCRYc-0000s8-7E for qemu-devel@nongnu.org; Fri, 14 Sep 2012 04:47:26 -0400 Received: by mail-wg0-f53.google.com with SMTP id dr1so370149wgb.10 for ; Fri, 14 Sep 2012 01:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YQR/0caFq/XInuIYcLOGzUI264ZrXg21QEWzvLO8Kcs=; b=fB/UmhKvdDneVFMGEFH98gkgeHx6eTVFhIjyr5ByN/8F1mfPt10lcpuFpHS+hiArR7 1UNdEy6xWpecucoLo6E25j/d92wLmdT06sXozvLsvU+pVJGNOkkKjRdFJbkvqaoQGUkP DL7AGLnTacMBNSWUuY1YMfywupvb8MFf+cwq9lwRTrsJjmROhxK8NTTfConao01ZUBjd w5sMG8Oy7dq6oZ1Fih/vaDo/GYewE2ZTk56NcV/rdjDFigJU7/mcgHUN7OoJD8R8B1Hk UVRwjXsCsjyFLBGlBl0W8BZLCYIHzM75XlNbusHBilT4lqvwTj5qoGzHF3jjcCxBOnt5 vRhg== Received: by 10.180.81.99 with SMTP id z3mr3787340wix.0.1347612445701; Fri, 14 Sep 2012 01:47:25 -0700 (PDT) Received: from localhost ([109.224.133.37]) by mx.google.com with ESMTPS id ct3sm17860337wib.5.2012.09.14.01.47.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Sep 2012 01:47:25 -0700 (PDT) From: Stefan Hajnoczi To: Anthony Liguori Date: Fri, 14 Sep 2012 09:46:52 +0100 Message-Id: <1347612420-5704-6-git-send-email-stefanha@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1347612420-5704-1-git-send-email-stefanha@gmail.com> References: <1347612420-5704-1-git-send-email-stefanha@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.53 Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 05/13] net: add receive_disabled logic to iov delivery path 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 From: Stefan Hajnoczi This patch adds the missing NetClient->receive_disabled logic in the sendv delivery code path. It seems that commit 893379efd0e1b84ceb0c42a713293f3dbd27b1bd ("net: disable receiving if client returns zero") only added the logic to qemu_deliver_packet() and not qemu_deliver_packet_iov(). The receive_disabled flag should be automatically set when .receive(), .receive_raw(), or .receive_iov() return 0. No further packets will be delivered to the NetClient until the receive_disabled flag is cleared again by calling qemu_flush_queued_packets(). Typically the NetClient will wait until its file descriptor becomes writable and then invoke qemu_flush_queued_packets() to resume transmission. Signed-off-by: Stefan Hajnoczi --- net.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net.c b/net.c index d9ba1e5..a187a7b 100644 --- a/net.c +++ b/net.c @@ -423,16 +423,27 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, void *opaque) { NetClientState *nc = opaque; + int ret; if (nc->link_down) { return iov_size(iov, iovcnt); } + if (nc->receive_disabled) { + return 0; + } + if (nc->info->receive_iov) { - return nc->info->receive_iov(nc, iov, iovcnt); + ret = nc->info->receive_iov(nc, iov, iovcnt); } else { - return nc_sendv_compat(nc, iov, iovcnt); + ret = nc_sendv_compat(nc, iov, iovcnt); } + + if (ret == 0) { + nc->receive_disabled = 1; + } + + return ret; } ssize_t qemu_sendv_packet_async(NetClientState *sender,