virtio_net: allow to change mac when iface is running
Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e9976d7c96
commit
d4fc6918f4
1 changed files with 5 additions and 4 deletions
|
@ -679,11 +679,12 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
|
||||||
{
|
{
|
||||||
struct virtnet_info *vi = netdev_priv(dev);
|
struct virtnet_info *vi = netdev_priv(dev);
|
||||||
struct virtio_device *vdev = vi->vdev;
|
struct virtio_device *vdev = vi->vdev;
|
||||||
int ret;
|
struct sockaddr *addr = p;
|
||||||
|
|
||||||
ret = eth_mac_addr(dev, p);
|
if (!is_valid_ether_addr(addr->sa_data))
|
||||||
if (ret)
|
return -EADDRNOTAVAIL;
|
||||||
return ret;
|
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
|
||||||
|
dev->addr_assign_type &= ~NET_ADDR_RANDOM;
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
|
if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
|
||||||
vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
|
vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
|
||||||
|
|
Loading…
Add table
Reference in a new issue