I'm reading the source code of the Linux(version 3.10)Ethernet drivers. There is one important structure net_device in the Kernel Netwoking.
Inside "struct net_device", there are two variables naming dev_addr and perm_addr indicating the mac address of NIC. However, some vendor driver set both of dev_addr and perm_addr while some set dev_addr only.
Though in the header file, it is commented as:
unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
/* Interface address info used in eth_type_trans() */
unsigned char *dev_addr; /* hw address, (before bcast
because most packets are
unicast) */
Still I can't get the difference between them.
Thanks to skrrgwasme, also I found in the kernel file net/core/dev.c reigster_netdev() function that :
/* If the device has permanent device address, driver should
* set dev_addr and also addr_assign_type should be set to
* NET_ADDR_PERM (default value).
*/
if (dev->addr_assign_type == NET_ADDR_PERM)
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
So this variable is seldom used in NIC driver.
The perm_addr
field is populated if the device has a permanent MAC address assigned to it. This will usually come from some EEPROM or other read-only memory on the physical device.
The dev_addr
field is the currently assigned MAC address, which can be changed by software.