• Eric Dumazet's avatar
    tcp: update skb->skb_mstamp more carefully · 8c72c65b
    Eric Dumazet authored
    liujian reported a problem in TCP_USER_TIMEOUT processing with a patch
    in tcp_probe_timer() :
          https://www.spinics.net/lists/netdev/msg454496.html
    
    After investigations, the root cause of the problem is that we update
    skb->skb_mstamp of skbs in write queue, even if the attempt to send a
    clone or copy of it failed. One reason being a routing problem.
    
    This patch prevents this, solving liujian issue.
    
    It also removes a potential RTT miscalculation, since
    __tcp_retransmit_skb() is not OR-ing TCP_SKB_CB(skb)->sacked with
    TCPCB_EVER_RETRANS if a failure happens, but skb->skb_mstamp has
    been changed.
    
    A future ACK would then lead to a very small RTT sample and min_rtt
    would then be lowered to this too small value.
    
    Tested:
    
    # cat user_timeout.pkt
    --local_ip=192.168.102.64
    
        0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
       +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
       +0 bind(3, ..., ...) = 0
       +0 listen(3, 1) = 0
    
       +0 `ifconfig tun0 192.168.102.64/16; ip ro add 192.0.2.1 dev tun0`
    
       +0 < S 0:0(0) win 0 <mss 1460>
       +0 > S. 0:0(0) ack 1 <mss 1460>
    
      +.1 < . 1:1(0) ack 1 win 65530
       +0 accept(3, ..., ...) = 4
    
       +0 setsockopt(4, SOL_TCP, TCP_USER_TIMEOUT, [3000], 4) = 0
       +0 write(4, ..., 24) = 24
       +0 > P. 1:25(24) ack 1 win 29200
       +.1 < . 1:1(0) ack 25 win 65530
    
    //change the ipaddress
       +1 `ifconfig tun0 192.168.0.10/16`
    
       +1 write(4, ..., 24) = 24
       +1 write(4, ..., 24) = 24
       +1 write(4, ..., 24) = 24
       +1 write(4, ..., 24) = 24
    
       +0 `ifconfig tun0 192.168.102.64/16`
       +0 < . 1:2(1) ack 25 win 65530
       +0 `ifconfig tun0 192.168.0.10/16`
    
       +3 write(4, ..., 24) = -1
    
    # ./packetdrill user_timeout.pkt
    Signed-off-by: default avatarEric Dumazet <[email protected]>
    Reported-by: default avatarliujian <[email protected]>
    Acked-by: default avatarNeal Cardwell <[email protected]>
    Acked-by: default avatarYuchung Cheng <[email protected]>
    Acked-by: default avatarSoheil Hassas Yeganeh <[email protected]>
    Signed-off-by: default avatarDavid S. Miller <[email protected]>
    8c72c65b
tcp_output.c 107 KB