* [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table
@ 2013-06-05 6:13 Amos Kong
2013-06-05 7:21 ` Amos Kong
2013-06-05 11:38 ` Stefan Hajnoczi
0 siblings, 2 replies; 4+ messages in thread
From: Amos Kong @ 2013-06-05 6:13 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.williamson, mst
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 <akong@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table
2013-06-05 6:13 [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table Amos Kong
@ 2013-06-05 7:21 ` Amos Kong
2013-06-05 8:56 ` Amos Kong
2013-06-05 11:38 ` Stefan Hajnoczi
1 sibling, 1 reply; 4+ messages in thread
From: Amos Kong @ 2013-06-05 7:21 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.williamson, mst
On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
> 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 <akong@redhat.com>
> ---
This patch breaks the migration.
> 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.
The comment is wrong, igbvf also uses an array.
Will post a v2 with migration fix.
> ---
> hw/net/virtio-net.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
--
Amos.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table
2013-06-05 7:21 ` Amos Kong
@ 2013-06-05 8:56 ` Amos Kong
0 siblings, 0 replies; 4+ messages in thread
From: Amos Kong @ 2013-06-05 8:56 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.williamson, mst
On Wed, Jun 05, 2013 at 03:21:30PM +0800, Amos Kong wrote:
> On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
> > 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.
The patch is wrong, one entry takes 4 bytes. Sorry for the noise.
--
Amos.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table
2013-06-05 6:13 [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table Amos Kong
2013-06-05 7:21 ` Amos Kong
@ 2013-06-05 11:38 ` Stefan Hajnoczi
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-06-05 11:38 UTC (permalink / raw)
To: Amos Kong; +Cc: alex.williamson, qemu-devel, mst
On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
> 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 <akong@redhat.com>
> ---
> 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(-)
I don't understand this patch. memset() and qemu_put_buffer() work in
bytes, therefore MAX_VLAN >> 3.
MAX_VLAN >> 3 == MAX_VLAN / BITS_PER_BYTE
MAX_VLAN >> 5 == MAX_VLAN / (sizeof(uint32_t) * BITS_PER_BYTE)
What bug are you trying to fix?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-05 11:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 6:13 [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table Amos Kong
2013-06-05 7:21 ` Amos Kong
2013-06-05 8:56 ` Amos Kong
2013-06-05 11:38 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).