|
@@ -24,6 +24,8 @@
|
|
|
#define COOKIEBITS 24 /* Upper bits store count */
|
|
|
#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
|
|
|
|
|
|
+static u32 syncookie6_secret[2][16-4+SHA_DIGEST_WORDS];
|
|
|
+
|
|
|
/* RFC 2460, Section 8.3:
|
|
|
* [ipv6 tcp] MSS must be computed as the maximum packet size minus 60 [..]
|
|
|
*
|
|
@@ -61,14 +63,18 @@ static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
|
|
|
static u32 cookie_hash(const struct in6_addr *saddr, const struct in6_addr *daddr,
|
|
|
__be16 sport, __be16 dport, u32 count, int c)
|
|
|
{
|
|
|
- __u32 *tmp = __get_cpu_var(ipv6_cookie_scratch);
|
|
|
+ __u32 *tmp;
|
|
|
+
|
|
|
+ net_get_random_once(syncookie6_secret, sizeof(syncookie6_secret));
|
|
|
+
|
|
|
+ tmp = __get_cpu_var(ipv6_cookie_scratch);
|
|
|
|
|
|
/*
|
|
|
* we have 320 bits of information to hash, copy in the remaining
|
|
|
- * 192 bits required for sha_transform, from the syncookie_secret
|
|
|
+ * 192 bits required for sha_transform, from the syncookie6_secret
|
|
|
* and overwrite the digest with the secret
|
|
|
*/
|
|
|
- memcpy(tmp + 10, syncookie_secret[c], 44);
|
|
|
+ memcpy(tmp + 10, syncookie6_secret[c], 44);
|
|
|
memcpy(tmp, saddr, 16);
|
|
|
memcpy(tmp + 4, daddr, 16);
|
|
|
tmp[8] = ((__force u32)sport << 16) + (__force u32)dport;
|