@@ -121,9 +121,26 @@ static inline int is_valid_ether_addr(const u8 *addr)
*/
static inline void random_ether_addr(u8 *addr)
{
- get_random_bytes (addr, ETH_ALEN);
- addr [0] &= 0xfe; /* clear multicast bit */
- addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
+ u32 val;
+
+ /* not calling get_random_bytes to avoid using entropy */
+ do {
+ val = random32();
+ addr[0] = val;
+ } while (addr[0] < 4);
+ addr[0] &= 0xfe; /* clear multicast bit */
+ addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
+
+ val >>= 8;
+ addr[1] = val;
+ val >>= 8;
+ addr[2] = val;
+ val >>= 8;
+ addr[3] = val;
+ val = random32();
+ addr[4] = val;
+ val >>= 8;
+ addr[5] = val;
}
/**
Perhaps this is slightly better, it doesn't call random32 for each octet and makes sure the leading octet is >= 0x04. random_ether_address should assign a leading octet >= "0x04" Does not use get_random_bytes to avoid drawing down entropy pool. Signed-off-by: Joe Perches <joe@perches.com> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html