diff options
author | Eric Dumazet <edumazet@google.com> | 2013-04-29 05:58:52 +0000 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2016-03-11 15:56:45 +0100 |
commit | efb52c489da12819daa2ea89115bbf84c7f42884 (patch) | |
tree | f6275f4cfd35534ef9e3d66ab4eb0eef0655d764 /net | |
parent | 2ab8afb3e51a9feab437da37a85c5a38ba56e109 (diff) | |
download | kernel_samsung_espresso10-efb52c489da12819daa2ea89115bbf84c7f42884.zip kernel_samsung_espresso10-efb52c489da12819daa2ea89115bbf84c7f42884.tar.gz kernel_samsung_espresso10-efb52c489da12819daa2ea89115bbf84c7f42884.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.c | 4 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 5 |
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 be3d56a..25b2b70 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); |