tcp: accept SOF_TIMESTAMPING_OPT_ID for passive TFO
authorSoheil Hassas Yeganeh <soheil@google.com>
Sun, 3 Apr 2016 03:08:07 +0000 (23:08 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Apr 2016 19:50:29 +0000 (15:50 -0400)
SOF_TIMESTAMPING_OPT_ID is set to get data-independent IDs
to associate timestamps with send calls. For TCP connections,
tp->snd_una is used as the starting point to calculate
relative IDs.

This socket option will fail if set before the handshake on a
passive TCP fast open connection with data in SYN or SYN/ACK,
since setsockopt requires the connection to be in the
ESTABLISHED state.

To address these, instead of limiting the option to the
ESTABLISHED state, accept the SOF_TIMESTAMPING_OPT_ID option as
long as the connection is not in LISTEN or CLOSE states.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 66976f88566bf5f78b63f12a1cf2e23dbaecf224..0a64fe20ce5a903ba697e163752ff3a127c31662 100644 (file)
@@ -832,7 +832,8 @@ set_rcvbuf:
                    !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
                        if (sk->sk_protocol == IPPROTO_TCP &&
                            sk->sk_type == SOCK_STREAM) {
-                               if (sk->sk_state != TCP_ESTABLISHED) {
+                               if ((1 << sk->sk_state) &
+                                   (TCPF_CLOSE | TCPF_LISTEN)) {
                                        ret = -EINVAL;
                                        break;
                                }