Commit 322f326e authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Ben Hutchings

net: feed /dev/random with the MAC address when registering a device

commit 7bf23575 upstream.

Cc: David Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 4e28e08b
...@@ -1177,6 +1177,7 @@ static int __dev_open(struct net_device *dev) ...@@ -1177,6 +1177,7 @@ static int __dev_open(struct net_device *dev)
net_dmaengine_get(); net_dmaengine_get();
dev_set_rx_mode(dev); dev_set_rx_mode(dev);
dev_activate(dev); dev_activate(dev);
add_device_randomness(dev->dev_addr, dev->addr_len);
} }
return ret; return ret;
...@@ -4841,6 +4842,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) ...@@ -4841,6 +4842,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
err = ops->ndo_set_mac_address(dev, sa); err = ops->ndo_set_mac_address(dev, sa);
if (!err) if (!err)
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
add_device_randomness(dev->dev_addr, dev->addr_len);
return err; return err;
} }
EXPORT_SYMBOL(dev_set_mac_address); EXPORT_SYMBOL(dev_set_mac_address);
...@@ -5621,6 +5623,7 @@ int register_netdevice(struct net_device *dev) ...@@ -5621,6 +5623,7 @@ int register_netdevice(struct net_device *dev)
dev_init_scheduler(dev); dev_init_scheduler(dev);
dev_hold(dev); dev_hold(dev);
list_netdevice(dev); list_netdevice(dev);
add_device_randomness(dev->dev_addr, dev->addr_len);
/* Notify protocols, that a new device appeared. */ /* Notify protocols, that a new device appeared. */
ret = call_netdevice_notifiers(NETDEV_REGISTER, dev); ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
......
...@@ -1354,6 +1354,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, ...@@ -1354,6 +1354,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
goto errout; goto errout;
send_addr_notify = 1; send_addr_notify = 1;
modified = 1; modified = 1;
add_device_randomness(dev->dev_addr, dev->addr_len);
} }
if (tb[IFLA_MTU]) { if (tb[IFLA_MTU]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment