net: feed /dev/random with the MAC address when registering a device
authorTheodore Ts'o <tytso@mit.edu>
Thu, 5 Jul 2012 01:23:25 +0000 (21:23 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 15 Jul 2012 00:17:46 +0000 (20:17 -0400)
Cc: David Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
net/core/dev.c
net/core/rtnetlink.c

index 6df214041a5e5bfe85b948b41ce56e15af514860..bdd1e88f60d3dd4cfa47c70047c398a5c9cb0b01 100644 (file)
@@ -1172,6 +1172,7 @@ static int __dev_open(struct net_device *dev)
                net_dmaengine_get();
                dev_set_rx_mode(dev);
                dev_activate(dev);
+               add_device_randomness(dev->dev_addr, dev->addr_len);
        }
 
        return ret;
@@ -4763,6 +4764,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
        err = ops->ndo_set_mac_address(dev, sa);
        if (!err)
                call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
+       add_device_randomness(dev->dev_addr, dev->addr_len);
        return err;
 }
 EXPORT_SYMBOL(dev_set_mac_address);
@@ -5541,6 +5543,7 @@ int register_netdevice(struct net_device *dev)
        dev_init_scheduler(dev);
        dev_hold(dev);
        list_netdevice(dev);
+       add_device_randomness(dev->dev_addr, dev->addr_len);
 
        /* Notify protocols, that a new device appeared. */
        ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
index 21318d15bbc3c1578bd2650282de9b6ddde7ae23..f058e599d858435e2736be7b3fc23582f03b2f3f 100644 (file)
@@ -1378,6 +1378,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
                        goto errout;
                send_addr_notify = 1;
                modified = 1;
+               add_device_randomness(dev->dev_addr, dev->addr_len);
        }
 
        if (tb[IFLA_MTU]) {