diff mbox

[RFC,v6,15/20] virtio-net: no writeable mac for virtio-1

Message ID 1418304322-7546-16-git-send-email-cornelia.huck@de.ibm.com
State New
Headers show

Commit Message

Cornelia Huck Dec. 11, 2014, 1:25 p.m. UTC
Devices operating as virtio 1.0 may not allow writes to the mac
address in config space.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/net/virtio-net.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Stefan Hajnoczi Jan. 20, 2015, 11:19 a.m. UTC | #1
On Thu, Dec 11, 2014 at 02:25:17PM +0100, Cornelia Huck wrote:
> Devices operating as virtio 1.0 may not allow writes to the mac
> address in config space.
> 
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  hw/net/virtio-net.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index d6d1b98..ebbea60 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -87,6 +87,7 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
>      memcpy(&netcfg, config, n->config_size);
>  
>      if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) &&

I don't see VIRTIO_NET_F_CTRL_MAC_ADDR (23) in the VIRTIO 1.0 "5.1.3.1
Legacy Interface: Feature bits" section.  Should it be there just so
people don't try to reuse bit 23 in the future?

The patch itself:
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Cornelia Huck Jan. 22, 2015, 4:31 p.m. UTC | #2
On Tue, 20 Jan 2015 11:19:47 +0000
Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Thu, Dec 11, 2014 at 02:25:17PM +0100, Cornelia Huck wrote:
> > Devices operating as virtio 1.0 may not allow writes to the mac
> > address in config space.
> > 
> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > ---
> >  hw/net/virtio-net.c |    1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index d6d1b98..ebbea60 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -87,6 +87,7 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
> >      memcpy(&netcfg, config, n->config_size);
> >  
> >      if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) &&
> 
> I don't see VIRTIO_NET_F_CTRL_MAC_ADDR (23) in the VIRTIO 1.0 "5.1.3.1
> Legacy Interface: Feature bits" section.  Should it be there just so
> people don't try to reuse bit 23 in the future?

But this isn't a legacy flag. Virtio-1 devices simply may not
manipulate the mac address directly even if this feature has not been
negotiated.

> 
> The patch itself:
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index d6d1b98..ebbea60 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -87,6 +87,7 @@  static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
     memcpy(&netcfg, config, n->config_size);
 
     if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) &&
+        !virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
         memcmp(netcfg.mac, n->mac, ETH_ALEN)) {
         memcpy(n->mac, netcfg.mac, ETH_ALEN);
         qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);