Skip to content

Commit

Permalink
net: fix qemu_can_send_packet logic
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Blue Swirl <[email protected]>
  • Loading branch information
vpalatin authored and blueswirl committed Mar 5, 2011
1 parent 24ac3a7 commit 60c07d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 60c07d9

Please sign in to comment.