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)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Oct 2012 21:41:20 +0000 (23:41 +0200)
commit 7bf2357524408b97fec58344caf7397f8140c3fd upstream.

Cc: David Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/core/dev.c
net/core/rtnetlink.c

index 84a0705920b69102d12d6d951eff4be2df73f171..46e2a29b5df3cc062fa8b05c835efc061a0e9786 100644 (file)
@@ -1133,6 +1133,7 @@ int dev_open(struct net_device *dev)
                /*
                 *      ... and announce new interface.
                 */
+               add_device_randomness(dev->dev_addr, dev->addr_len);
                call_netdevice_notifiers(NETDEV_UP, dev);
        }
 
@@ -4268,6 +4269,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);
@@ -4871,6 +4873,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 d4fd895e8712b59df367033f20d13047f7dcc5d1..9d700421df0e7f214811a8edff0743a7213f7bc9 100644 (file)
@@ -817,6 +817,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]) {