diff options
author | Christoph Paasch <cpaasch@apple.com> | 2017-10-23 16:22:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-24 05:48:08 -0400 |
commit | 71c02379c762cb616c00fd5c4ed253fbf6bbe11b (patch) | |
tree | 516606a09f6d284d35d2d510fe23b11bf9e69f2a /net/ipv4/tcp.c | |
parent | b6f4f8484d88b69f700907200a9a9ec73806355f (diff) |
tcp: Configure TFO without cookie per socket and/or per route
We already allow to enable TFO without a cookie by using the
fastopen-sysctl and setting it to TFO_SERVER_COOKIE_NOT_REQD (or
TFO_CLIENT_NO_COOKIE).
This is safe to do in certain environments where we know that there
isn't a malicous host (aka., data-centers) or when the
application-protocol already provides an authentication mechanism in the
first flight of data.
A server however might be providing multiple services or talking to both
sides (public Internet and data-center). So, this server would want to
enable cookie-less TFO for certain services and/or for connections that
go to the data-center.
This patch exposes a socket-option and a per-route attribute to enable such
fine-grained configurations.
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
Reviewed-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index be07e9b6dbdd..8f36277e82e9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2836,6 +2836,14 @@ static int do_tcp_setsockopt(struct sock *sk, int level, | |||
2836 | err = -EOPNOTSUPP; | 2836 | err = -EOPNOTSUPP; |
2837 | } | 2837 | } |
2838 | break; | 2838 | break; |
2839 | case TCP_FASTOPEN_NO_COOKIE: | ||
2840 | if (val > 1 || val < 0) | ||
2841 | err = -EINVAL; | ||
2842 | else if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) | ||
2843 | err = -EINVAL; | ||
2844 | else | ||
2845 | tp->fastopen_no_cookie = val; | ||
2846 | break; | ||
2839 | case TCP_TIMESTAMP: | 2847 | case TCP_TIMESTAMP: |
2840 | if (!tp->repair) | 2848 | if (!tp->repair) |
2841 | err = -EPERM; | 2849 | err = -EPERM; |
@@ -3256,6 +3264,10 @@ static int do_tcp_getsockopt(struct sock *sk, int level, | |||
3256 | val = tp->fastopen_connect; | 3264 | val = tp->fastopen_connect; |
3257 | break; | 3265 | break; |
3258 | 3266 | ||
3267 | case TCP_FASTOPEN_NO_COOKIE: | ||
3268 | val = tp->fastopen_no_cookie; | ||
3269 | break; | ||
3270 | |||
3259 | case TCP_TIMESTAMP: | 3271 | case TCP_TIMESTAMP: |
3260 | val = tcp_time_stamp_raw() + tp->tsoffset; | 3272 | val = tcp_time_stamp_raw() + tp->tsoffset; |
3261 | break; | 3273 | break; |