virtio_net: allow to change mac when iface is running
authorJiri Pirko <jpirko@redhat.com>
Wed, 27 Jun 2012 05:27:46 +0000 (05:27 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Jun 2012 04:25:58 +0000 (21:25 -0700)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index f18149ae2588e682e661100f026f7bcf60a16d06..36a16d581f7184ed578e21541dd75720ef7491ff 100644 (file)
@@ -679,11 +679,12 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
 {
        struct virtnet_info *vi = netdev_priv(dev);
        struct virtio_device *vdev = vi->vdev;
-       int ret;
+       struct sockaddr *addr = p;
 
-       ret = eth_mac_addr(dev, p);
-       if (ret)
-               return ret;
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+       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))
                vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),