From patchwork Mon Sep 27 12:51:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 65841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB9E7B70D3 for ; Mon, 27 Sep 2010 22:56:53 +1000 (EST) Received: from localhost ([127.0.0.1]:37242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DGE-0002EC-Rv for incoming@patchwork.ozlabs.org; Mon, 27 Sep 2010 08:56:50 -0400 Received: from [140.186.70.92] (port=43518 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DB4-0007j5-M8 for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0DB3-0002cV-I6 for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61434) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0DB3-0002cM-8u for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:29 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8RCpRIS030782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Sep 2010 08:51:27 -0400 Received: from dhcp-91-7.nay.redhat.com.englab.nay.redhat.com (dhcp-91-7.nay.redhat.com [10.66.91.7]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8RCpPTv007768; Mon, 27 Sep 2010 08:51:25 -0400 To: qemu-devel@nongnu.org, anthony@codemonkey.ws, mst@redhat.com From: Jason Wang Date: Mon, 27 Sep 2010 20:51:17 +0800 Message-ID: <20100927125117.12060.55442.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> In-Reply-To: <20100927124606.12060.66912.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> References: <20100927124606.12060.66912.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [RFC PATCH 4/4] virtio-net: implement virtio-net specific announce function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch tries to announce every mac address for one virtio nic after migration. The primary mac address is announced unconditionally and other macaddress are only announced when no vlan is configurated in guest. For guest with vlan, what we need do is to send tagged gratutious packet, but current virtio-net implementation can not distinguish the mapping between mac addresses and vlan. And I believe this function must be implemented with the modifications of guest drivers ( vlan_dev_info ). Signed-off-by: Jason Wang --- hw/virtio-net.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 79afb65..0b47ac2 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -922,6 +922,35 @@ static void virtio_net_cleanup(VLANClientState *nc) n->nic = NULL; } +static void virtio_net_announce(VLANClientState *nc) +{ + uint8_t buf[60]; + bool has_vlan = false; + int len; + int i; + VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque; + + len = announce_self_create(buf, &n->mac[0]); + qemu_send_packet_raw(nc, buf, len); + + for (i = 0; i < (MAX_VLAN >> 5); i++) { + if (n->vlans[i] & ~0u) { + has_vlan = true; + break; + } + } + + if (!has_vlan) { + /* It's safe to announce the rest of mac addresses when there's no vlan + * in guest */ + for (i = 0; i < n->mac_table.in_use; i++) { + mac_debug(&n->mac_table.macs[i * ETH_ALEN]); + len = announce_self_create(buf, &n->mac_table.macs[i * ETH_ALEN]); + qemu_send_packet_raw(nc, buf, len); + } + } +} + static NetClientInfo net_virtio_info = { .type = NET_CLIENT_TYPE_NIC, .size = sizeof(NICState), @@ -929,6 +958,7 @@ static NetClientInfo net_virtio_info = { .receive = virtio_net_receive, .cleanup = virtio_net_cleanup, .link_status_changed = virtio_net_set_link_status, + .announce = virtio_net_announce, }; static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)