net: fix qemu_can_send_packet logic
commit60c07d933c66c4b30a83b7ccbc8a0cb3df1b2d0e
authorVincent Palatin <vpalatin@chromium.org>
Wed, 2 Mar 2011 22:25:02 +0000 (2 17:25 -0500)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 5 Mar 2011 12:00:59 +0000 (5 12:00 +0000)
treea60247ab922b1d6a4af7aeb1e636bbc880a9f67c
parent24ac3a7d4eacea38d514dbf50baa845e5bc6840b
net: fix qemu_can_send_packet logic

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 <vpalatin@chromium.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
net.c