• Eric Dumazet's avatar
    tcp: avoid reorders for TFO passive connections · 7c85af88
    Eric Dumazet authored
    We found that a TCP Fast Open passive connection was vulnerable
    to reorders, as the exchange might look like
    
    [1] C -> S S <FO ...> <request>
    [2] S -> C S. ack request <options>
    [3] S -> C . <answer>
    
    packets [2] and [3] can be generated at almost the same time.
    
    If C receives the 3rd packet before the 2nd, it will drop it as
    the socket is in SYN_SENT state and expects a SYNACK.
    
    S will have to retransmit the answer.
    
    Current OOO avoidance in linux is defeated because SYNACK
    packets are attached to the LISTEN socket, while DATA packets
    are attached to the children. They might be sent by different cpus,
    and different TX queues might be selected.
    
    It turns out that for TFO, we created a child, which is a
    full blown socket in TCP_SYN_RECV state, and we simply can attach
    the SYNACK packet to this socket.
    
    This means that at the time tcp_sendmsg() pushes DATA packet,
    skb->ooo_okay will be set iff the SYNACK packet had been sent
    and TX completed.
    
    This removes the reorder source at the host level.
    
    We also removed the export of tcp_try_fastopen(), as it is no
    longer called from IPv6.
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    7c85af88
tcp_input.c 178 KB