aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_fastopen.c
diff options
context:
space:
mode:
authorHaishuang Yan <yanhaishuang@cmss.chinamobile.com>2017-09-26 23:35:40 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-01 20:55:54 -0400
commite1cfcbe82b4534bd0f99fef92a6d33843fd85e0e (patch)
tree1a9fde5eff8d55d710fcc0631c7bcc8116ce72c6 /net/ipv4/tcp_fastopen.c
parent506d0a3edbc0bd4eaabe0c4e9c31ce69d6dfd5e5 (diff)
ipv4: Namespaceify tcp_fastopen knob
Different namespace application might require enable TCP Fast Open feature independently of the host. This patch series continues making more of the TCP Fast Open related sysctl knobs be per net-namespace. Reported-by: Luca BRUNO <lucab@debian.org> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e3c33220c418..31b08ec38cb8 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -9,8 +9,6 @@
9#include <net/inetpeer.h> 9#include <net/inetpeer.h>
10#include <net/tcp.h> 10#include <net/tcp.h>
11 11
12int sysctl_tcp_fastopen __read_mostly = TFO_CLIENT_ENABLE;
13
14struct tcp_fastopen_context __rcu *tcp_fastopen_ctx; 12struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
15 13
16static DEFINE_SPINLOCK(tcp_fastopen_ctx_lock); 14static DEFINE_SPINLOCK(tcp_fastopen_ctx_lock);
@@ -279,21 +277,22 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
279 struct request_sock *req, 277 struct request_sock *req,
280 struct tcp_fastopen_cookie *foc) 278 struct tcp_fastopen_cookie *foc)
281{ 279{
282 struct tcp_fastopen_cookie valid_foc = { .len = -1 };
283 bool syn_data = TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq + 1; 280 bool syn_data = TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq + 1;
281 int tcp_fastopen = sock_net(sk)->ipv4.sysctl_tcp_fastopen;
282 struct tcp_fastopen_cookie valid_foc = { .len = -1 };
284 struct sock *child; 283 struct sock *child;
285 284
286 if (foc->len == 0) /* Client requests a cookie */ 285 if (foc->len == 0) /* Client requests a cookie */
287 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENCOOKIEREQD); 286 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENCOOKIEREQD);
288 287
289 if (!((sysctl_tcp_fastopen & TFO_SERVER_ENABLE) && 288 if (!((tcp_fastopen & TFO_SERVER_ENABLE) &&
290 (syn_data || foc->len >= 0) && 289 (syn_data || foc->len >= 0) &&
291 tcp_fastopen_queue_check(sk))) { 290 tcp_fastopen_queue_check(sk))) {
292 foc->len = -1; 291 foc->len = -1;
293 return NULL; 292 return NULL;
294 } 293 }
295 294
296 if (syn_data && (sysctl_tcp_fastopen & TFO_SERVER_COOKIE_NOT_REQD)) 295 if (syn_data && (tcp_fastopen & TFO_SERVER_COOKIE_NOT_REQD))
297 goto fastopen; 296 goto fastopen;
298 297
299 if (foc->len >= 0 && /* Client presents or requests a cookie */ 298 if (foc->len >= 0 && /* Client presents or requests a cookie */
@@ -347,7 +346,7 @@ bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
347 return false; 346 return false;
348 } 347 }
349 348
350 if (sysctl_tcp_fastopen & TFO_CLIENT_NO_COOKIE) { 349 if (sock_net(sk)->ipv4.sysctl_tcp_fastopen & TFO_CLIENT_NO_COOKIE) {
351 cookie->len = -1; 350 cookie->len = -1;
352 return true; 351 return true;
353 } 352 }