From patchwork Thu Feb 16 08:07:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 141518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A43D8B6EE7 for ; Thu, 16 Feb 2012 19:07:44 +1100 (EST) Received: from localhost ([::1]:50655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwNO-00031Z-RG for incoming@patchwork.ozlabs.org; Thu, 16 Feb 2012 03:07:38 -0500 Received: from eggs.gnu.org ([140.186.70.92]:57011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwNE-00031P-SY for qemu-devel@nongnu.org; Thu, 16 Feb 2012 03:07:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxwND-00058w-QV for qemu-devel@nongnu.org; Thu, 16 Feb 2012 03:07:28 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:43342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwND-00058p-JE for qemu-devel@nongnu.org; Thu, 16 Feb 2012 03:07:27 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Feb 2012 03:07:26 -0500 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Feb 2012 03:07:25 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id EBFD238C8052 for ; Thu, 16 Feb 2012 03:07:23 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1G87NJI337626 for ; Thu, 16 Feb 2012 03:07:23 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1G87Nqo019649 for ; Thu, 16 Feb 2012 06:07:23 -0200 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q1G87JR8019574; Thu, 16 Feb 2012 06:07:20 -0200 Received: by us.ibm.com (sSMTP sendmail emulation); Thu, 16 Feb 2012 16:07:15 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2012 16:07:14 +0800 Message-Id: <1329379634-1498-1-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12021608-5806-0000-0000-00001281F20B X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.137 Cc: aliguori@us.ibm.com, Zhi Yong Wu , jan.kiszka@web.de, stefanha@linux.vnet.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2] slirp: fix packet requeue issue in batchq 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: Zhi Yong Wu Signed-off-by: Zhi Yong Wu --- slirp/if.c | 19 +++++++++++++++++-- slirp/mbuf.c | 3 +-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/slirp/if.c b/slirp/if.c index 8e0cac2..57350d5 100644 --- a/slirp/if.c +++ b/slirp/if.c @@ -22,6 +22,7 @@ ifs_remque(struct mbuf *ifm) { ifm->ifs_prev->ifs_next = ifm->ifs_next; ifm->ifs_next->ifs_prev = ifm->ifs_prev; + ifs_init(ifm); } void @@ -154,7 +155,7 @@ if_start(Slirp *slirp) { uint64_t now = qemu_get_clock_ns(rt_clock); int requeued = 0; - struct mbuf *ifm, *ifqt; + struct mbuf *ifm, *ifqt, *ifm_next; DEBUG_CALL("if_start"); @@ -162,6 +163,8 @@ if_start(Slirp *slirp) return; /* Nothing to do */ again: + ifm_next = NULL; + /* check if we can really output */ if (!slirp_can_output(slirp->opaque)) return; @@ -190,6 +193,7 @@ if_start(Slirp *slirp) /* If there are more packets for this session, re-queue them */ if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) { insque(ifm->ifs_next, ifqt); + ifm_next = ifm->ifs_next; ifs_remque(ifm); } @@ -209,7 +213,18 @@ if_start(Slirp *slirp) m_free(ifm); } else { /* re-queue */ - insque(ifm, ifqt); + if (ifm_next) { + /*restore the original state of batchq*/ + remque(ifm_next); + insque(ifm, ifqt); + ifm_next->ifs_prev->ifs_next = ifm; + ifm->ifs_prev = ifm_next->ifs_prev; + ifm->ifs_next = ifm_next; + ifm_next->ifs_prev = ifm; + } else { + insque(ifm, ifqt); + } + requeued++; } } diff --git a/slirp/mbuf.c b/slirp/mbuf.c index c699c75..f429c0a 100644 --- a/slirp/mbuf.c +++ b/slirp/mbuf.c @@ -68,8 +68,7 @@ m_get(Slirp *slirp) m->m_size = SLIRP_MSIZE - offsetof(struct mbuf, m_dat); m->m_data = m->m_dat; m->m_len = 0; - m->m_nextpkt = NULL; - m->m_prevpkt = NULL; + ifs_init(m); m->arp_requested = false; m->expiration_date = (uint64_t)-1; end_error: