net: etherdevice: add address inherit helper
authorBjørn Mork <bjorn@mork.no>
Fri, 30 Aug 2013 16:08:44 +0000 (18:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Sep 2013 00:57:49 +0000 (20:57 -0400)
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>
include/linux/etherdevice.h

index c623861..d8b5124 100644 (file)
@@ -198,6 +198,21 @@ static inline void eth_hw_addr_random(struct net_device *dev)
        eth_random_addr(dev->dev_addr);
 }
 
+/**
+ * eth_hw_addr_inherit - Copy dev_addr from another net_device
+ * @dst: pointer to net_device to copy dev_addr to
+ * @src: pointer to net_device to copy dev_addr from
+ *
+ * Copy the Ethernet address from one net_device to another along with
+ * the address attributes (addr_assign_type).
+ */
+static inline void eth_hw_addr_inherit(struct net_device *dst,
+                                      struct net_device *src)
+{
+       dst->addr_assign_type = src->addr_assign_type;
+       memcpy(dst->dev_addr, src->dev_addr, ETH_ALEN);
+}
+
 /**
  * compare_ether_addr - Compare two Ethernet addresses
  * @addr1: Pointer to a six-byte array containing the Ethernet address