]> git.proxmox.com Git - mirror_qemu.git/commitdiff
net: vlan clients with no fd_can_read() can always receive
authorMark McLoughlin <markmc@redhat.com>
Wed, 29 Apr 2009 08:36:43 +0000 (09:36 +0100)
committerMark McLoughlin <markmc@redhat.com>
Tue, 9 Jun 2009 10:38:49 +0000 (11:38 +0100)
If a vlan client has no fd_can_read(), that means it can
always receive packets. The current code assumes it can *never*
receive packets.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
net.c

diff --git a/net.c b/net.c
index 443f769a03fa79f28fb3cf5fe6dddb3802f2b233..0d9e5203014a87286008af8aac74698583433821 100644 (file)
--- a/net.c
+++ b/net.c
@@ -389,15 +389,19 @@ VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque)
     return NULL;
 }
 
-int qemu_can_send_packet(VLANClientState *vc1)
+int qemu_can_send_packet(VLANClientState *sender)
 {
-    VLANState *vlan = vc1->vlan;
+    VLANState *vlan = sender->vlan;
     VLANClientState *vc;
 
-    for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
-        if (vc != vc1) {
-            if (vc->fd_can_read && vc->fd_can_read(vc->opaque))
-                return 1;
+    for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
+        if (vc == sender) {
+            continue;
+        }
+
+        /* no fd_can_read() handler, they can always receive */
+        if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
+            return 1;
         }
     }
     return 0;