From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=YcN4iGX+; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 517C15A0625 for ; Fri, 30 Jan 2026 05:41:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1769748065; bh=ll0SfBzmrPs/HPNaffvGCEw44Cq74SNvxXtkJIcV3Gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YcN4iGX+TbXUoopcJh07JJayXJ5VRY7akwwor0s/i83Drv1Q9aitqTFE8gT798qN2 LhflBMDRfkhmcLrOH8lBXaaDD+z82hUCy50JVd2Q9e7KWoIBtrzfyJR8iigzEZBths +eh0jKw+qtJEyEdLfGMqk9iF8TvIQY2g2A9rHhKJd9c19MU6BJy2m2IsS+hwr5bzz9 P15GC+kbXISVlRnLpSL0N91p5BRP/nlP2H1mK3HncsXz/btR1YMycWno7Efi1sECaC 73cA/dwY4xXkgUjgwoeC1AwQYk34KWeZxqgsg6OwHETkofD/qbI8ss/xFvkiUYxeTY A3Ixw3cOa+7Lw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4f2Ncd4BRjz4wDG; Fri, 30 Jan 2026 15:41:05 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 1/3] tcp: Retransmit FINs like data segments Date: Fri, 30 Jan 2026 15:41:02 +1100 Message-ID: <20260130044104.1793253-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130044104.1793253-1-david@gibson.dropbear.id.au> References: <20260130044104.1793253-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XNBJPUY5IA4FU4OOJXUVYCESFVC4PYHV X-Message-ID-Hash: XNBJPUY5IA4FU4OOJXUVYCESFVC4PYHV X-MailFrom: dgibson@gandalf.ozlabs.org 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: David Gibson 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: RFC 9293 doesn't distinguish between regular data segments and FIN segments for the purposes of retransmissions. Our existing retransmission logic will also work for FIN segments, except for one detail: we don't currently set the ACK_FROM_TAP_DUE flag when we send a FIN. Add the flag, so that we'll properly retransmit FIN segments like data segments. Remove the section from the theory of operation comment that describes a different way of handling FIN timeouts which (a) isn't correct behaviour and (b) doesn't appear to be implemented. I've tested this by adding logic to suppress sending the FIN if retries < some non-zero value. We correctly resend the FIN and close normally after the expected timeouts. Link: https://bugs.passt.top/show_bug.cgi?id=195 Signed-off-by: David Gibson --- tcp.c | 4 ---- tcp_buf.c | 1 + tcp_vu.c | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tcp.c b/tcp.c index 17e5b006..dbfde2e0 100644 --- a/tcp.c +++ b/tcp.c @@ -190,10 +190,6 @@ * - RTO_INIT_AFTER_SYN_RETRIES: if SYN retries happened during handshake and * RTO is less than this, re-initialise RTO to this for data retransmissions * - * - 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 - * the connection - * * - FIN_TIMEOUT: if a FIN segment was acknowledged by tap/guest and a FIN * segment (write shutdown) was sent via socket (events SOCK_FIN_SENT and * TAP_FIN_ACKED), but no socket activity is detected from the socket within diff --git a/tcp_buf.c b/tcp_buf.c index 5d419d36..d2925410 100644 --- a/tcp_buf.c +++ b/tcp_buf.c @@ -407,6 +407,7 @@ int tcp_buf_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) } conn_event(c, conn, TAP_FIN_SENT); + conn_flag(c, conn, ACK_FROM_TAP_DUE); } return 0; diff --git a/tcp_vu.c b/tcp_vu.c index db9db78a..b9e9b55e 100644 --- a/tcp_vu.c +++ b/tcp_vu.c @@ -425,6 +425,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) } conn_event(c, conn, TAP_FIN_SENT); + conn_flag(c, conn, ACK_FROM_TAP_DUE); } return 0; -- 2.52.0