From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6M2u-0005pM-3p for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6M2o-0005jb-Kl for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:39 -0400 Received: from [199.232.76.173] (port=34890 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6M2o-0005j9-6C for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:34 -0400 Received: from mail28.svc.cra.dublin.eircom.net ([159.134.118.224]:48360) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1M6M2n-0006eo-QR for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:33 -0400 From: Mark McLoughlin Date: Tue, 19 May 2009 10:55:25 +0100 Message-Id: <1242726931-5726-4-git-send-email-markmc@redhat.com> In-Reply-To: <1242726931-5726-3-git-send-email-markmc@redhat.com> References: <1242726931-5726-1-git-send-email-markmc@redhat.com> <1242726931-5726-2-git-send-email-markmc@redhat.com> <1242726931-5726-3-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 03/13] net: vlan clients with no fd_can_read() can always receive List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Mark McLoughlin , qemu-devel@nongnu.org If a vlan client has no fd_can_read(), that means it can always receive packets. The current code assumes it can *never* receive packets. Signed-off-by: Mark McLoughlin --- net.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/net.c b/net.c index 3f9062f..a3f4674 100644 --- a/net.c +++ b/net.c @@ -389,15 +389,19 @@ VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque) return NULL; } -int qemu_can_send_packet(VLANClientState *vc1) +int qemu_can_send_packet(VLANClientState *sender) { - VLANState *vlan = vc1->vlan; + VLANState *vlan = sender->vlan; VLANClientState *vc; - for(vc = vlan->first_client; vc != NULL; vc = vc->next) { - if (vc != vc1) { - if (vc->fd_can_read && vc->fd_can_read(vc->opaque)) - return 1; + for (vc = vlan->first_client; vc != NULL; vc = vc->next) { + if (vc == sender) { + continue; + } + + /* no fd_can_read() handler, they can always receive */ + if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) { + return 1; } } return 0; -- 1.6.0.6