public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Yumei Huang <yuhuang@redhat.com>
To: passt-dev@passt.top, sbrivio@redhat.com
Cc: david@gibson.dropbear.id.au, yuhuang@redhat.com
Subject: [PATCH 2/2] tcp: Resend SYN for inbound connections
Date: Sun, 28 Sep 2025 15:29:46 +0800	[thread overview]
Message-ID: <20250928072946.15284-3-yuhuang@redhat.com> (raw)
In-Reply-To: <20250928072946.15284-1-yuhuang@redhat.com>

If a client connects while guest is not connected or ready yet,
resend SYN instead of just resetting connection after SYN_TIMEOUT.

Signed-off-by: Yumei Huang <yuhuang@redhat.com>
---
 tcp.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tcp.c b/tcp.c
index 21b75a5..6fe8678 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2378,8 +2378,15 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref)
 		tcp_timer_ctl(c, conn);
 	} else if (conn->flags & ACK_FROM_TAP_DUE) {
 		if (!(conn->events & ESTABLISHED)) {
-			flow_dbg(conn, "handshake timeout");
-			tcp_rst(c, conn);
+			if (conn->retries == TCP_MAX_RETRANS){
+				flow_dbg(conn, "handshake timeout");
+				tcp_rst(c, conn);
+			} else {
+				flow_dbg(conn, "SYN timeout, retry");
+				tcp_send_flag(c, conn, SYN);
+				conn->retries++;
+				tcp_timer_ctl(c, conn);
+			}
 		} else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) {
 			flow_dbg(conn, "FIN timeout");
 			tcp_rst(c, conn);
-- 
2.47.0


  parent reply	other threads:[~2025-09-28  7:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-28  7:29 [PATCH 0/2] Retry SYNs " Yumei Huang
2025-09-28  7:29 ` [PATCH 1/2] tcp: Rename "retrans" of struct tcp_tap_conn and tcp_tap_transfer Yumei Huang
2025-09-29  6:06   ` David Gibson
2025-09-28  7:29 ` Yumei Huang [this message]
2025-09-29  6:25   ` [PATCH 2/2] tcp: Resend SYN for inbound connections David Gibson
2025-09-29 22:23     ` Stefano Brivio
2025-09-30  1:05       ` David Gibson
2025-09-30  6:04         ` Yumei Huang
2025-09-29 22:23   ` Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250928072946.15284-3-yuhuang@redhat.com \
    --to=yuhuang@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).