From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZAdqvX4j; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 08C185A026F for ; Fri, 24 Oct 2025 01:04:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761260684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKuFcKY8CTqvjLbAPV+dVyCaf57tTwFWFDoFHLAwv8E=; b=ZAdqvX4j7GuHuNYmKnjj6sV1ytMxA9CQIIVy98sg9U+uJBEt1tmMb9Ut88XQ/DRB+lxRE+ G0SK2f5pMduPSdhq0dPDdUkqCRLXU9t+qE7cTUvKxmc1FqciAdOSjMEsLfV7cIerq5h7Oa fTGgMhTu7RlPVUi1b7V4xBu/kW4kKPw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-ZQjXfP4iO06OJyZq6stkSw-1; Thu, 23 Oct 2025 19:04:42 -0400 X-MC-Unique: ZQjXfP4iO06OJyZq6stkSw-1 X-Mimecast-MFC-AGG-ID: ZQjXfP4iO06OJyZq6stkSw_1761260681 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4298b58bd3bso652624f8f.2 for ; Thu, 23 Oct 2025 16:04:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761260681; x=1761865481; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tKuFcKY8CTqvjLbAPV+dVyCaf57tTwFWFDoFHLAwv8E=; b=IJEvKLxAq93FD+/KIx4aNb25LZYhww3/gV5d4Vi9tdVH9X+wW4F0Rt6rU3I3kwvvvq JWbbQtw0lOIvgtFUokjSS+qqbo3u1Qp6/JPfzp5xJkdy04dyFjwOYmCQLwVjR9vSKHK9 iNyIhZ1SHqp+/4ZD+0jl3xI/iiBTweHLHW27M/PDWFzkYz/8I+ehblfvhnJ05PRFKRLO yTKb3JoGsvUr3ncYuLIrasI/g9YqAZkk/cOnx+HTv0s8PcV/XSUTHUjnZ01hEA9kFKDz OkaRhP3hyX7bemGo618xJqqNz6DWWTzdTmXt+NzfniTCDtLO/cnzsSedRYkOVHGEotBL bK6w== X-Gm-Message-State: AOJu0Yyo0McueQVrXPiki/z+2fwo7kNe+HhqGFTeQ13XZmMGM4AQd4UO sA8u6wMiwiNOS/obExG6rQ3M6es+zGLKph1uHbs+JFOzGKmS2bKtY3+0vX8d3vzOx7UeZgsQQkO kgN87K6grTAXwAKFOyrXEKd8XwKZ8EEip4VNddggddgrCS6UL0rDCtA== X-Gm-Gg: ASbGncvuXZedkZqSxJxZAw6sW+EqySNNXAhPDPVD88j5HI3HAj2Q0ZqxclrbT7RsP1q +7BLRFxjCc0jA9aeYawx+WNCe8uHMULA8Qelt1snW8C1YQC7Dd1SL+YK8a8qDGmQ/LUNWBPqeza wZI0mhipbx2iUh+Tb2J9ML5x2k/N65Mxsjnw7QW5urKKCJ8cKOC/hPHHYImT31JkySPjp3V6jQh QI0hpxxK0KBF41opvHrB1prmMO0Gi8/rUItiZWiVnrFXC0caynIzPuYZgLxjvnY1U5gO8k74S8g e3CCfivrH+mQ7PAa2dxS2I/y9iS5OkPK50s6JO666HEuW0seCVw8iR1lPiyA8TsIoDwGkSa2/B6 E6/9VnUDOjNzLp4udyzTAzEz9Mik= X-Received: by 2002:a05:6000:240f:b0:426:d582:14a3 with SMTP id ffacd0b85a97d-4298a040705mr2222755f8f.9.1761260681087; Thu, 23 Oct 2025 16:04:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXtVNoEYKFlkD2LATCLeFV6N3sM3iUW2h4BdPGTbT+VonkfHN5wwL/MRt7x9LjEAm8mdSMhA== X-Received: by 2002:a05:6000:240f:b0:426:d582:14a3 with SMTP id ffacd0b85a97d-4298a040705mr2222748f8f.9.1761260680646; Thu, 23 Oct 2025 16:04:40 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429897e7630sm6212347f8f.10.2025.10.23.16.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 16:04:40 -0700 (PDT) Date: Fri, 24 Oct 2025 01:04:38 +0200 From: Stefano Brivio To: Yumei Huang Subject: Re: [PATCH v6 4/4] tcp: Update data retransmission timeout Message-ID: <20251024010438.16e19757@elisabeth> In-Reply-To: <20251017062838.21041-5-yuhuang@redhat.com> References: <20251017062838.21041-1-yuhuang@redhat.com> <20251017062838.21041-5-yuhuang@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: A2AlYqp4P_CaGyfFWhzgCtWhrj9ncbN3XEZnFAYQutM_1761260681 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: JOXDRSZEJTCXL6B56TMCLAS4AORTMCQG X-Message-ID-Hash: JOXDRSZEJTCXL6B56TMCLAS4AORTMCQG X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, david@gibson.dropbear.id.au X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 17 Oct 2025 14:28:38 +0800 Yumei Huang wrote: > Use an exponential backoff timeout for data retransmission according > to RFC 2988 and RFC 6298. Set the initial RTO to one second as discussed > in Appendix A of RFC 6298. > > Also combine the macros defining the initial RTO for both SYN and ACK. > > Signed-off-by: Yumei Huang > Reviewed-by: David Gibson > --- > tcp.c | 27 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 15 deletions(-) > > diff --git a/tcp.c b/tcp.c > index 9385132..dc0ec6c 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -179,16 +179,14 @@ > * > * Timeouts are implemented by means of timerfd timers, set based on flags: > * > - * - SYN_TIMEOUT_INIT: if no ACK is received from tap/guest during handshake > - * (flag ACK_FROM_TAP_DUE without ESTABLISHED event) within this time, resend > - * SYN. It's the starting timeout for the first SYN retry. If this persists > - * for more than TCP_MAX_RETRIES or (tcp_syn_retries + > - * tcp_syn_linear_timeouts) times in a row, reset the connection > - * > - * - ACK_TIMEOUT: if no ACK segment was received from tap/guest, after sending > - * data (flag ACK_FROM_TAP_DUE with ESTABLISHED event), re-send data from the > - * socket and reset sequence to what was acknowledged. If this persists for > - * more than TCP_MAX_RETRIES times in a row, reset the connection > + * - RTO_INIT: if no ACK segment was received from tap/guest, either during > + * handshake (flag ACK_FROM_TAP_DUE without ESTABLISHED event) or after > + * sending data (flag ACK_FROM_TAP_DUE with ESTABLISHED event), re-send data > + * from the socket and reset sequence to what was acknowledged. This is the > + * timeout for the first retry, in seconds. If this persists too many times > + * in a row, reset the connection: TCP_MAX_RETRIES for established > + * connections, or (tcp_syn_retries + tcp_syn_linear_timeouts) during the > + * handshake. > * > * - FIN_TIMEOUT: if a FIN segment was sent to tap/guest (flag ACK_FROM_TAP_DUE > * with TAP_FIN_SENT event), and no ACK is received within this time, reset > @@ -342,8 +340,7 @@ enum { > #define WINDOW_DEFAULT 14600 /* RFC 6928 */ > > #define ACK_INTERVAL 10 /* ms */ > -#define SYN_TIMEOUT_INIT 1 /* s */ > -#define ACK_TIMEOUT 2 > +#define RTO_INIT 1 /* s, RFC 6298 */ > #define FIN_TIMEOUT 60 > #define ACT_TIMEOUT 7200 > > @@ -588,13 +585,13 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn) > } else if (conn->flags & ACK_FROM_TAP_DUE) { > if (!(conn->events & ESTABLISHED)) { > if (conn->retries < c->tcp.syn_linear_timeouts) > - it.it_value.tv_sec = SYN_TIMEOUT_INIT; > + it.it_value.tv_sec = RTO_INIT; > else > - it.it_value.tv_sec = SYN_TIMEOUT_INIT << > + it.it_value.tv_sec = RTO_INIT << > (conn->retries - c->tcp.syn_linear_timeouts); > } > else > - it.it_value.tv_sec = ACK_TIMEOUT; > + it.it_value.tv_sec = RTO_INIT << conn->retries; Same as on 3/4, but here it's clearly more convenient: just assign RTO_INIT, and multiply as needed in the if / else clauses. > } else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) { > it.it_value.tv_sec = FIN_TIMEOUT; > } else { The rest of the series looks good to me. It might be slightly more practical to factor in directly the RTO clamp, and I don't think it's complicated now that you have the helper from 2/4, but it's not a strong preference from my side, as the series makes sense in any case. -- Stefano