* [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random
@ 2019-08-27 8:13 Michael Walle
2019-08-27 8:40 ` Bin Meng
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Walle @ 2019-08-27 8:13 UTC (permalink / raw)
To: u-boot
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>
---
since v1:
- Removed the and-mask. Since there were no more comments I did some tests
and apparently there are no compiler warnings.
include/net.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net.h b/include/net.h
index a54d5eeac5..75a16e4c8f 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);
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random
2019-08-27 8:13 [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random Michael Walle
@ 2019-08-27 8:40 ` Bin Meng
2019-09-03 21:44 ` Joe Hershberger
2019-09-04 16:41 ` [U-Boot] " Joe Hershberger
2 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2019-08-27 8:40 UTC (permalink / raw)
To: u-boot
On Tue, Aug 27, 2019 at 4:14 PM Michael Walle <michael@walle.cc> wrote:
>
> 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>
> ---
> since v1:
> - Removed the and-mask. Since there were no more comments I did some tests
> and apparently there are no compiler warnings.
>
> include/net.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random
2019-08-27 8:13 [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random Michael Walle
2019-08-27 8:40 ` Bin Meng
@ 2019-09-03 21:44 ` Joe Hershberger
2019-09-04 16:41 ` [U-Boot] " Joe Hershberger
2 siblings, 0 replies; 4+ messages in thread
From: Joe Hershberger @ 2019-09-03 21:44 UTC (permalink / raw)
To: u-boot
On Tue, Aug 27, 2019 at 3:14 AM Michael Walle <michael@walle.cc> wrote:
>
> 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>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] net: make net_random_ethaddr() more random
2019-08-27 8:13 [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random Michael Walle
2019-08-27 8:40 ` Bin Meng
2019-09-03 21:44 ` Joe Hershberger
@ 2019-09-04 16:41 ` Joe Hershberger
2 siblings, 0 replies; 4+ messages in thread
From: Joe Hershberger @ 2019-09-04 16:41 UTC (permalink / raw)
To: u-boot
Hi Michael,
https://patchwork.ozlabs.org/patch/1153632/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-04 16:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 8:13 [U-Boot] [PATCH v2] net: make net_random_ethaddr() more random Michael Walle
2019-08-27 8:40 ` Bin Meng
2019-09-03 21:44 ` Joe Hershberger
2019-09-04 16:41 ` [U-Boot] " Joe Hershberger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.