--- zzzz-none-000/linux-2.6.39.4/include/linux/etherdevice.h 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/include/linux/etherdevice.h 2021-11-10 13:23:10.000000000 +0000 @@ -138,7 +138,26 @@ addr [0] &= 0xfe; /* clear multicast bit */ addr [0] |= 0x02; /* set local assignment bit (IEEE802) */ } - + static inline void eth_random_addr(u8 *addr) + { + get_random_bytes(addr, ETH_ALEN); + addr[0] &= 0xfe; /* clear multicast bit */ + addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ + } +/** + * eth_hw_addr_random - Generate software assigned random Ethernet and + * set device flag + * @dev: pointer to net_device structure + * + * Generate a random Ethernet address (MAC) to be used by a net device + * and set addr_assign_type so the state can be read by sysfs and be + * used by userspace. + */ + static inline void eth_hw_addr_random(struct net_device *dev) + { + dev->addr_assign_type |= NET_ADDR_RANDOM; + eth_random_addr(dev->dev_addr); + } /** * dev_hw_addr_random - Create random MAC and set device flag * @dev: pointer to net_device structure @@ -169,6 +188,18 @@ return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; } +/** + * ether_addr_equal - Compare two Ethernet addresses + * @addr1: Pointer to a six-byte array containing the Ethernet address + * @addr2: Pointer other six-byte array containing the Ethernet address + * + * Compare two ethernet addresses, returns true if equal + */ +static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) +{ + return !compare_ether_addr(addr1, addr2); +} + static inline unsigned long zap_last_2bytes(unsigned long value) { #ifdef __BIG_ENDIAN