mopsfelder / rpms / qemu

Forked from rpms/qemu 4 years ago
Clone
fa00e1e
From 7e8d33b027316936a7659007117b644b65bc01dd Mon Sep 17 00:00:00 2001
5544c1b
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1b
Date: Fri, 24 Aug 2012 13:50:30 +0100
5544c1b
Subject: [PATCH] net: broadcast hub packets if at least one port can receive
5544c1b
5544c1b
In commit 60c07d933c66c4b30a83b7ccbc8a0cb3df1b2d0e ("net: fix
5544c1b
qemu_can_send_packet logic") the "VLAN" broadcast behavior was changed
5544c1b
to queue packets if any net client cannot receive.  It turns out that
5544c1b
this was not actually the right fix and just hides the real bug that
5544c1b
hw/usb/dev-network.c:usbnet_receive() clobbers its receive buffer when
5544c1b
called multiple times in a row.  The commit also introduced a new bug
5544c1b
that "VLAN" packets would not be sent if one of multiple net clients was
5544c1b
down.
5544c1b
5544c1b
The hw/usb/dev-network.c bug has since been fixed, so this patch reverts
5544c1b
broadcast behavior to send packets as long as one net client can
5544c1b
receive.  Packets simply get queued for the net clients that are
5544c1b
temporarily unable to receive.
5544c1b
5544c1b
Reported-by: Roy.Li <rongqing.li@windriver.com>
5544c1b
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1b
(cherry picked from commit 61518a74ca98870e8ff132f91dd5dda252e31f58)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 net/hub.c | 6 +++---
5544c1b
 1 file changed, 3 insertions(+), 3 deletions(-)
5544c1b
5544c1b
diff --git a/net/hub.c b/net/hub.c
5544c1b
index ac157e3..650a8b4 100644
5544c1b
--- a/net/hub.c
5544c1b
+++ b/net/hub.c
5544c1b
@@ -97,12 +97,12 @@ static int net_hub_port_can_receive(NetClientState *nc)
5544c1b
             continue;
5544c1b
         }
5544c1b
 
5544c1b
-        if (!qemu_can_send_packet(&port->nc)) {
5544c1b
-            return 0;
5544c1b
+        if (qemu_can_send_packet(&port->nc)) {
5544c1b
+            return 1;
5544c1b
         }
5544c1b
     }
5544c1b
 
5544c1b
-    return 1;
5544c1b
+    return 0;
5544c1b
 }
5544c1b
 
5544c1b
 static ssize_t net_hub_port_receive(NetClientState *nc,