[U-Boot] Generating random numbers

Albert ARIBAUD albert.u.boot at aribaud.net
Tue Aug 30 23:48:41 CEST 2011


Le 30/08/2011 22:10, elison.niven at gmail.com a écrit :
> On Wed, Aug 31, 2011 at 1:25 AM, Wolfgang Denk<wd at denx.de>  wrote:
>
>> Dear "elison.niven at gmail.com",
>>
>> In message<CAAO=
>> tyeYTt4M+54y_qovCK7vdQy_ssOktRdjbPF8+Pq0-YcCzQ at mail.gmail.com>  you wrote:
>>>
>>> I am trying to random my mac in u-boot on AT91RM9200 and AT91SAM9G45
>>> processor.
>>
>> This approach is inherently wrong, and I'm actually happy if you
>> find it difficult to implement.  Otherwise we would probably have
>> rejected your code when you submit the patches.
>>
>> MAC addresses are supposed to be NOT random. Please see the related
>> FAQ, for example
>> http://www.denx.de/wiki/view/DULG/WhereCanIGetAValidMACAddress
>>
>> Hi,
> I do realize that. The "random" MAC address is not forever. It is only to
> get the "actual" MAC in the first boot so as to not set the environment
> variables manually.

If it is only until the environment provides the MAC, then I suspect the 
"random MAC" will never ever be used in a single packet, right? But 
then, what's the point of setting it if it won't be used at all? Simply 
set the real MAC once you have it.

(from your other reply)

> Why does arch/blackfin/include/asm/net.h have bfin_gen_rand_mac ?

Just because some code in U-Boot appears to wrongly use random MACs does 
not *make* it wrong, and does not make the use you intend right either.. :)

In the Blackfin case, just as in the the Marvell GBE driver case, a 
random MAC is generated only if the actual MAC is *not* in the 
environment -- a case that should not happen in normal cicumstances.

The blackfin use case is "if the environment does not contain a MAC, 
then as a degenerate case we provide a private (random) MAC so that the 
U-Boot can still use the network" -- a resilience case for a degenerate 
situation.

This differs from your use case which apparently is "use a random MAC so 
that with some yet-undefined mechanism we can ask for a real MAC because 
we don't want to set the real MAC in the environment" -- to me it looks 
not like a degenerate case but a nominal use case.

Now I may have misunderstood your case, of course. Feel free to provide 
more context.

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list