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=GwE6ygwJ; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id EBF225A0619 for ; Tue, 28 Oct 2025 09:09:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761638957; 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=0yuLvfOgAvqrryZUG/x0of3+M5FK40uUgfYqIU/LjJg=; b=GwE6ygwJSqGCdDLoWv8UTzZTIEHA0d30j3zApM+GNWroZ2/q1LcozPu8s2rxF6PQVg52L5 EbY8QSV3BtN3HUduOOAVq6AKH9oqvhX5TzdhtH5Hq7vwJjaovtf33EWbhbo+5yU/rxRGJn otDB3XoJ22rJH0iZHUF4HVSXG454Yjk= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-aEqbhkDsMsGZAZK76zYkuQ-1; Tue, 28 Oct 2025 04:09:16 -0400 X-MC-Unique: aEqbhkDsMsGZAZK76zYkuQ-1 X-Mimecast-MFC-AGG-ID: aEqbhkDsMsGZAZK76zYkuQ_1761638955 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-63c3efeed6aso4565069a12.1 for ; Tue, 28 Oct 2025 01:09:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761638954; x=1762243754; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0yuLvfOgAvqrryZUG/x0of3+M5FK40uUgfYqIU/LjJg=; b=DbMGFvSOqaD1L76ngHkJ9MC7cRqXeVdzNbXEhHnHBaXP5+OO/lAWRlvvYoAJuiyueU GKjdKwTeweyiMiNIRJv5Bd+V1eG9q3fsET9RwSE4nhWvh+9hkT5Ikd0ag1OHpI0umdOJ +cattsIFdwo3PybXHSmJWRuijRjgbKrTvUR6yhw8Iy0xzHjRA347oQlaoecFZQLUbH87 ltP5AVxvT96aFVO1LnITztf9uKml6d31l48SarN2Y2J49PyKvbiYYOlpJQXCRxbbFMVZ ROHVKltMmW3YaebwaWpMcRormwMbtqCZoKO2YGcc3cFYW+NYFPoL9RveK4iiFYzmmocz xT+Q== X-Gm-Message-State: AOJu0YwaFU09CIprYY1dob/+juZF2uDnV9ewjF2RyeX+UZY3ufu8TfT7 +khlMhPol++zPT3+SoUTebBejxzVVzIsp5HLbWJuoJ/vO1gOlb1suWVyVii8urWTGxlZrBUskjq /6aNiB7PDFGRp+5E+RONwZm+mXT9YW4mvlWSY9s4M4To5ZMVjkgPbjmNl7JIbm51Vu7VlGwItob VUQcuiKfF5VQAv3oJL893IS7CbnumBC/Mst2DGciU= X-Gm-Gg: ASbGncvMlkqxxSiUmsRhzDKWedPSeoRYAWu7Bbk0Z91ixTF6e1XOSwU41DpXpQ//b+M /PIqCO86hPmzfv0mhtTQWALf9+SnrjZknXQ1xekuSnFofcEBoast+CwZDF0ducKgfbK41uNKFc/ tI4UuNrZxqe43ZI5SGPOkifrlnAY53JNMrgsp+ixMhZulH+fWf5mjpafW3 X-Received: by 2002:a05:6402:44c4:b0:63c:b2:c656 with SMTP id 4fb4d7f45d1cf-63ed7e0821emr2042205a12.4.1761638954575; Tue, 28 Oct 2025 01:09:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3b4np+aTL2jbvp6dN8eG5WTq3beRdjs8pC7k/7a2MPOQHrczeEnF4+IC1EYVlHHTy9Lf5ZHXJo4HT6hQ1AE8= X-Received: by 2002:a05:6402:44c4:b0:63c:b2:c656 with SMTP id 4fb4d7f45d1cf-63ed7e0821emr2042193a12.4.1761638954177; Tue, 28 Oct 2025 01:09:14 -0700 (PDT) MIME-Version: 1.0 References: <20251017062838.21041-1-yuhuang@redhat.com> <20251017062838.21041-5-yuhuang@redhat.com> <20251024010438.16e19757@elisabeth> In-Reply-To: <20251024010438.16e19757@elisabeth> From: Yumei Huang Date: Tue, 28 Oct 2025 16:09:03 +0800 X-Gm-Features: AWmQ_bl4es9DD59RlHu5G5fwT_Bdi8Va-sZ7TjFcgT4fal1GJw44qOzo421jYWc Message-ID: Subject: Re: [PATCH v6 4/4] tcp: Update data retransmission timeout To: Stefano Brivio X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YJhoMwqOShKZsBpDeC9olG9CBYikGV5z_rBz8j6azXg_1761638955 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KQKXWI2ZX26R47OQHED4CFSNJA4TZ6E5 X-Message-ID-Hash: KQKXWI2ZX26R47OQHED4CFSNJA4TZ6E5 X-MailFrom: yuhuang@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, Oct 24, 2025 at 7:04=E2=80=AFAM Stefano Brivio = wrote: > > 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 discusse= d > > 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 f= lags: > > * > > - * - SYN_TIMEOUT_INIT: if no ACK is received from tap/guest during han= dshake > > - * (flag ACK_FROM_TAP_DUE without ESTABLISHED event) within this tim= e, resend > > - * SYN. It's the starting timeout for the first SYN retry. If this p= ersists > > - * 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 persi= sts 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 d= uring > > + * handshake (flag ACK_FROM_TAP_DUE without ESTABLISHED event) or af= ter > > + * sending data (flag ACK_FROM_TAP_DUE with ESTABLISHED event), re-s= end 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 man= y times > > + * in a row, reset the connection: TCP_MAX_RETRIES for established > > + * connections, or (tcp_syn_retries + tcp_syn_linear_timeouts) durin= g the > > + * handshake. > > * > > * - FIN_TIMEOUT: if a FIN segment was sent to tap/guest (flag ACK_FRO= M_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 69= 28 */ > > > > #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, st= ruct 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 =3D SYN_TIMEOUT_INIT; > > + it.it_value.tv_sec =3D RTO_INIT; > > else > > - it.it_value.tv_sec =3D SYN_TIMEOUT_INIT <= < > > + it.it_value.tv_sec =3D RTO_INIT << > > (conn->retries - c->tcp.syn_linea= r_timeouts); > > } > > else > > - it.it_value.tv_sec =3D ACK_TIMEOUT; > > + it.it_value.tv_sec =3D 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. I guess we can't just assign RTO_INIT. Maybe assign it only when retries=3D=3D0, otherwise multiply as it.it_value.tv_sec <<=3D1. But it seems more complicated. What do you think? > > > } else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) { > > it.it_value.tv_sec =3D 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. Reading tcp_rto_max_ms can be easy with the helper. My concern is about the way we get the total time for retries. I used to do it like this in v2, https://archives.passt.top/passt-dev/20251010074700.22177-4-yuhuang@redhat.= com/: +#define RETRY_ELAPSED(timeout_init, retries) \ + ((timeout_init) * ((1 << ((retries) + 1)) - 2)) Though the formula is not quite right, we could refine it as below: #define RETRY_ELAPSED(retries) ((RTO_INIT) * ((1 << ((retries) + 1)) - 1)) Does it make sense to get the time this way? > > -- > Stefano > --=20 Thanks, Yumei Huang