diff options
Diffstat (limited to 'net/ipv4/syncookies.c')
-rw-r--r-- | net/ipv4/syncookies.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index f470fe4511db..4704f27f6c0b 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * 2 of the License, or (at your option) any later version. | 10 | * 2 of the License, or (at your option) any later version. |
11 | * | 11 | * |
12 | * $Id: syncookies.c,v 1.18 2002/02/01 22:01:04 davem Exp $ | 12 | * $Id: syncookies.c,v 1.18 2002/02/01 22:01:04 davem Exp $ |
13 | * | ||
14 | * Missing: IPv6 support. | ||
15 | */ | 13 | */ |
16 | 14 | ||
17 | #include <linux/tcp.h> | 15 | #include <linux/tcp.h> |
@@ -23,22 +21,25 @@ | |||
23 | 21 | ||
24 | extern int sysctl_tcp_syncookies; | 22 | extern int sysctl_tcp_syncookies; |
25 | 23 | ||
26 | static __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS]; | 24 | __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS]; |
25 | EXPORT_SYMBOL(syncookie_secret); | ||
27 | 26 | ||
28 | static __init int init_syncookies(void) | 27 | static __init int init_syncookies(void) |
29 | { | 28 | { |
30 | get_random_bytes(syncookie_secret, sizeof(syncookie_secret)); | 29 | get_random_bytes(syncookie_secret, sizeof(syncookie_secret)); |
31 | return 0; | 30 | return 0; |
32 | } | 31 | } |
33 | module_init(init_syncookies); | 32 | __initcall(init_syncookies); |
34 | 33 | ||
35 | #define COOKIEBITS 24 /* Upper bits store count */ | 34 | #define COOKIEBITS 24 /* Upper bits store count */ |
36 | #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) | 35 | #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) |
37 | 36 | ||
37 | static DEFINE_PER_CPU(__u32, cookie_scratch)[16 + 5 + SHA_WORKSPACE_WORDS]; | ||
38 | |||
38 | static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport, | 39 | static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport, |
39 | u32 count, int c) | 40 | u32 count, int c) |
40 | { | 41 | { |
41 | __u32 tmp[16 + 5 + SHA_WORKSPACE_WORDS]; | 42 | __u32 *tmp = __get_cpu_var(cookie_scratch); |
42 | 43 | ||
43 | memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c])); | 44 | memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c])); |
44 | tmp[0] = (__force u32)saddr; | 45 | tmp[0] = (__force u32)saddr; |