Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Pirko and committed by
David S. Miller
948b337e 7265a6bb

+7
+7
net/core/dev.c
··· 6004 6004 list_netdevice(dev); 6005 6005 add_device_randomness(dev->dev_addr, dev->addr_len); 6006 6006 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 + 6007 6014 /* Notify protocols, that a new device appeared. */ 6008 6015 ret = call_netdevice_notifiers(NETDEV_REGISTER, dev); 6009 6016 ret = notifier_to_errno(ret);