]> git.proxmox.com Git - qemu.git/blobdiff - net.c
net: return status from qemu_deliver_packet()
[qemu.git] / net.c
diff --git a/net.c b/net.c
index 8403120750a6a2f4b7fb48055438a8f32bc94dc3..e48b0fe5e788e98b947262890959ba9921592429 100644 (file)
--- a/net.c
+++ b/net.c
@@ -409,16 +409,30 @@ int qemu_can_send_packet(VLANClientState *sender)
     return 0;
 }
 
-static void
+static int
 qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)
 {
     VLANClientState *vc;
+    int ret = -1;
 
     for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
-        if (vc != sender && !vc->link_down) {
-            vc->receive(vc, buf, size);
+        ssize_t len;
+
+        if (vc == sender) {
+            continue;
+        }
+
+        if (vc->link_down) {
+            ret = size;
+            continue;
         }
+
+        len = vc->receive(vc, buf, size);
+
+        ret = (ret >= 0) ? ret : len;
     }
+
+    return ret;
 }
 
 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size)