diff options
author | Andi Kleen <ak@suse.de> | 2008-04-03 17:07:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-03 17:07:02 -0400 |
commit | 61407f80f72970d52d4339f81c6c3cd03f4ca0f0 (patch) | |
tree | 2063040e6e16d5dcc1024c3aedee23195f38b1ba | |
parent | 84f59370c519449c70dcc813b050f5cbbf0098e7 (diff) |
[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: Andi Kleen <ak@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | lib/random32.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/random32.c b/lib/random32.c index ec7f81d3fb18..ca87d86992bd 100644 --- a/lib/random32.c +++ b/lib/random32.c | |||
@@ -97,13 +97,18 @@ EXPORT_SYMBOL(random32); | |||
97 | * @seed: seed value | 97 | * @seed: seed value |
98 | * | 98 | * |
99 | * Add some additional seeding to the random32() pool. | 99 | * Add some additional seeding to the random32() pool. |
100 | * Note: this pool is per cpu so it only affects current CPU. | ||
101 | */ | 100 | */ |
102 | void srandom32(u32 entropy) | 101 | void srandom32(u32 entropy) |
103 | { | 102 | { |
104 | struct rnd_state *state = &get_cpu_var(net_rand_state); | 103 | int i; |
105 | __set_random32(state, state->s1 ^ entropy); | 104 | /* |
106 | put_cpu_var(state); | 105 | * No locking on the CPUs, but then somewhat random results are, well, |
106 | * expected. | ||
107 | */ | ||
108 | for_each_possible_cpu (i) { | ||
109 | struct rnd_state *state = &per_cpu(net_rand_state, i); | ||
110 | __set_random32(state, state->s1 ^ entropy); | ||
111 | } | ||
107 | } | 112 | } |
108 | EXPORT_SYMBOL(srandom32); | 113 | EXPORT_SYMBOL(srandom32); |
109 | 114 | ||