kohler / click

The Click modular router: fast modular packet processing and analysis
Other
748 stars 321 forks source link

Glue: Use /dev/urandom instead of /dev/random #332

Closed justuswilhelm closed 7 years ago

justuswilhelm commented 7 years ago

This will resolve issues with slow random sources (e.g., in virtual machines)

tbarbette commented 7 years ago

Shouldn't we generate randomness completely in userlevel? Seems crazy to rely on read to generate random numbers.

kohler commented 7 years ago

@justuswilhelm: Thanks, great catch.

@tbarbette: Read up on /dev/urandom — it's usually the right answer https://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/

We should probably have a cryptographic random number generator at userlevel, but for this purpose (initializing the non-cryptographic click_random() generator to a less-than-totally-predictable value) a single read from /dev/urandom is fine.

justuswilhelm commented 7 years ago

@kohler: Thanks so much!

tbarbette commented 7 years ago

@kohler what method would you recommend for this userlevel replacement? Does the following seems good :

We may want a per-cpu seed to avoid false sharing. Or we may want to use a hardware generator (eg. through DPDK support for Intel QuickAssist). So it seems like it should be a user-configurable "method".

This could also be followed for other features based on system calls, such as the click_jiffies (UserJiffies would rely on a Timer to update a jiffie count).

Advantage is that it is fully configurable, disadvantage is that all Click userlevel configurations would always have the same set of Elements in their config such as UserCryptoMP;UserJiffiesMP;...