aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/af_inet.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index e225a4e5b572..9cbcb94a4c6d 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -248,8 +248,12 @@ EXPORT_SYMBOL(inet_listen);
248u32 inet_ehash_secret __read_mostly; 248u32 inet_ehash_secret __read_mostly;
249EXPORT_SYMBOL(inet_ehash_secret); 249EXPORT_SYMBOL(inet_ehash_secret);
250 250
251u32 ipv6_hash_secret __read_mostly;
252EXPORT_SYMBOL(ipv6_hash_secret);
253
251/* 254/*
252 * inet_ehash_secret must be set exactly once 255 * inet_ehash_secret must be set exactly once, and to a non nul value
256 * ipv6_hash_secret must be set exactly once.
253 */ 257 */
254void build_ehash_secret(void) 258void build_ehash_secret(void)
255{ 259{
@@ -259,7 +263,8 @@ void build_ehash_secret(void)
259 get_random_bytes(&rnd, sizeof(rnd)); 263 get_random_bytes(&rnd, sizeof(rnd));
260 } while (rnd == 0); 264 } while (rnd == 0);
261 265
262 cmpxchg(&inet_ehash_secret, 0, rnd); 266 if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
267 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
263} 268}
264EXPORT_SYMBOL(build_ehash_secret); 269EXPORT_SYMBOL(build_ehash_secret);
265 270