net/hub: remove can_receive handler
PATCH 1/1 net/hub: remove can_receive handler
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the qemu_send_packet() do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver call qemu_flush_queued_packets() later the queue will be really flushed and no packets will be stalled in the sender network queue.
--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)
net/hub.c +0 -20
@@ -87,25 +87,6 @@ static NetHub *net_hub_new(int id)return hub; } -static int net_hub_port_can_receive (NetClientState *nc) -{ -NetHubPort *port; -NetHubPort *src_port =DO_UPCAST (NetHubPort, nc, nc); -NetHub *hub = src_port->hub; - - QLIST_FOREACH(port, &hub->ports, next) { -if (port == src_port) { -continue ; - } - -if (qemu_can_send_packet (&port->nc)) { -return 1 ; - } - } - -return 0 ; -} -static ssize_t net_hub_port_receive (NetClientState *nc,const uint8_t *buf,size_t len) {
@@ -132,7 +113,6 @@ static void net_hub_port_cleanup(NetClientState *nc)static NetClientInfo net_hub_port_info = { .type =NET_CLIENT_OPTIONS_KIND_HUBPORT , .size =sizeof (NetHubPort), - .can_receive = net_hub_port_can_receive, .receive = net_hub_port_receive, .receive_iov = net_hub_port_receive_iov, .cleanup = net_hub_port_cleanup,
Signature · 1 line
1.7.9.5
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)
Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device. slirp_output() calls qemu_send_packet() which eventually calls qemu_net_queue_send(). qemu_net_queue_send() calls qemu_can_send_packet(), which calls can_receive() callback of network hub. Then net_hub_port_can_receive() also calls qemu_can_send_packet() for each port except packet source port.
Sometimes USB network device is not able to receive packet and qemu_can_send_packet() returns false. In my case there is no more ports and net_hub_port_can_receive() returns false. So qemu_net_queue_send() call qemu_net_queue_append() instead of qemu_net_queue_deliver(). qemu_net_queue_append() appends the packet to the receiving port of the network hub which is not flushed when USB netork device calls qemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.
Actually there is no need in net_hub_port_can_receive() as the network hub can always receive packets and pass it to its port network clients with qemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client call qemu_flush_queued_packets().
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 39 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.
Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().
Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
commit 199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100
net: fix qemu_flush_queued_packets() in presence of a hub
Stefan
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the qemu_send_packet() do the right things.
E.g. network hub has 3 ports. Suppose when iterating through port list in net_hub_port_can_receive() a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Later net_hub_flush() will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.
Anyway, actually there is no need in net_hub_port_can_receive() as the network hub can always receive packets and pass it to its port network clients with qemu_send_packet(). I think it's more natural solution.
Sergey
Il 22/04/2013 17:27, Fedorov Sergey ha scritto:
Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.
Perhaps it is indeed wrong to do this blocking in can_receive()... You're right that a hubport can always receive, but the hub itself should have a queue. If one port cannot receive, the packet should be appended to the hub's queue. And net_hub_flush will just go through the hub's queue.
Quoted 3 lines
Anyway, actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). I think it's more natural solution.
I think the point was to keep dumps in sync with what actually happened on the other ports. Otherwise a "-net dump" port will show the packet immediately, even though it hasn't been delivered yet.
Paolo
Quoted 15 lines · Paolo Bonzini
Il 22/04/2013 17:27, Fedorov Sergey ha scritto:
Quoted 8 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.Perhaps it is indeed wrong to do this blocking in
can_receive()... You're right that a hubport can always receive, but the hub itself should have a queue. If one port cannot receive, the packet should be appended to the hub's queue. Andnet_hub_flushwill just go through the hub's queue.
Quoted 9 lines
Quoted 3 lines
Anyway, actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). I think it's more natural solution.I think the point was to keep dumps in sync with what actually happened on the other ports. Otherwise a "-net dump" port will show the packet immediately, even though it hasn't been delivered yet.
Paolo
The user documentation says that `-net dump' dumps network traffic on VLAN. There is nothing said about interfaces connected to VALN nor synchronization with them. In my view, VLAN hub is a device that forwards an incoming packet to all other ports as soon as possible, just like real hardware hub. I think of `-net dump' as a special network interface that dumps every packet received by VLAN hub itself, not delivered to its clients. If we want to dump packets actually delivered to network interfaces we need to do it in per-interface manner. Maybe I misunderstand?
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 61 lines · Fedorov Sergey
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the
qemu_send_packet()do the right things.
Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.
Did you mean "second port" instead of "source port" in the beginning?
I don't see a scenario where the packet is delivered to the same port twice. If one port can receive then the packet will be sent and other ports will queue the packet. Note that the source port will not queue the packet. When the blocked ports can receive again their send queues will be flushed.
Paolo mentioned that we want to provide a consistent view of packets, especially when -net dump is used.
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
Stefan
Quoted 71 lines · Stefan Hajnoczi
Quoted 61 lines · Fedorov Sergey
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the
qemu_send_packet()do the right things.Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.
Quoted 5 lines
Did you mean "second port" instead of "source port" in the beginning?
I don't see a scenario where the packet is delivered to the same port twice. If one port can receive then the packet will be sent and other ports will queue the packet.
I agree. I was wrong with that.
Quoted 1 line
Note that the source port will not queue the packet.
The source port will queue the packet if no port, except the source one, can receive.
Quoted 9 lines
When the blocked ports can receive again their send queues will be flushed.
Paolo mentioned that we want to provide a consistent view of packets, especially when -net dump is used.
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No, net_hub_receive() calls qemu_send_packet(). If the destination queue cannot receive the packet qemu_net_queue_append() will take care of queue->nq_maxlen.
Quoted 3 lines
Stefan
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 6 lines · Fedorov Sergey
Quoted 3 lines
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No,
net_hub_receive()callsqemu_send_packet(). If the destination queue cannot receive the packetqemu_net_queue_append()will take care ofqueue->nq_maxlen.
You are right, sorry. We do discard packets at nq_maxlen.
The problem with ignoring .can_receive() on the hub is that it breaks flow control. For example, net/tap.c is designed to avoid reading more packets if its peer cannot receive (see tap_can_send()).
If the hub claims it can always receive we waste cycles reading packets from the tap device only to discard them.
Since qemu.git already has a fix which preserves flow control, I am not going to merge your patch.
Stefan
Quoted 13 lines · Stefan Hajnoczi
Quoted 6 lines · Fedorov Sergey
Quoted 3 lines
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No,
net_hub_receive()callsqemu_send_packet(). If the destination queue cannot receive the packetqemu_net_queue_append()will take care ofqueue->nq_maxlen.You are right, sorry. We do discard packets at
nq_maxlen.The problem with ignoring .can_receive() on the hub is that it breaks flow control. For example,
net/tap.cis designed to avoid reading more packets if its peer cannot receive (seetap_can_send()).
Quoted 8 lines
If the hub claims it can always receive we waste cycles reading packets from the tap device only to discard them.
Since qemu.git already has a fix which preserves flow control, I am not going to merge your patch.
Stefan
OK, I see. Thanks for attention.
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 13 lines · Stefan Hajnoczi
Quoted 6 lines · Fedorov Sergey
Quoted 3 lines
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No,
net_hub_receive()callsqemu_send_packet(). If the destination queue cannot receive the packetqemu_net_queue_append()will take care ofqueue->nq_maxlen.You are right, sorry. We do discard packets at
nq_maxlen.The problem with ignoring .can_receive() on the hub is that it breaks flow control. For example,
net/tap.cis designed to avoid reading more packets if its peer cannot receive (seetap_can_send()).
Quoted 9 lines
If the hub claims it can always receive we waste cycles reading packets from the tap device only to discard them.
Since qemu.git already has a fix which preserves flow control, I am not going to merge your patch.
Stefan
Dear, Stefan Hajnoczi,
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)
10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh
Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000
03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500)
10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus
POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000
03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500)
10.0.2.2 > 10.0.2.15: udp
03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)
10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh
Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000
03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500)
10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus
POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000
03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500)
10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit 199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100
net: fix qemu_flush_queued_packets() in presence of a hub
And then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)
10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh
Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000
04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500)
10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus
POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000
04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500)
10.0.2.2 > 10.0.2.15: udp
04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240)
10.0.2.2 > 10.0.2.15: udpSo there must be something wrong with already applied patch. What could you suggest?
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 67 lines · Fedorov Sergey
Quoted 13 lines · Stefan Hajnoczi
Quoted 6 lines · Fedorov Sergey
Quoted 3 lines
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No,
net_hub_receive()callsqemu_send_packet(). If the destination queue cannot receive the packetqemu_net_queue_append()will take care ofqueue->nq_maxlen.You are right, sorry. We do discard packets at
nq_maxlen.The problem with ignoring .can_receive() on the hub is that it breaks flow control. For example,
net/tap.cis designed to avoid reading more packets if its peer cannot receive (seetap_can_send()).Quoted 9 lines
If the hub claims it can always receive we waste cycles reading packets from the tap device only to discard them.
Since qemu.git already has a fix which preserves flow control, I am not going to merge your patch.
Stefan
Dear, Stefan Hajnoczi,
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164) 10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubAnd then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240) 10.0.2.2 > 10.0.2.15: udp
Quoted 2 lines
So there must be something wrong with already applied patch. What could you suggest?
Sorry, I missed that Anthony Liguori email address has been changed. So I resend the email.
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 69 lines · Fedorov Sergey
Quoted 67 lines · Fedorov Sergey
Quoted 13 lines · Stefan Hajnoczi
Quoted 6 lines · Fedorov Sergey
Quoted 3 lines
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
No,
net_hub_receive()callsqemu_send_packet(). If the destination queue cannot receive the packetqemu_net_queue_append()will take care ofqueue->nq_maxlen.You are right, sorry. We do discard packets at
nq_maxlen.The problem with ignoring .can_receive() on the hub is that it breaks flow control. For example,
net/tap.cis designed to avoid reading more packets if its peer cannot receive (seetap_can_send()).Quoted 9 lines
If the hub claims it can always receive we waste cycles reading packets from the tap device only to discard them.
Since qemu.git already has a fix which preserves flow control, I am not going to merge your patch.
Stefan
Dear, Stefan Hajnoczi,
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164) 10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubAnd then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240) 10.0.2.2 > 10.0.2.15: udp
Quoted 5 lines
Quoted 2 lines
So there must be something wrong with already applied patch. What could you suggest?
Sorry, I missed that Anthony Liguori email address has been changed. So I resend the email.
Ping.
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 58 lines · Fedorov Sergey
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164) 10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubAnd then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240) 10.0.2.2 > 10.0.2.15: udp
Quoted 2 lines
So there must be something wrong with already applied patch. What could you suggest?
The next step is to investigate the cause.
Perhaps hw/usb/dev-network.c:usb_net_handle_datain() is not calling qemu_flush_queued_packets() every time in_buf[] is read completely. This if statement looks strange to me:
if (s->in_ptr >= s->in_len &&
(is_rndis(s) || (s->in_len & (64 - 1)) || !len)) {
/* no short packet necessary */
usb_net_reset_in_buf(s);
}Try placing printfs to find out whether qemu_flush_queued_packets() is getting called when you see packet loss.
Stefan
Quoted 73 lines · Stefan Hajnoczi
Quoted 58 lines · Fedorov Sergey
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164) 10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubAnd then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240) 10.0.2.2 > 10.0.2.15: udpQuoted 2 lines
So there must be something wrong with already applied patch. What could you suggest?
The next step is to investigate the cause.
Perhaps hw/usb/dev-network.c:usb_net_handle_datain() is not calling
qemu_flush_queued_packets()every time in_buf[] is read completely. This if statement looks strange to me:if (
s->in_ptr>=s->in_len&&(is_rndis(s) || (s->in_len & (64 - 1)) || !len)) { /* no short packet necessary */ usb_net_reset_in_buf(s); }
Quoted 5 lines
Try placing printfs to find out whether
qemu_flush_queued_packets()is getting called when you see packet loss.Stefan
Seems that I have figured out the problem. net_hub_flush() does not flush source port. And qemu_flush_queued_packets() also returns after calling net_hub_flush(). So I think the problem is that neither qemu_flush_queued_packets() nor net_hub_flush() call qemu_net_queue_flush() for the source port. So I think it sould be fixed in qemu_flush_queued_packets() by removing the return statement after calling net_hub_flush(). That fix does work for me. So I could submit that patch after getting permission for that.
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 80 lines · Fedorov Sergey
Quoted 73 lines · Stefan Hajnoczi
Quoted 58 lines · Fedorov Sergey
After our discussion about this patch I decided to keep my patch in our branch until rebase onto a new release. Recently I have rebased our branch onto v1.5.3 and reverted my patch. Then I face an issue when using user-mode networking with USB network device for mounting root file system through NFS. Fragmented UDP packets from host to guest does not handled properly. Seems that some fragments is lost or somehow stalled. See guest tcpdump log below.
03:16:52.259690 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:52.262323 IP (tos 0x0, ttl 64, id 16, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:52.264592 IP (tos 0x0, ttl 64, id 16, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 03:16:54.462961 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164) 10.0.2.15.3369105030 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 03:16:54.466300 IP (tos 0x0, ttl 64, id 17, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3369105030: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 03:16:54.467084 IP (tos 0x0, ttl 64, id 17, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp...
I didn't investigate the cause of the problem in detail. I just reverted
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4Author: Luigi Rizzo <[email protected]> Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubAnd then applied my patch. After that everything works fine for me. See guest tcpdump log below.
04:45:15.897245 IP (tos
0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 164)10.0.2.15.3642011847 > 10.0.2.2.nfs: 136 readdirplus fh Unknown/0100070004001200000000002873593C9B3C43388E23748B0BAD870C00000000 512 bytes @ 0 max 4096 verf 0000000000000000 04:45:15.899686 IP (tos 0x0, ttl 64, id 15, offset 0, flags [+], proto UDP (17), length 1500) 10.0.2.2.nfs > 10.0.2.15.3642011847: reply ok 1472 readdirplus POST: DIR 40777 ids 0/0 sz 4096 verf 0000000000000000 04:45:15.906253 IP (tos 0x0, ttl 64, id 15, offset 1480, flags [+], proto UDP (17), length 1500) 10.0.2.2 > 10.0.2.15: udp 04:45:15.906687 IP (tos 0x0, ttl 64, id 15, offset 2960, flags [none], proto UDP (17), length 240) 10.0.2.2 > 10.0.2.15: udpQuoted 2 lines
So there must be something wrong with already applied patch. What could you suggest?
The next step is to investigate the cause.
Perhaps hw/usb/dev-network.c:usb_net_handle_datain() is not calling
qemu_flush_queued_packets()every time in_buf[] is read completely. This if statement looks strange to me:if (
s->in_ptr>=s->in_len&&(is_rndis(s) || (s->in_len & (64 - 1)) || !len)) { /* no short packet necessary */ usb_net_reset_in_buf(s); }Quoted 5 lines
Try placing printfs to find out whether
qemu_flush_queued_packets()is getting called when you see packet loss.Stefan
Quoted 8 lines
Seems that I have figured out the problem.
net_hub_flush()does not flush source port. Andqemu_flush_queued_packets()also returns after callingnet_hub_flush(). So I think the problem is that neitherqemu_flush_queued_packets()nornet_hub_flush()callqemu_net_queue_flush()for the source port. So I think it sould be fixed inqemu_flush_queued_packets()by removing the return statement after callingnet_hub_flush(). That fix does work for me. So I could submit that patch after getting permission for that.
Sounds good to me.
I have CCed Luigi in case he wants to comment.
Stefan
Quoted 71 lines · Stefan Hajnoczi
Quoted 61 lines · Fedorov Sergey
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the
qemu_send_packet()do the right things.Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.
Quoted 5 lines
Did you mean "second port" instead of "source port" in the beginning?
I don't see a scenario where the packet is delivered to the same port twice. If one port can receive then the packet will be sent and other ports will queue the packet.
Whether dump network client can always receive? If so, then the packet will always be sent to the dump client regardless of whether the other clients can receive. Is there actually any synchronization?
Quoted 13 lines
Note that the source port will not queue
the packet. When the blocked ports can receive again their send queues will be flushed.Paolo mentioned that we want to provide a consistent view of packets, especially when -net dump is used.
Beyond that, we also want to avoid growing net queues indefinitely. If the hub does not implement .can_receive() then it relies on growing queues (keeping packets buffered in memory).
Stefan
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]
Quoted 75 lines · Fedorov Sergey
Quoted 73 lines · Stefan Hajnoczi
Quoted 61 lines · Fedorov Sergey
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the
qemu_send_packet()do the right things.Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.Did you mean "second port" instead of "source port" in the beginning?
Quoted 7 lines
Quoted 3 lines
I don't see a scenario where the packet is delivered to the same port twice. If one port can receive then the packet will be sent and other ports will queue the packet.
Whether dump network client can always receive? If so, then the packet will always be sent to the dump client regardless of whether the other clients can receive. Is there actually any synchronization?
Yes, the dump net client can always receive. Other net clients may not.
There is no explicit synchronization between send queues on the hub.
Stefan
Quoted 82 lines · Stefan Hajnoczi
Quoted 74 lines · Fedorov Sergey
Quoted 73 lines · Stefan Hajnoczi
Quoted 61 lines · Fedorov Sergey
Quoted 49 lines · Stefan Hajnoczi
Quoted 38 lines · Fedorov Sergey
Quoted 12 lines · Stefan Hajnoczi
Quoted 11 lines · Sergey Fedorov
Network hub should always receive incoming packets. Then forward them to the appropriate port queue and let the
qemu_send_packet()do the right things. If the destination queue cannot receive the packet it will be appended to the queue. When the receiver callqemu_flush_queued_packets()later the queue will be really flushed and no packets will be stalled in the sender network queue.Signed-off-by Sergey Fedorov <[email protected]>--- net/hub.c | 20 -------------------- 1 file changed, 20 deletions(-)Quoted 8 lines
What is the point of this change? There is no semantic difference for well-behaved net clients.
Does it fix a bug, if so, please include details?
Stefan
Yes, this fixes a bug. There were packet stalls when using user-mode networking with USB network device.
slirp_output()callsqemu_send_packet()which eventually callsqemu_net_queue_send().qemu_net_queue_send()callsqemu_can_send_packet(), which callscan_receive()callback of network hub. Thennet_hub_port_can_receive()also callsqemu_can_send_packet()for each port except packet source port.Sometimes USB network device is not able to receive packet and
qemu_can_send_packet()returns false. In my case there is no more ports andnet_hub_port_can_receive()returns false. Soqemu_net_queue_send()callqemu_net_queue_append()instead ofqemu_net_queue_deliver().qemu_net_queue_append()appends the packet to the receiving port of the network hub which is not flushed when USB netork device callsqemu_flush_queued_packets(). It is flushed only when slirp resend the packet by timeout.Quoted 7 lines
Actually there is no need in
net_hub_port_can_receive()as the network hub can always receive packets and pass it to its port network clients withqemu_send_packet(). And if the destination port network client cannot receive the packet it will be queued in the *destination* port network client queue. Queued packets from that queue will be delivered as soon as the network client callqemu_flush_queued_packets().Please confirm the bug is still present in qemu.git/master. It should have been fixed by the following commit:
Quoted 8 lines
commit
199ee608f0d08510b5c6c37f31a7fbff211d63c4
Author: Luigi Rizzo <[email protected]>
Date: Tue Feb 5 17:53:31 2013 +0100net: fix
qemu_flush_queued_packets()in presence of a hubStefan
Yes, this commit fixes a bug but from other side. I think it's better to just let the
qemu_send_packet()do the right things.Quoted 9 lines
E.g. network hub has 3 ports. Suppose when iterating through port list in
net_hub_port_can_receive()a packet is successfully delivered to the first port, and then is queued in the source port queue because the second port cannot receive packets. Laternet_hub_flush()will flush the packet from the source port queue and it will be delivered in every port. But it had been already delivered to one of them. So it will be delivered twice to some ports. Moreover there is less chance to dequeue the packet if several clients can't receive periodically.Did you mean "second port" instead of "source port" in the beginning?
Quoted 7 lines
Quoted 3 lines
I don't see a scenario where the packet is delivered to the same port twice. If one port can receive then the packet will be sent and other ports will queue the packet.
Whether dump network client can always receive? If so, then the packet will always be sent to the dump client regardless of whether the other clients can receive. Is there actually any synchronization?
Quoted 6 lines
Yes, the dump net client can always receive. Other net clients may not.
There is no explicit synchronization between send queues on the hub.
Stefan
So why don't we apply this patch?
Signature · 4 lines
Best regards, Sergey Fedorov, Junior Software Engineer, Samsung R&D Institute Rus. E-mail: [email protected]