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=gBFEGa8s; 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 18CDC5A0619 for ; Thu, 27 Nov 2025 23:33:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764282811; 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=9hks/LNLqYKI0I8IzFYQXJOO2B+iGuWZNjXGMnl8d2w=; b=gBFEGa8s+eL+FRrIsUm4K37kzBFb4PBnqIQCPocJ0TCtiHUsDw5wbzZwYcT3wEP8EjrTLX Ltpsp4ZN2BD/sUr8QJ4WF9KNrDPZFNqrXAoTef8QaZ6RaT+p0HB3+g+nPOS0secrzCO31F Q64jlAP+CuhHuDnrt4UVuP67jvmy8q0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-GNkMTgN7Mkm58qqcga6z6g-1; Thu, 27 Nov 2025 17:33:29 -0500 X-MC-Unique: GNkMTgN7Mkm58qqcga6z6g-1 X-Mimecast-MFC-AGG-ID: GNkMTgN7Mkm58qqcga6z6g_1764282808 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-429cd1d0d98so1017048f8f.3 for ; Thu, 27 Nov 2025 14:33:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764282808; x=1764887608; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9hks/LNLqYKI0I8IzFYQXJOO2B+iGuWZNjXGMnl8d2w=; b=YRVwBmYwKJHktwKF3ttjSKnGbulYL3NSqbJHM/ZjUiicmnwdDFduyWItiIHupmyLif zDdZZRCTUe54xuuZjD8TaAUbsGdewxbJv9VeUCnTcYWbYn/SdPoAWX/1HWDKgLnE9nZh +ReAdWzdJJcJ+YEdwFj87xb7NM+OOlkZx7r3MpLmaeiRimxSma6m/3LpL8pTpVYBHqyj 8OeAaHFrexV5Xate5wgpF198N2bRwE0nWmVTXcMx4i76Uj6A30J8qVjtYHuMS4XGXETU /GmtvGuL+shi9c/iaDRgEUpEnMsBdN78x0Ttd/0psYBIdA+6K6+rOVO2lKfMg7necO7O iodg== X-Gm-Message-State: AOJu0YztNRjc43kiKslpWcNfsHX9I14EXESV/mqFFz8Vf1wgX20voLYf 1LSkbZZC4uUMORAIXJJBrjB3PcwdkAekgXrp7+y/UvsyqF3U5D1tuw+E/VeEXp9dLcZdT8T7pXk SHWzPO+mZ3asS9vvOKEzH2ZX/Sm48BHeQrwUABw4KMu8BqufWau97YQ== X-Gm-Gg: ASbGncv++f7Z0fProMJLpCKjhBoI+p4vfYWuMsgKJwrZVKTHTY45+ghnpbDE9Rs620X zF8GZsLzfmbKfbNbrKTCyRJD790CJ8Rj5oO1Hjz3Ai5mVOHhv2gW8gCRpdGIGmRRLUt+0g0V1Od vFHONl6PKwVfLpAdUvOTkvdz9vqzxh1wfwHZU4hPafSNa3BJ/6Lf3Jd0rE2Uu25n8G0sYHANFhf YGNwHForMNfdscZtbcNYh22C0pwYf9rNsyv55OvG+SLPG2KPBB08dkA6b00FYgaXWLoOEeyVgFC dPvHeu2sBNbwV7o+DTq3Tvzt/rgG0kcR9rlQUOyGP5lAIwsXm8XfrRhEktmPK4zm0ha8m+HSyPJ LBAdH2vh27fUM3ZUSZy8x67WOD2+j9rYPqTVMtQ== X-Received: by 2002:a05:600c:8b37:b0:477:569c:34e9 with SMTP id 5b1f17b1804b1-47904b1eda4mr106545115e9.23.1764282808322; Thu, 27 Nov 2025 14:33:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBqyFNcc+ra9W2/slUf3Uxjai3PhZD4pirDQML1ZisSYNSuVThuC3c0AjdwL0TOnro9OHPYg== X-Received: by 2002:a05:600c:8b37:b0:477:569c:34e9 with SMTP id 5b1f17b1804b1-47904b1eda4mr106545025e9.23.1764282807872; Thu, 27 Nov 2025 14:33:27 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4791163e3dasm52423845e9.11.2025.11.27.14.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Nov 2025 14:33:27 -0800 (PST) Date: Thu, 27 Nov 2025 23:33:26 +0100 From: Stefano Brivio To: Yumei Huang Subject: Re: [PATCH v9 4/5] tcp: Update data retransmission timeout Message-ID: <20251127233326.3e1fa06f@elisabeth> In-Reply-To: <20251125072638.88896-5-yuhuang@redhat.com> References: <20251125072638.88896-1-yuhuang@redhat.com> <20251125072638.88896-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: SriNmjYckO1uKdRgNdZePUKFrVHCwWN4Sl3paEAXVrM_1764282808 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: UQFNRUDSA2754AQMRFX5TNTFFGPJJEQ4 X-Message-ID-Hash: UQFNRUDSA2754AQMRFX5TNTFFGPJJEQ4 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 Tue, 25 Nov 2025 15:26:37 +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 | 31 ++++++++++++------------------- > 1 file changed, 12 insertions(+), 19 deletions(-) > > diff --git a/tcp.c b/tcp.c > index 2887f2c..b3aa064 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -179,16 +179,13 @@ > * > * Timeouts are implemented by means of timerfd timers, set based on flags: > * > - * - SYN_TIMEOUT_INIT: if no SYN,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. Retry for TCP_MAX_RETRIES or (syn_retries + syn_linear_timeouts) > - * times, 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. Retry for TCP_MAX_RETRIES times > + * for established connections, or (syn_retries + syn_linear_timeouts) times > + * during the handshake, reset the connection Same as David's comment on 3/5: ", then reset the connection". Otherwise, after saying "Retry x times, or y times, ..." is looks like "reset the connection" is another possibility. No, we do that in any case, but later (after retrying), hence "then". Sorry, I just realised this was already like that starting from v7 but we missed it. > * > * - 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 +339,7 @@ enum { > #define WINDOW_DEFAULT 14600 /* RFC 6928 */ > > #define ACK_INTERVAL 10 /* ms */ > -#define SYN_TIMEOUT_INIT 1 /* s, RFC 6928 */ > -#define ACK_TIMEOUT 2 > +#define RTO_INIT 1 /* s, RFC 6298 */ > #define FIN_TIMEOUT 60 > #define ACT_TIMEOUT 7200 > > @@ -594,13 +590,10 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn) > if (conn->flags & ACK_TO_TAP_DUE) { > it.it_value.tv_nsec = (long)ACK_INTERVAL * 1000 * 1000; > } else if (conn->flags & ACK_FROM_TAP_DUE) { > - if (!(conn->events & ESTABLISHED)) { > - int exp; > - exp = (int)conn->retries - c->tcp.syn_linear_timeouts; > - it.it_value.tv_sec = SYN_TIMEOUT_INIT << MAX(exp, 0); > - } else { > - it.it_value.tv_sec = ACK_TIMEOUT; > - } > + int exp = conn->retries; > + if (!(conn->events & ESTABLISHED)) > + exp -= c->tcp.syn_linear_timeouts; > + it.it_value.tv_sec = RTO_INIT << MAX(exp, 0); > } else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) { > it.it_value.tv_sec = FIN_TIMEOUT; > } else { -- Stefano