peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0190-net-add-receive_disabled-logic-to-iov-delivery-path.patch

5544c1
From eccdc01e744cf3a389a527406f4d529420133e89 Mon Sep 17 00:00:00 2001
5544c1
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1
Date: Fri, 17 Aug 2012 21:16:42 +0100
5544c1
Subject: [PATCH] net: add receive_disabled logic to iov delivery path
5544c1
5544c1
This patch adds the missing NetClient->receive_disabled logic in the
5544c1
sendv delivery code path.  It seems that commit
5544c1
893379efd0e1b84ceb0c42a713293f3dbd27b1bd ("net: disable receiving if
5544c1
client returns zero") only added the logic to qemu_deliver_packet() and
5544c1
not qemu_deliver_packet_iov().
5544c1
5544c1
The receive_disabled flag should be automatically set when .receive(),
5544c1
.receive_raw(), or .receive_iov() return 0.  No further packets will be
5544c1
delivered to the NetClient until the receive_disabled flag is cleared
5544c1
again by calling qemu_flush_queued_packets().
5544c1
5544c1
Typically the NetClient will wait until its file descriptor becomes
5544c1
writable and then invoke qemu_flush_queued_packets() to resume
5544c1
transmission.
5544c1
5544c1
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1
(cherry picked from commit c67f5dc10573687497f0f5c3aec19b15c35c63d7)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 net.c | 15 +++++++++++++--
5544c1
 1 file changed, 13 insertions(+), 2 deletions(-)
5544c1
5544c1
diff --git a/net.c b/net.c
5544c1
index 76a8336..1303819 100644
5544c1
--- a/net.c
5544c1
+++ b/net.c
5544c1
@@ -423,16 +423,27 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
5544c1
                                 void *opaque)
5544c1
 {
5544c1
     NetClientState *nc = opaque;
5544c1
+    int ret;
5544c1
 
5544c1
     if (nc->link_down) {
5544c1
         return iov_size(iov, iovcnt);
5544c1
     }
5544c1
 
5544c1
+    if (nc->receive_disabled) {
5544c1
+        return 0;
5544c1
+    }
5544c1
+
5544c1
     if (nc->info->receive_iov) {
5544c1
-        return nc->info->receive_iov(nc, iov, iovcnt);
5544c1
+        ret = nc->info->receive_iov(nc, iov, iovcnt);
5544c1
     } else {
5544c1
-        return nc_sendv_compat(nc, iov, iovcnt);
5544c1
+        ret = nc_sendv_compat(nc, iov, iovcnt);
5544c1
     }
5544c1
+
5544c1
+    if (ret == 0) {
5544c1
+        nc->receive_disabled = 1;
5544c1
+    }
5544c1
+
5544c1
+    return ret;
5544c1
 }
5544c1
 
5544c1
 ssize_t qemu_sendv_packet_async(NetClientState *sender,
5544c1
-- 
5544c1
1.7.12.1
5544c1