From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43485 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DAw-0007fH-Sw for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0DAv-0002b1-L7 for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57753) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0DAv-0002ax-DY for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:21 -0400 From: Jason Wang Date: Mon, 27 Sep 2010 20:51:09 +0800 Message-ID: <20100927125109.12060.19145.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH 3/4] virtio-net: Limit the num of uni/multicast mac addresses List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, anthony@codemonkey.ws, mst@redhat.com Cc: kvm@vger.kernel.org In order to send gratuitous packet for each mac address, we need to keep track every macaddress after migration which is obviously conflicted with the overload policy currently used in qemu which just forward all packets to guest when it can't record all the macaddress. So we need to limit the num of uni/multicast mac addresses in qemu. Signed-off-by: Jason Wang --- hw/virtio-net.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 0a9cae2..79afb65 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -291,7 +291,9 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd, mac_data.entries * ETH_ALEN); n->mac_table.in_use += mac_data.entries; } else { - n->mac_table.uni_overflow = 1; + /* Gratuitous packet could not be built properly in overflow mode, so we + * never allow uni_overflow here. */ + return VIRTIO_NET_ERR; } n->mac_table.first_multi = n->mac_table.in_use; @@ -309,7 +311,9 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd, mac_data.entries * ETH_ALEN); n->mac_table.in_use += mac_data.entries; } else { - n->mac_table.multi_overflow = 1; + /* Gratuitous packet could not be built properly in overflow mode, + * so we never allow multi_overflow here. */ + return VIRTIO_NET_ERR; } } @@ -844,9 +848,8 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) qemu_get_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN); } else if (n->mac_table.in_use) { - qemu_fseek(f, n->mac_table.in_use * ETH_ALEN, SEEK_CUR); - n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1; - n->mac_table.in_use = 0; + error_report("virtio-net: Overflow was not permitted."); + return -EINVAL; } } @@ -873,6 +876,10 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) if (version_id >= 9) { n->mac_table.multi_overflow = qemu_get_byte(f); n->mac_table.uni_overflow = qemu_get_byte(f); + if (n->mac_table.multi_overflow || n->mac_table.uni_overflow) { + error_report("virtio-net: Overflow was not permitted"); + return -EINVAL; + } } if (version_id >= 10) {