Skip to content

Commit

Permalink
net: Get mac address from driver as seed
Browse files Browse the repository at this point in the history
Previously seeded by obtaining mac addr from env. If mac addr was
never set, rand would output 0. This fix obtains the mac addr
from driver instead.

Signed-off-by: Jimmy Du <[email protected]>
Acked-by: Joe Hershberger <[email protected]>
  • Loading branch information
Jimmy Du authored and jhershbe committed Aug 7, 2017
1 parent 8f0b169 commit b044cc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/net_rand.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
static inline unsigned int seed_mac(void)
{
unsigned char enetaddr[6];
unsigned char enetaddr[ARP_HLEN];
unsigned int seed;

/* get our mac */
eth_getenv_enetaddr("ethaddr", enetaddr);
memcpy(enetaddr, eth_get_ethaddr(), ARP_HLEN);

seed = enetaddr[5];
seed ^= enetaddr[4] << 8;
Expand Down

0 comments on commit b044cc1

Please sign in to comment.