Commit ffc56c90 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Jakub Kicinski
Browse files

selftest: packetdrill: Add max RTO test for SYN+ACK.



This script sets net.ipv4.tcp_rto_max_ms to 1000 and checks
if SYN+ACK RTO is capped at 1s for TFO and non-TFO.

Without the previous patch, the max RTO is applied to TFO
SYN+ACK only, and non-TFO SYN+ACK RTO increases exponentially.

  # selftests: net/packetdrill: tcp_rto_synack_rto_max.pkt
  # TAP version 13
  # 1..2
  # tcp_rto_synack_rto_max.pkt:46: error handling packet: timing error:
     expected outbound packet at 5.091936 sec but happened at 6.107826 sec; tolerance 0.127974 sec
  # script packet:  5.091936 S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
  # actual packet:  6.107826 S. 0:0(0) ack 1 win 65535 <mss 1460,nop,nop,sackOK>
  # not ok 1 ipv4
  # tcp_rto_synack_rto_max.pkt:46: error handling packet: timing error:
     expected outbound packet at 5.075901 sec but happened at 6.091841 sec; tolerance 0.127976 sec
  # script packet:  5.075901 S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
  # actual packet:  6.091841 S. 0:0(0) ack 1 win 65535 <mss 1460,nop,nop,sackOK>
  # not ok 2 ipv6
  # # Totals: pass:0 fail:2 xfail:0 xpass:0 skip:0 error:0
  not ok 49 selftests: net/packetdrill: tcp_rto_synack_rto_max.pkt # exit=1

With the previous patch, all SYN+ACKs are retransmitted
after 1s.

  # selftests: net/packetdrill: tcp_rto_synack_rto_max.pkt
  # TAP version 13
  # 1..2
  # ok 1 ipv4
  # ok 2 ipv6
  # # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:0 error:0
  ok 49 selftests: net/packetdrill: tcp_rto_synack_rto_max.pkt

Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20251106003357.273403-7-kuniyu@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1e9d3005
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
//
// Test SYN+ACK RTX with 1s RTO.
//
`./defaults.sh
 ./set_sysctls.py /proc/sys/net/ipv4/tcp_rto_max_ms=1000`

//
// Test 1: TFO SYN+ACK
//
    0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0
   +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0

   +0 < S 0:10(10) win 1000 <mss 1460,sackOK,nop,nop,FO TFO_COOKIE,nop,nop>
   +0 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK>

// RTO must be capped to 1s
   +1 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK>
   +1 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK>
   +1 > S. 0:0(0) ack 11 <mss 1460,nop,nop,sackOK>

   +0 < . 11:11(0) ack 1 win 1000 <mss 1460,nop,nop,sackOK>
   +0 accept(3, ..., ...) = 4
   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) != 0, tcpi_options }%

   +0 close(4) = 0
   +0 close(3) = 0


//
// Test 2: non-TFO SYN+ACK
//
   +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 < S 0:0(0) win 1000 <mss 1460,sackOK,nop,nop>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>

// RTO must be capped to 1s
   +1 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +1 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +1 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>

   +0 < . 1:1(0) ack 1 win 1000 <mss 1460,nop,nop,sackOK>
   +0 accept(3, ..., ...) = 4
   +0 %{ assert (tcpi_options & TCPI_OPT_SYN_DATA) == 0, tcpi_options }%

   +0 close(4) = 0
   +0 close(3) = 0