From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39485 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuuTt-0006Vv-PU for qemu-devel@nongnu.org; Wed, 02 Mar 2011 17:25:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PuuTr-0003RI-K4 for qemu-devel@nongnu.org; Wed, 02 Mar 2011 17:25:17 -0500 Received: from smtp-out.google.com ([74.125.121.67]:44259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PuuTr-0003Qy-BJ for qemu-devel@nongnu.org; Wed, 02 Mar 2011 17:25:15 -0500 From: Vincent Palatin Date: Wed, 2 Mar 2011 17:25:02 -0500 Message-Id: <1299104702-18928-3-git-send-email-vpalatin@chromium.org> In-Reply-To: <1299104702-18928-1-git-send-email-vpalatin@chromium.org> References: <1299104702-18928-1-git-send-email-vpalatin@chromium.org> Subject: [Qemu-devel] [PATCH 2/2] net: fix qemu_can_send_packet logic List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: Vincent Palatin If any of the clients is not ready to receive (ie it has a can_receive callback and can_receive() returns false), we don't want to start sending, else this client may miss/discard the packet. I got this behaviour with the following setup : the emulated machine is using an USB-ethernet adapter, it is connected to the network using SLIRP and I'm dumping the traffic in a .pcap file. As per the following command line : -net nic,model=usb,vlan=1 -net user,vlan=1 -net dump,vlan=1,file=/tmp/pkt.pcap Every time that two packets are coming in a row from the host, the usb-net code will receive the first one, then returns 0 to can_receive call since it has a 1 packet long queue. But as the dump code is always ready to receive, qemu_can_send_packet will return true and the next packet will discard the previous one in the usb-net code. Signed-off-by: Vincent Palatin --- net.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net.c b/net.c index ec4745d..72ac4cf 100644 --- a/net.c +++ b/net.c @@ -411,11 +411,11 @@ int qemu_can_send_packet(VLANClientState *sender) } /* no can_receive() handler, they can always receive */ - if (!vc->info->can_receive || vc->info->can_receive(vc)) { - return 1; + if (vc->info->can_receive && !vc->info->can_receive(vc)) { + return 0; } } - return 0; + return 1; } static ssize_t qemu_deliver_packet(VLANClientState *sender, -- 1.7.3.1