diff options
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f011390f19c9..b7b7278d801c 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -87,6 +87,7 @@ | |||
87 | #include <linux/init.h> | 87 | #include <linux/init.h> |
88 | #include <linux/poll.h> | 88 | #include <linux/poll.h> |
89 | #include <linux/netfilter_ipv4.h> | 89 | #include <linux/netfilter_ipv4.h> |
90 | #include <linux/random.h> | ||
90 | 91 | ||
91 | #include <asm/uaccess.h> | 92 | #include <asm/uaccess.h> |
92 | #include <asm/system.h> | 93 | #include <asm/system.h> |
@@ -217,6 +218,16 @@ out: | |||
217 | return err; | 218 | return err; |
218 | } | 219 | } |
219 | 220 | ||
221 | u32 inet_ehash_secret; | ||
222 | EXPORT_SYMBOL(inet_ehash_secret); | ||
223 | |||
224 | void build_ehash_secret(void) | ||
225 | { | ||
226 | while (!inet_ehash_secret) | ||
227 | get_random_bytes(&inet_ehash_secret, 4); | ||
228 | } | ||
229 | EXPORT_SYMBOL(build_ehash_secret); | ||
230 | |||
220 | /* | 231 | /* |
221 | * Create an inet socket. | 232 | * Create an inet socket. |
222 | */ | 233 | */ |
@@ -233,6 +244,11 @@ static int inet_create(struct socket *sock, int protocol) | |||
233 | int try_loading_module = 0; | 244 | int try_loading_module = 0; |
234 | int err; | 245 | int err; |
235 | 246 | ||
247 | if (sock->type != SOCK_RAW && | ||
248 | sock->type != SOCK_DGRAM && | ||
249 | !inet_ehash_secret) | ||
250 | build_ehash_secret(); | ||
251 | |||
236 | sock->state = SS_UNCONNECTED; | 252 | sock->state = SS_UNCONNECTED; |
237 | 253 | ||
238 | /* Look for the requested type/protocol pair. */ | 254 | /* Look for the requested type/protocol pair. */ |