1 #include <linux/kernel.h>
4 #include <linux/module.h>
6 #include <linux/random.h>
7 #include <linux/hrtimer.h>
9 #include <linux/string.h>
15 static int __init net_secret_init(
void)
23 static u32 seq_scale(
u32 seq)
39 #if IS_ENABLED(CONFIG_IPV6)
48 for (i = 0; i < 4; i++)
50 secret[4] = net_secret[4] +
53 secret[i] = net_secret[i];
57 return seq_scale(hash[0]);
69 for (i = 0; i < 4; i++)
71 secret[4] = net_secret[4] + (
__force u32)dport;
73 secret[i] = net_secret[i];
88 hash[1] = net_secret[13];
89 hash[2] = net_secret[14];
90 hash[3] = net_secret[15];
115 hash[3] = net_secret[15];
119 return seq_scale(hash[0]);
128 hash[2] = (
__force u32)dport ^ net_secret[14];
129 hash[3] = net_secret[15];
138 #if IS_ENABLED(CONFIG_IP_DCCP)
148 hash[3] = net_secret[15];
152 seq = hash[0] | (((
u64)hash[1]) << 32);
154 seq &= (1ull << 48) - 1;
160 #if IS_ENABLED(CONFIG_IPV6)
170 for (i = 0; i < 4; i++)
171 secret[i] = net_secret[i] + daddr[i];
172 secret[4] = net_secret[4] +
175 secret[i] = net_secret[i];
179 seq = hash[0] | (((
u64)hash[1]) << 32);
181 seq &= (1ull << 48) - 1;