Patchwork virtio-net: revert mac on reset

login
register
mail settings
Submitter Michael S. Tsirkin
Date Jan. 16, 2013, 11:45 a.m.
Message ID <20130116114521.GA20630@redhat.com>
Download mbox | patch
Permalink /patch/212493/
State New
Headers show

Comments

Michael S. Tsirkin - Jan. 16, 2013, 11:45 a.m.
Once guest overrides virtio net primary mac,
it retains the value set until qemu exit.
This is inconsistent with standard nic behaviour.
To fix, revert the mac to the original value on reset.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)
Stefan Hajnoczi - Jan. 16, 2013, 1:29 p.m.
On Wed, Jan 16, 2013 at 01:45:21PM +0200, Michael S. Tsirkin wrote:
> Once guest overrides virtio net primary mac,
> it retains the value set until qemu exit.
> This is inconsistent with standard nic behaviour.
> To fix, revert the mac to the original value on reset.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/virtio-net.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Laszlo Ersek - Jan. 16, 2013, 1:44 p.m.
On 01/16/13 12:45, Michael S. Tsirkin wrote:
> Once guest overrides virtio net primary mac,
> it retains the value set until qemu exit.
> This is inconsistent with standard nic behaviour.
> To fix, revert the mac to the original value on reset.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/virtio-net.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 3bb01b1..4d80a25 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -199,6 +199,7 @@ static void virtio_net_reset(VirtIODevice *vdev)
>      n->mac_table.multi_overflow = 0;
>      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);
>  }
>  

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3bb01b1..4d80a25 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -199,6 +199,7 @@  static void virtio_net_reset(VirtIODevice *vdev)
     n->mac_table.multi_overflow = 0;
     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);
 }