etherdevice: introduce help function eth_zero_addr()
authorDuan Jiong <djduanjiong@gmail.com>
Sat, 8 Sep 2012 16:32:28 +0000 (16:32 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 22 Aug 2016 21:37:17 +0000 (22:37 +0100)
commit 6d57e9078e880a3dd232d579f42ac437a8f1ef7b upstream.

a lot of code has either the memset or an inefficient copy
from a static array that contains the all-zeros Ethernet address.
Introduce help function eth_zero_addr() to fill an address with
all zeros, making the code clearer and allowing us to get rid of
some constant arrays.

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/linux/etherdevice.h

index 05955cf..4d29153 100644 (file)
@@ -139,6 +139,17 @@ static inline void random_ether_addr(u8 *addr)
        addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
 }
 
+/**
+ * eth_zero_addr - Assign zero address
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Assign the zero address to the given address array.
+ */
+static inline void eth_zero_addr(u8 *addr)
+{
+       memset(addr, 0x00, ETH_ALEN);
+}
+
 /**
  * dev_hw_addr_random - Create random MAC and set device flag
  * @dev: pointer to net_device structure