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=cGAUKjIH; 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 784715A026F for ; Tue, 30 Sep 2025 00:23:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759184620; 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=7tyGklUETe7iHS6yPHMOftX7jjnMkzJwenWJyVBbssc=; b=cGAUKjIHXOyt3H0/wvQKnjEIYgAuKwZUvnjNmav7z3on5vFM1YBlgzx4eJ+DChxN2WIxhx uD9qQMkWJZHs9a1ZWMlKv4Ema104BTBen0vmfrVE8CSiWKda1uuYjWiPLDElFpxM9Tg9qT tnVn2BRWnJmjla7tyegs/L2OSCwvAs8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-2G7kS4OHNyqxd0iALfMhIQ-1; Mon, 29 Sep 2025 18:23:39 -0400 X-MC-Unique: 2G7kS4OHNyqxd0iALfMhIQ-1 X-Mimecast-MFC-AGG-ID: 2G7kS4OHNyqxd0iALfMhIQ_1759184618 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ece0fd841cso2911408f8f.0 for ; Mon, 29 Sep 2025 15:23:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759184617; x=1759789417; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7tyGklUETe7iHS6yPHMOftX7jjnMkzJwenWJyVBbssc=; b=Eidta++HqSqEX3lozjFg7OhHg7q8ccdQG5w9w0qIQwNOgK0qKqf73tuB+bmWjWxPnG fQY6s/WquWmoBiaKOVWwHoyQPxGAFTwgVbNIVJqMh3rqOC1yI3aVyJmLFhCPGUlHW59g 8F+XURV4lY23qojsAUPP3p2ymHpdQokjcbN5XZ8Yb9WxKb8ZRxIoC9XRM/tTnKdQWLUd kvJCfeW9tAOzknd3wE02wMcHRkWRSx8Nbnfu7FqtXj7bxLYAX01SopdB89Ebvx0dU988 arV/YnmGRl8Yf1LxrgHtNK+U7mxjc5jeAHJKnKwNSnNrfCNv1HU1DL+SAkonIUUmUPL9 Hbgw== X-Gm-Message-State: AOJu0YxRO8HV98aAhBxMuDeywsdzco9ojt8btGucFPHPD4cKXV1iMqt9 eyuJm+PS5N1Z/1dxd3egOQVszYP9lakSDnHr378BAdrtN+B5HdG8SabnC3QB1xNXyv27x7p/8l8 Ee3wuA8MMnZFMillAjVSESgkLyXyg3NhbfqE25XV72fSRJvkaaDj3CkVGuTvTGA== X-Gm-Gg: ASbGncsdnE+fbXoELrG5E+1lh1U3NRl46IPzRC17gU1KuiaTALjidLxIKMjpBrYtpKr ONIGUkaCQsb0jdAoLzt4ozgA8HQw00hPqHkOd8l0xHshzeChAFHQIp3f/2cTqGfMyDoCYlfhVR3 tM0IJdBEqm5Po2RjxWrbIYV8yWWgJRP247jfuD+k/Q6Rtf0fJ93K6xfeTb8OXBWFl7SEinm4Y3j v+6N9ePL1omX5TN+SyUzWJulsBxL55mzU0+oV6Mt/rOvoNEHrIXs0vYx9A3x2qXGYudDo6P4zHy A4IFTqnKdslnkM4xrCohYmNW3/P9rhhO0D192RKFeBsdAvrwEbjN3vONe/g3hiIgyGqs X-Received: by 2002:a05:6000:2585:b0:3ee:15b4:174c with SMTP id ffacd0b85a97d-40e4486c164mr15891443f8f.3.1759184617477; Mon, 29 Sep 2025 15:23:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGd1yxr9D2m9aOxnWzH8H2ounPAKrO3olh0FGcuMjzymPvUkLZg2GwPD6kUVSiQAZoLNZwv1A== X-Received: by 2002:a05:6000:2585:b0:3ee:15b4:174c with SMTP id ffacd0b85a97d-40e4486c164mr15891430f8f.3.1759184617007; Mon, 29 Sep 2025 15:23:37 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fb72fbb27sm19650374f8f.4.2025.09.29.15.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Sep 2025 15:23:36 -0700 (PDT) Date: Tue, 30 Sep 2025 00:23:30 +0200 From: Stefano Brivio To: Yumei Huang Subject: Re: [PATCH 2/2] tcp: Resend SYN for inbound connections Message-ID: <20250930002330.5c3cf866@elisabeth> In-Reply-To: <20250928072946.15284-3-yuhuang@redhat.com> References: <20250928072946.15284-1-yuhuang@redhat.com> <20250928072946.15284-3-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: uOJpfFDAwLLHtI_DpHKk0v2mRcHoFiYTcJ-4i7Vjot8_1759184618 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: WUQBTGDZ6S7K46MGWYYJB7QQWXXIMVFG X-Message-ID-Hash: WUQBTGDZ6S7K46MGWYYJB7QQWXXIMVFG 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 Sun, 28 Sep 2025 15:29:46 +0800 Yumei Huang wrote: > 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 > --- > 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){ Nit: missing whitespace between ) and {. Now that you use conn->retries for this purpose as well, I guess you should either rename TCP_MAX_RETRANS to TCP_MAX_RETRIES, or use another constant. This also depends on the timing behaviour we want to have here, see the other part of the thread. In any case, you should update the "Theory of Operation" documentation at the top of tcp.c, see the "Aging and timeout" section. > + flow_dbg(conn, "handshake timeout"); > + tcp_rst(c, conn); > + } else { > + flow_dbg(conn, "SYN timeout, retry"); > + tcp_send_flag(c, conn, SYN); > + conn->retries++; You should reset this to zero once the connection is established, otherwise we might start the connection with a value of conn->retries that indicates that we already retransmitted data a number of times, even if we didn't. > + 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); -- Stefano