From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: [PATCH 11/17] net: drop packet from tap device if all NICs are down Date: Sun, 17 May 2009 10:43:13 -0500 Message-ID: <1242574999-20887-13-git-send-email-aliguori@us.ibm.com> References: <1242574999-20887-1-git-send-email-aliguori@us.ibm.com> Cc: Glauber Costa , Mark McLoughlin , Avi Kivity , Anthony Liguori To: kvm@vger.kernel.org Return-path: Received: from e1.ny.us.ibm.com ([32.97.182.141]:40336 "EHLO e1.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754674AbZEQPnj (ORCPT ); Sun, 17 May 2009 11:43:39 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e1.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4HFdnQf026515 for ; Sun, 17 May 2009 11:39:49 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4HFhene249586 for ; Sun, 17 May 2009 11:43:40 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4HFfeDT030511 for ; Sun, 17 May 2009 11:41:40 -0400 In-Reply-To: <1242574999-20887-1-git-send-email-aliguori@us.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Mark McLoughlin 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] Reported-by: Yan Vugenfirer Signed-off-by: Mark McLoughlin Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori 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; } -- 1.6.0.6