diff mbox

kvm: qemu: net: drop packet from tap device if all NICs are down

Message ID 1240412194.7661.22.camel@blaa (mailing list archive)
State New, archived
Headers show

Commit Message

Mark McLoughlin April 22, 2009, 2:56 p.m. UTC
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.

Reported-by: Yan Vugenfirer <yvugenfi@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 qemu/net.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Avi Kivity April 23, 2009, 3:24 p.m. UTC | #1
Mark McLoughlin wrote:
> 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.
>
>   

Applied, thanks.
diff mbox

Patch

diff --git a/qemu/net.c b/qemu/net.c
index 9c199d6..201d282 100644
--- a/qemu/net.c
+++ b/qemu/net.c
@@ -412,8 +412,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;
             }