From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com 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 00FE95A0269 for ; Thu, 03 Dec 2026 01:24:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796257449; 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=/9fWJHF2E8UnDplNwWnIr6nsPWlmBdseGpCapE2trYA=; b=RYOpf22jcZ64Nwg98dKVmfJCrwjf+OV4wBf6ALYAXBUCm9MB01hVkV4DcC815wMrvhtKM8 5eWXKh1xv8A3Pv8+64i7d95day/IBIDOsSBPTJLWh97tN9e1/jjxJSApZKypKvRWoBGy7H 07lodN/kFVJxLEIzB/UohJFjpMKfC8E= X-MC-Rep: binary re single Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-DmtOTrUSO-OQQKvG1q6xQQ-1; Thu, 3 Dec 2026 00:24:07 +0000 X-MC-Unique: DmtOTrUSO-OQQKvG1q6xQQ-1 X-Mimecast-MFC-AGG-ID: DmtOTrUSO-OQQKvG1q6xQQ_1796257446 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4bb67b2c00cso1889595e9.1 for ; Wed, 02 Dec 2026 16:24:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796257446; x=1796862246; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :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:600c:698c:b0:4bb:85d9:156e with SMTP id 5b1f17b1804b1-4bbe198595fmr6797165e9.11.1796257445809; Wed, 02 Dec 2026 16:24:05 -0800 (PST) X-Received: by 2002:a05:600c:698c:b0:4bb:85d9:156e with SMTP id 5b1f17b1804b1-4bbe198595fmr6796835e9.11.1796257445324; Wed, 02 Dec 2026 16:24:05 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb90655f5asm813479045e9.1.2026.12.02.16.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 16:24:04 -0800 (PST) From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH] tcp: Retransmit the same SYN or SYN-ACK on handshake timeout Message-ID: <20261203012403.4c97b686@elisabeth> In-Reply-To: <20261202202103.2840787-1-jmaloy@redhat.com> References: <20261202202103.2840787-1-jmaloy@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 Date: Thu, 03 Dec 2026 01:24:04 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HxHz3D7kshNBDZKQdSCDj4hkTdzM8EJqkA0YTAW679I_1796257446 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: M6FIYAXIPPO7H6I5ANBP6Q4GCYMCSYGH X-Message-ID-Hash: M6FIYAXIPPO7H6I5ANBP6Q4GCYMCSYGH 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, Fumin 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 Wed, 2 Dec 2026 15:21:03 -0500 Jon Maloy wrote: > Commit 0e8df13c96be ("tcp: Resend SYN for inbound connections") lets > tcp_timer_handler() retry the handshake for connections that are > taking too long to establish, by sending a new, bare SYN at each retry. > > However, this approach has two issues: > > - For connections initiated by the guest (TAP_SYN_RCVD), we send a > SYN-ACK, not a SYN, so the retry carries the wrong flags, and lacks > the ACK > > - As tcp_prepare_flags() advances seq_to_tap for every SYN we send, > every retry uses a different sequence number, and, once the > handshake completes, we start sending data from the ISN plus the > number of retries, instead of ISN + 1 > > If the guest acknowledges our original SYN-ACK (or SYN) after one or > more retries, for example because the ACK was held in a queue, we send > data with sequence numbers shifted by the number of retries, and, once > the retransmission timer rewinds to the acknowledged sequence, the > same data again, so that the guest assembles a corrupted stream. > > Retransmit what we originally sent instead: a SYN-ACK if the guest > initiated the connection, a SYN otherwise, and reset seq_to_tap to the > initial sequence number first, which is still stored in > seq_ack_from_tap at this point. > > If the guest initiated the connection, i.e. the TAP_SYN_RCVD flag is > set, we set the ACK flag in each retry, otherwise not. In both cases, > we rewind the sequence number to ISN before retransmitting. > > Link: https://bugs.passt.top/show_bug.cgi?id=229 > Fixes: 0e8df13c96be ("tcp: Resend SYN for inbound connections") > Signed-off-by: Jon Maloy > > --- > tcp.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tcp.c b/tcp.c > index 409f4ce1..7dfb1490 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2729,8 +2729,19 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref, > flow_dbg(conn, "handshake timeout"); > tcp_rst(c, conn, now); > } else { > + int flags = SYN; > + > flow_trace(conn, "SYN timeout, retry"); > - if (tcp_send_flag(c, conn, SYN, now)) { > + > + /* Retransmit what we sent: a SYN-ACK if the > + * guest initiated the connection, a SYN > + * otherwise. Rewind to ISN at each retry. > + */ > + if (conn->events & TAP_SYN_RCVD) > + flags |= ACK; > + conn->seq_to_tap = conn->seq_ack_from_tap; > + > + if (tcp_send_flag(c, conn, flags, now)) { > tcp_rst(c, conn, now); > return; > } Applied. -- Stefano