[dpdk-dev] [RFC] eal: make rte_rand() MT safe

Mattias Rönnblom mattias.ronnblom at ericsson.com
Fri Apr 5 20:04:28 CEST 2019


On 2019-04-05 18:57, Stephen Hemminger wrote:
> 
> rand48 is a terrible PRNG, why not use something better?
> 
> Similar discussion in Linux kernel pointed at:
> http://www.pcg-random.org/posts/some-prng-implementations.html
> 
> Mail thread here:
> https://www.spinics.net/lists/netdev/msg560231.html
> 

DPDK was already using lrand48(), I primarily wanted to address 
lrand48()'s lack of MT safety, nothing else.

That said, maybe the easiest way to maintain the current API, provide MT 
safety and have something portable is for DPDK to carry its own random 
number generator, instead of relying on libc.

Maybe an ARC4 port from BSD? But instead of pulling entropy from the 
kernel, let the user give the seed, like the current DPDK APIs permit.

You could deprecate rte_srand(), but I would vote against such a move, 
because its sometimes useful to able to have something that is "random", 
yet reproducible.


More information about the dev mailing list