提交 61407f80 编写于 作者: A Andi Kleen 提交者: David S. Miller

[NET]: srandom32 fixes for networking v2

- Let it update the state of all CPUs. The network stack goes
into pains to feed the current IP addresses in, but it is not very
effective if that is only done for some random CPU instead of all.
So change it to feed bits into all CPUs.  I decided to do that lockless 
because well somewhat random results are ok.

v2: Drop rename so that this patch doesn't depend on x86 maintainers
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 84f59370
...@@ -97,13 +97,18 @@ EXPORT_SYMBOL(random32); ...@@ -97,13 +97,18 @@ EXPORT_SYMBOL(random32);
* @seed: seed value * @seed: seed value
* *
* Add some additional seeding to the random32() pool. * Add some additional seeding to the random32() pool.
* Note: this pool is per cpu so it only affects current CPU.
*/ */
void srandom32(u32 entropy) void srandom32(u32 entropy)
{ {
struct rnd_state *state = &get_cpu_var(net_rand_state); int i;
__set_random32(state, state->s1 ^ entropy); /*
put_cpu_var(state); * No locking on the CPUs, but then somewhat random results are, well,
* expected.
*/
for_each_possible_cpu (i) {
struct rnd_state *state = &per_cpu(net_rand_state, i);
__set_random32(state, state->s1 ^ entropy);
}
} }
EXPORT_SYMBOL(srandom32); EXPORT_SYMBOL(srandom32);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册