diff options
author | Michael Walle | 2019-08-27 10:13:52 +0200 |
---|---|---|
committer | Joe Hershberger | 2019-09-04 11:37:19 -0500 |
commit | 12c2a310e87d4eacfd669346338e856cb3ad54c2 (patch) | |
tree | 5d9962b295fb126a6ebed0d04d67c61f7c3daecc /include | |
parent | 5ccd657b6d6cdf2378b98f6b71a2a5a22d8f4d50 (diff) |
net: make net_random_ethaddr() more random
The net_random_ethaddr() tries to get some entropy from different
startup times of a board. The seed is initialized with get_timer() which
has only a granularity of milliseconds. We can do better if we use
get_ticks() which returns the raw timer ticks. Using this we have a
higher chance of getting different values at startup.
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/net.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net.h b/include/net.h index a54d5eeac5f..75a16e4c8f8 100644 --- a/include/net.h +++ b/include/net.h @@ -816,7 +816,7 @@ static inline int is_valid_ethaddr(const u8 *addr) static inline void net_random_ethaddr(uchar *addr) { int i; - unsigned int seed = get_timer(0); + unsigned int seed = get_ticks(); for (i = 0; i < 6; i++) addr[i] = rand_r(&seed); |