aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2013-04-29 05:58:52 +0000
committerZiyann <jaraidaniel@gmail.com>2014-11-26 22:39:16 +0100
commit2d2d8554aac4e33d368afafda7875d98a50b653c (patch)
treef67d37ea256eb22daccfb357531b85b58e15e89b /net
parentc803831c2cd079ace467fb5108fe931067329a03 (diff)
downloadkernel_samsung_tuna-2d2d8554aac4e33d368afafda7875d98a50b653c.zip
kernel_samsung_tuna-2d2d8554aac4e33d368afafda7875d98a50b653c.tar.gz
kernel_samsung_tuna-2d2d8554aac4e33d368afafda7875d98a50b653c.tar.bz2
net: defer net_secret[] initialization
Instead of feeding net_secret[] at boot time, defer the init at the point first socket is created. This permits some platforms to use better entropy sources than the ones available at boot time. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/secure_seq.c4
-rw-r--r--net/ipv4/af_inet.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
index 45329d7..72c94be 100644
--- a/net/core/secure_seq.c
+++ b/net/core/secure_seq.c
@@ -12,12 +12,10 @@
static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
-static int __init net_secret_init(void)
+void net_secret_init(void)
{
get_random_bytes(net_secret, sizeof(net_secret));
- return 0;
}
-late_initcall(net_secret_init);
static u32 seq_scale(u32 seq)
{
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ba78b76..5fc9368 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -114,6 +114,7 @@
#include <net/inet_common.h>
#include <net/xfrm.h>
#include <net/net_namespace.h>
+#include <net/secure_seq.h>
#ifdef CONFIG_IP_MROUTE
#include <linux/mroute.h>
#endif
@@ -254,8 +255,10 @@ void build_ehash_secret(void)
get_random_bytes(&rnd, sizeof(rnd));
} while (rnd == 0);
- if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
+ if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
+ net_secret_init();
+ }
}
EXPORT_SYMBOL(build_ehash_secret);