Skip to content

Commit 948b337

Browse files
jpirkodavem330
authored andcommitted
net: init perm_addr in register_netdevice()
Benefit from the fact that dev->addr_assign_type is set to NET_ADDR_PERM in case the device has permanent address. This also fixes the problem that many drivers do not set perm_addr at all. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7265a6b commit 948b337

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎net/core/dev.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6004,6 +6004,13 @@ int register_netdevice(struct net_device *dev)
60046004
list_netdevice(dev);
60056005
add_device_randomness(dev->dev_addr, dev->addr_len);
60066006

6007+
/* If the device has permanent device address, driver should
6008+
* set dev_addr and also addr_assign_type should be set to
6009+
* NET_ADDR_PERM (default value).
6010+
*/
6011+
if (dev->addr_assign_type == NET_ADDR_PERM)
6012+
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
6013+
60076014
/* Notify protocols, that a new device appeared. */
60086015
ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
60096016
ret = notifier_to_errno(ret);

0 commit comments

Comments
 (0)