[U-Boot] [PATCH 1/2] net: Remove call of srand from eth_random_enetaddr()

Wolfgang Denk wd at denx.de
Wed Jan 9 09:47:31 CET 2013


Dear Christian Riesch,

In message <CABkLObrL2BhKmjh9NCcv1UQ-cbfJisUidK8JoE8DSAOEkqiZ1g at mail.gmail.com> you wrote:
>
> > I don't like this change.  What exactly is wrong with using the timer
> > here?   It is probably much more random that the (so-called)
> > "un-initialized" memory you suggest to use instead.
> 
> On the AM1808 SoC the counter is reset to zero on power up. So using it to
> generate random numbers in code that is called interactively by the user is
> fine and will yield a random MAC address, but in my case I will get the
> same MAC address on each board at each power up.

I think the whole concept of using random MAC adresses is broken.  You
should consider thinking about fixing the root cause of your problem.

> > If there is really need to use another inital valu, only this should
> > be fixed - but the srand() call itself should remain as is.
>
> For other boards it may be ok to use a counter, and for some there may be
> no SRAM or it may be already overwritten, e.g by the SPL... Therefore I am
> not changing this for all boards, but make it board specific.

I don't want to see any board specific code here.  If using the timer
is not good enough, then pass a weak funtion as argument to srand()
which defaults to using the timer as we do now, and which can be
redefined in board specific code.

Other than this, the common code should not be changed.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The main thing is the play itself. I swear that greed for  money  has
nothing  to  do with it, although heaven knows I am sorely in need of
money.                                           - Feodor Dostoyevsky


More information about the U-Boot mailing list