aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_fastopen.c
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2017-01-23 13:59:20 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-25 14:04:38 -0500
commit065263f40f0972d5f1cd294bb0242bd5aa5f06b2 (patch)
treec8d7915e4b9cb64a7e069b2842897af5b5c73f85 /net/ipv4/tcp_fastopen.c
parenta9c54ad2c737853b1f404b10b09da4ca7fa18597 (diff)
net/tcp-fastopen: refactor cookie check logic
Refactor the cookie check logic in tcp_send_syn_data() into a function. This function will be called else where in later changes. Signed-off-by: Wei Wang <weiwan@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_fastopen.c')
-rw-r--r--net/ipv4/tcp_fastopen.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index f51919535ca7..f90e09e1ff4c 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -325,3 +325,24 @@ fastopen:
325 *foc = valid_foc; 325 *foc = valid_foc;
326 return NULL; 326 return NULL;
327} 327}
328
329bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
330 struct tcp_fastopen_cookie *cookie)
331{
332 unsigned long last_syn_loss = 0;
333 int syn_loss = 0;
334
335 tcp_fastopen_cache_get(sk, mss, cookie, &syn_loss, &last_syn_loss);
336
337 /* Recurring FO SYN losses: no cookie or data in SYN */
338 if (syn_loss > 1 &&
339 time_before(jiffies, last_syn_loss + (60*HZ << syn_loss))) {
340 cookie->len = -1;
341 return false;
342 }
343 if (sysctl_tcp_fastopen & TFO_CLIENT_NO_COOKIE) {
344 cookie->len = -1;
345 return true;
346 }
347 return cookie->len > 0;
348}