Skip to content

Commit

Permalink
virtio_net: Set the mac config only when VIRITO_NET_F_MAC
Browse files Browse the repository at this point in the history
VIRTIO_NET_F_MAC indicates the presence of the mac field in config
space, not the validity of the value it contains.  Allow the mac to be
changed at runtime, but only push the change into config space with the
VIRTIO_NET_F_MAC feature present.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alex Williamson authored and David S. Miller committed Apr 4, 2009
1 parent cd36e9e commit 62994b2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,9 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
if (ret)
return ret;

vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
dev->dev_addr, dev->addr_len);
if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
dev->dev_addr, dev->addr_len);

return 0;
}
Expand Down Expand Up @@ -876,11 +877,8 @@ static int virtnet_probe(struct virtio_device *vdev)
vdev->config->get(vdev,
offsetof(struct virtio_net_config, mac),
dev->dev_addr, dev->addr_len);
} else {
} else
random_ether_addr(dev->dev_addr);
vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
dev->dev_addr, dev->addr_len);
}

/* Set up our device-specific information */
vi = netdev_priv(dev);
Expand Down

0 comments on commit 62994b2

Please sign in to comment.