From patchwork Wed Apr 22 14:56:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 19384 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3MEuq01019556 for ; Wed, 22 Apr 2009 14:56:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbZDVO4v (ORCPT ); Wed, 22 Apr 2009 10:56:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752151AbZDVO4v (ORCPT ); Wed, 22 Apr 2009 10:56:51 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49683 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbZDVO4u (ORCPT ); Wed, 22 Apr 2009 10:56:50 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3MEunLd030290 for ; Wed, 22 Apr 2009 10:56:49 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3MEulaJ003085; Wed, 22 Apr 2009 10:56:48 -0400 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3MEuk2W011827; Wed, 22 Apr 2009 10:56:46 -0400 Subject: kvm: qemu: net: drop packet from tap device if all NICs are down From: Mark McLoughlin Reply-To: Mark McLoughlin To: Avi Kivity Cc: kvm , Yan Vugenfirer Date: Wed, 22 Apr 2009 15:56:34 +0100 Message-Id: <1240412194.7661.22.camel@blaa> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Signed-off-by: Mark McLoughlin --- qemu/net.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) 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; }