From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk6yv-0005Ue-8K for qemu-devel@nongnu.org; Wed, 05 Jun 2013 02:14:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uk6ys-00042Z-TQ for qemu-devel@nongnu.org; Wed, 05 Jun 2013 02:14:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk6ys-00042P-KC for qemu-devel@nongnu.org; Wed, 05 Jun 2013 02:13:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r556DvOu032703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Jun 2013 02:13:58 -0400 From: Amos Kong Date: Wed, 5 Jun 2013 14:13:48 +0800 Message-Id: <1370412828-15960-1-git-send-email-akong@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, mst@redhat.com The MAX_VLAN is 4096, currently the vlan filter table has 512 (4096 >> 3) entries, it's wrong. One entry in vlan filter table can indicate 32(1 << 5) vlans, so the table should have 128 (4096 >> 5) entries. Signed-off-by: Amos Kong --- btw, it would be simple to use an uint32 number to indicate all vlans (same as igbvf). I found e1000 uses the same table. Nothing needs to change here, it would cause migration issue. --- hw/net/virtio-net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index d4ef21f..6dedb97 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -293,7 +293,7 @@ static void virtio_net_reset(VirtIODevice *vdev) n->mac_table.uni_overflow = 0; memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN); memcpy(&n->mac[0], &n->nic->conf->macaddr, sizeof(n->mac)); - memset(n->vlans, 0, MAX_VLAN >> 3); + memset(n->vlans, 0, MAX_VLAN >> 5); } static void peer_test_vnet_hdr(VirtIONet *n) @@ -1246,7 +1246,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque) qemu_put_byte(f, n->allmulti); qemu_put_be32(f, n->mac_table.in_use); qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN); - qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); + qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 5); qemu_put_be32(f, n->has_vnet_hdr); qemu_put_byte(f, n->mac_table.multi_overflow); qemu_put_byte(f, n->mac_table.uni_overflow); @@ -1316,7 +1316,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) } if (version_id >= 6) - qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); + qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 5); if (version_id >= 7) { if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) { -- 1.8.1.4