qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net: add receive_disabled logic to iov delivery path
@ 2012-08-20 13:21 Stefan Hajnoczi
  2012-08-29 15:36 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-08-20 13:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Hajnoczi

This patch adds the missing NetClient->receive_disabled logic in the
sendv delivery code path.  It seems that commit
893379efd0e1b84ceb0c42a713293f3dbd27b1bd ("net: disable receiving if
client returns zero") only added the logic to qemu_deliver_packet() and
not qemu_deliver_packet_iov().

The receive_disabled flag should be automatically set when .receive(),
.receive_raw(), or .receive_iov() return 0.  No further packets will be
delivered to the NetClient until the receive_disabled flag is cleared
again by calling qemu_flush_queued_packets().

Typically the NetClient will wait until its file descriptor becomes
writable and then invoke qemu_flush_queued_packets() to resume
transmission.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 net.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/net.c b/net.c
index 60043dd..efeec61 100644
--- a/net.c
+++ b/net.c
@@ -418,16 +418,27 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
                                 void *opaque)
 {
     NetClientState *nc = opaque;
+    int ret;
 
     if (nc->link_down) {
         return iov_size(iov, iovcnt);
     }
 
+    if (nc->receive_disabled) {
+        return 0;
+    }
+
     if (nc->info->receive_iov) {
-        return nc->info->receive_iov(nc, iov, iovcnt);
+        ret = nc->info->receive_iov(nc, iov, iovcnt);
     } else {
-        return nc_sendv_compat(nc, iov, iovcnt);
+        ret = nc_sendv_compat(nc, iov, iovcnt);
     }
+
+    if (ret == 0) {
+        nc->receive_disabled = 1;
+    }
+
+    return ret;
 }
 
 ssize_t qemu_sendv_packet_async(NetClientState *sender,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] net: add receive_disabled logic to iov delivery path
  2012-08-20 13:21 [Qemu-devel] [PATCH] net: add receive_disabled logic to iov delivery path Stefan Hajnoczi
@ 2012-08-29 15:36 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-08-29 15:36 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

On Mon, Aug 20, 2012 at 02:21:53PM +0100, Stefan Hajnoczi wrote:
> This patch adds the missing NetClient->receive_disabled logic in the
> sendv delivery code path.  It seems that commit
> 893379efd0e1b84ceb0c42a713293f3dbd27b1bd ("net: disable receiving if
> client returns zero") only added the logic to qemu_deliver_packet() and
> not qemu_deliver_packet_iov().
> 
> The receive_disabled flag should be automatically set when .receive(),
> .receive_raw(), or .receive_iov() return 0.  No further packets will be
> delivered to the NetClient until the receive_disabled flag is cleared
> again by calling qemu_flush_queued_packets().
> 
> Typically the NetClient will wait until its file descriptor becomes
> writable and then invoke qemu_flush_queued_packets() to resume
> transmission.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
>  net.c |   15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)

Applied to the net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-29 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20 13:21 [Qemu-devel] [PATCH] net: add receive_disabled logic to iov delivery path Stefan Hajnoczi
2012-08-29 15:36 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).