From patchwork Mon Nov 23 12:23:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 39252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D33F01007D1 for ; Wed, 25 Nov 2009 09:41:05 +1100 (EST) Received: from localhost ([127.0.0.1]:53831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ND44E-00040j-NH for incoming@patchwork.ozlabs.org; Tue, 24 Nov 2009 17:41:02 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCY13-00052g-Fe for qemu-devel@nongnu.org; Mon, 23 Nov 2009 07:27:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCY0y-00051e-3Q for qemu-devel@nongnu.org; Mon, 23 Nov 2009 07:27:36 -0500 Received: from [199.232.76.173] (port=60916 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCY0x-00051V-TM for qemu-devel@nongnu.org; Mon, 23 Nov 2009 07:27:31 -0500 Received: from dlpdemo.checkpoint.com ([194.29.32.54]:59977) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NCY0w-0006Tx-Sc for qemu-devel@nongnu.org; Mon, 23 Nov 2009 07:27:31 -0500 X-CheckPoint: {4B0A7C0A-2-14201DC2-FFFF} Received: by dlpdemo.checkpoint.com (Postfix, from userid 105) id 0864129C004; Mon, 23 Nov 2009 14:27:27 +0200 (IST) Received: from michael.checkpoint.com (michael.checkpoint.com [194.29.32.68]) by dlpdemo.checkpoint.com (Postfix) with ESMTP id DEA7F29C002 for ; Mon, 23 Nov 2009 14:27:26 +0200 (IST) X-CheckPoint: {4B0A7C0A-0-14201DC2-FFFF} Received: from il-ex01.ad.checkpoint.com (localhost [127.0.0.1]) by michael.checkpoint.com (8.12.10+Sun/8.12.10) with ESMTP id nANCRQGo025891 for ; Mon, 23 Nov 2009 14:27:26 +0200 (IST) Received: from il-ex01.ad.checkpoint.com ([126.0.0.2]) by il-ex01.ad.checkpoint.com ([126.0.0.2]) with mapi; Mon, 23 Nov 2009 14:27:31 +0200 From: Boris Sukholitko To: "qemu-devel@nongnu.org" Date: Mon, 23 Nov 2009 14:23:03 +0200 Thread-Topic: [PATCH] Remove VLAN client on network connection close Thread-Index: AQHKbDdfUHBdKjdWtEyaKrxFfoxyDpFDlvkB Message-ID: <623FF5F796BC1248BD72BE2383C52FAF7AD08B2C4E@il-ex01.ad.checkpoint.com> References: <623FF5F796BC1248BD72BE2383C52FAF7AD08B2C4D@il-ex01.ad.checkpoint.com> In-Reply-To: <623FF5F796BC1248BD72BE2383C52FAF7AD08B2C4D@il-ex01.ad.checkpoint.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-Mailman-Approved-At: Tue, 24 Nov 2009 17:38:49 -0500 Subject: [Qemu-devel] [PATCH] Remove VLAN client on network connection close X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, I am seeing funny QEMU behaviour when using "-net socket,listen" mechanism. When connecting and disconnecting several clients I start to get duplicated packets from QEMU server. IMHO, the following is happenning: 1. Client is disconnected: we get into net_socket_send callback. 2. net_socket_send does closesocket on the fd. 3. Note, that VLANClientState is not being removed. 4. New client is getting the same fd as the old client. 5. At this stage we have two VLANClientState's with the same fd. 6. From now on, every packet is being sent twice by qemu_vlan_deliver_packet. It seems that the fix would be to qemu_del_vlan_client on stage 3. It certainly fixes my problem. Thanks, Boris. PS. Please CC me as I am not subscribed to the list. Signed-off-by: Boris Sukholitko diff --git a/net.c b/net.c index 9ea66e3..951b9a4 100644 --- a/net.c +++ b/net.c @@ -1440,6 +1440,7 @@ static void net_socket_send(void *opaque) eoc: qemu_set_fd_handler(s->fd, NULL, NULL, NULL); closesocket(s->fd); + qemu_del_vlan_client(s->vc); return; } buf = buf1;