
Currently eth_random_enetaddr() seeds the random number generator with get_timer(0). Some boards might want to use other sources for the seed, therefore move the call of srand() to the board specific code.
Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Michael Walle michael@walle.cc Cc: Joe Hershberger joe.hershberger@gmail.com --- board/buffalo/lsxl/lsxl.c | 1 + include/net.h | 3 +++ net/eth.c | 2 -- 3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c index 57776fb..b7eb0dc 100644 --- a/board/buffalo/lsxl/lsxl.c +++ b/board/buffalo/lsxl/lsxl.c @@ -248,6 +248,7 @@ static void rescue_mode(void) printf("Entering rescue mode..\n"); #ifdef CONFIG_RANDOM_MACADDR if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { + srand(get_timer(0)); eth_random_enetaddr(enetaddr); if (eth_setenv_enetaddr("ethaddr", enetaddr)) { printf("Failed to set ethernet address\n"); diff --git a/include/net.h b/include/net.h index 970d4d1..5fc3693 100644 --- a/include/net.h +++ b/include/net.h @@ -141,6 +141,9 @@ extern int eth_getenv_enetaddr_by_index(const char *base_name, int index, * * In these cases, we generate a random locally administered ethernet address. * + * Remember to seed the random number generator with srand() before calling + * this functon. + * * Args: * enetaddr - returns 6 byte hardware address */ diff --git a/net/eth.c b/net/eth.c index 321d5b1..dc4cc20 100644 --- a/net/eth.c +++ b/net/eth.c @@ -84,8 +84,6 @@ void eth_random_enetaddr(uchar *enetaddr) { uint32_t rval;
- srand(get_timer(0)); - rval = rand(); enetaddr[0] = rval & 0xff; enetaddr[1] = (rval >> 8) & 0xff;