13 #include <linux/tcp.h>
14 #include <linux/slab.h>
15 #include <linux/random.h>
17 #include <linux/kernel.h>
18 #include <linux/export.h>
24 #define TSMASK (((__u32)1 << TSBITS) - 1)
31 static __init int init_syncookies(
void)
39 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
77 options |= ireq->
ecn_ok << 5;
106 return (cookie_hash(saddr, daddr, sport, dport, 0, 0) +
108 ((cookie_hash(saddr, daddr, sport, dport, count, 1) + data)
128 cookie -= cookie_hash(saddr, daddr, sport, dport, 0, 0) + sseq;
136 cookie_hash(saddr, daddr, sport, dport, count - diff, 1))
148 static __u16 const msstab[] = {
165 const struct iphdr *iph = ip_hdr(skb);
166 const struct tcphdr *
th = tcp_hdr(skb);
170 tcp_synq_overflow(sk);
172 for (mssind =
ARRAY_SIZE(msstab) - 1; mssind ; mssind--)
173 if (mss >= msstab[mssind])
175 *mssp = msstab[mssind];
179 return secure_tcp_syn_cookie(iph->
saddr, iph->
daddr,
190 #define COUNTER_TRIES 4
197 const struct iphdr *iph = ip_hdr(skb);
198 const struct tcphdr *
th = tcp_hdr(skb);
205 return mssind <
ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
215 child = icsk->
icsk_af_ops->syn_recv_sock(sk, skb, req, dst);
217 inet_csk_reqsk_queue_add(sk, req, child);
241 tcp_clear_options(tcp_opt);
249 *ecn_ok = (options >> 5) & 1;
256 if ((options & 0xf) == 0xf)
269 const u8 *hash_location;
273 const struct tcphdr *
th = tcp_hdr(skb);
286 if (tcp_synq_no_recent_overflow(sk) ||
287 (mss = cookie_check(skb, cookie)) == 0) {
295 memset(&tcp_opt, 0,
sizeof(tcp_opt));
306 ireq = inet_rsk(req);
313 ireq->
loc_addr = ip_hdr(skb)->daddr;
314 ireq->
rmt_addr = ip_hdr(skb)->saddr;
337 if (security_inet_conn_request(sk, skb, req)) {
353 inet_sk_flowi_flags(sk),
356 security_req_classify_flow(req, flowi4_to_flowi(&fl4));
357 rt = ip_route_output_key(sock_net(sk), &fl4);
373 ret = get_cookie_sock(sk, skb, req, &rt->
dst);
378 inet_sk(ret)->cork.fl.u.ip4 = fl4;