Skip to content

Commit 83a093b

Browse files
bmorkdavem330
authored andcommitted
net: etherdevice: add address inherit helper
Some etherdevices inherit their address from a parent or master device. The addr_assign_type should be updated along with the address in these cases. Adding a helper function to simplify this. Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5a17a39 commit 83a093b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎include/linux/etherdevice.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ static inline void eth_hw_addr_random(struct net_device *dev)
198198
eth_random_addr(dev->dev_addr);
199199
}
200200

201+
/**
202+
* eth_hw_addr_inherit - Copy dev_addr from another net_device
203+
* @dst: pointer to net_device to copy dev_addr to
204+
* @src: pointer to net_device to copy dev_addr from
205+
*
206+
* Copy the Ethernet address from one net_device to another along with
207+
* the address attributes (addr_assign_type).
208+
*/
209+
static inline void eth_hw_addr_inherit(struct net_device *dst,
210+
struct net_device *src)
211+
{
212+
dst->addr_assign_type = src->addr_assign_type;
213+
memcpy(dst->dev_addr, src->dev_addr, ETH_ALEN);
214+
}
215+
201216
/**
202217
* compare_ether_addr - Compare two Ethernet addresses
203218
* @addr1: Pointer to a six-byte array containing the Ethernet address

0 commit comments

Comments
 (0)