diff mbox

[11/17] net: drop packet from tap device if all NICs are down

Message ID 1242574999-20887-12-git-send-email-aliguori@us.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony Liguori May 17, 2009, 3:43 p.m. UTC
From: Mark McLoughlin <markmc@redhat.com>

If you do e.g. "set_link virtio.0 down" and there are packets
pending on the tap interface, we currently buffer a packet
and constantly try and send it until the link is up again.

We actually just want to drop the packet if the NIC is down.
Upstream qemu already does this, we just differ because we
buffer packets from the tap interface.

[aliguori: rebased this patch on stable.  Mark, please review and Ack]

Reported-by: Yan Vugenfirer <yvugenfi@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Comments

Mark McLoughlin May 19, 2009, 5:52 p.m. UTC | #1
On Sun, 2009-05-17 at 10:43 -0500, Anthony Liguori wrote:
> From: Mark McLoughlin <markmc@redhat.com>
> 
> If you do e.g. "set_link virtio.0 down" and there are packets
> pending on the tap interface, we currently buffer a packet
> and constantly try and send it until the link is up again.
> 
> We actually just want to drop the packet if the NIC is down.
> Upstream qemu already does this, we just differ because we
> buffer packets from the tap interface.
> 
> [aliguori: rebased this patch on stable.  Mark, please review and Ack]
> 
> Reported-by: Yan Vugenfirer <yvugenfi@redhat.com>
> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Looks good to me.

Cheers,
Mark.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net.c b/net.c
index d8fb759..ef3a965 100644
--- a/net.c
+++ b/net.c
@@ -414,8 +414,10 @@  int qemu_send_packet(VLANClientState *vc1, const uint8_t *buf, int size)
     hex_dump(stdout, buf, size);
 #endif
     for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
-        if (vc != vc1 && !vc->link_down) {
-            if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
+        if (vc != vc1) {
+            if (vc->link_down) {
+                ret = 0;
+            } else  if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
                 vc->fd_read(vc->opaque, buf, size);
                 ret = 0;
             }