public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] tcp: Implement conservative zero-window probe on ACK timeout
@ 2025-02-11 19:51 Stefano Brivio
  2025-02-12  0:44 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2025-02-11 19:51 UTC (permalink / raw)
  To: passt-dev; +Cc: David Gibson, Jon Maloy

This probably doesn't cover all the cases where we should send a
zero-window probe, but it's rather unobtrusive and obvious, so start
from here, also because I just observed this case (without the fix
from the previous patch, to take into account window information from
keep-alive segments).

If we hit the ACK timeout, and try re-sending data from the socket,
if the window is zero, we'll just fail again, go back to the timer,
and so on, until we hit the maximum number of re-transmissions and
reset the connection.

Don't do that: forcibly try to send something by implementing the
equivalent of a zero-window probe in this case.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 tcp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tcp.c b/tcp.c
index 2addf4a..b87478f 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2175,6 +2175,8 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref)
 			flow_dbg(conn, "ACK timeout, retry");
 			conn->retrans++;
 			conn->seq_to_tap = conn->seq_ack_from_tap;
+			if (!conn->wnd_from_tap)
+				conn->wnd_from_tap = 1; /* Zero-window probe */
 			if (tcp_set_peek_offset(conn->sock, 0)) {
 				tcp_rst(c, conn);
 			} else {
-- 
@@ -2175,6 +2175,8 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref)
 			flow_dbg(conn, "ACK timeout, retry");
 			conn->retrans++;
 			conn->seq_to_tap = conn->seq_ack_from_tap;
+			if (!conn->wnd_from_tap)
+				conn->wnd_from_tap = 1; /* Zero-window probe */
 			if (tcp_set_peek_offset(conn->sock, 0)) {
 				tcp_rst(c, conn);
 			} else {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tcp: Implement conservative zero-window probe on ACK timeout
  2025-02-11 19:51 [PATCH] tcp: Implement conservative zero-window probe on ACK timeout Stefano Brivio
@ 2025-02-12  0:44 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2025-02-12  0:44 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev, Jon Maloy

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

On Tue, Feb 11, 2025 at 08:51:00PM +0100, Stefano Brivio wrote:
> This probably doesn't cover all the cases where we should send a
> zero-window probe, but it's rather unobtrusive and obvious, so start
> from here, also because I just observed this case (without the fix
> from the previous patch, to take into account window information from
> keep-alive segments).
> 
> If we hit the ACK timeout, and try re-sending data from the socket,
> if the window is zero, we'll just fail again, go back to the timer,
> and so on, until we hit the maximum number of re-transmissions and
> reset the connection.
> 
> Don't do that: forcibly try to send something by implementing the
> equivalent of a zero-window probe in this case.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tcp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tcp.c b/tcp.c
> index 2addf4a..b87478f 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -2175,6 +2175,8 @@ void tcp_timer_handler(const struct ctx *c, union epoll_ref ref)
>  			flow_dbg(conn, "ACK timeout, retry");
>  			conn->retrans++;
>  			conn->seq_to_tap = conn->seq_ack_from_tap;
> +			if (!conn->wnd_from_tap)
> +				conn->wnd_from_tap = 1; /* Zero-window probe */
>  			if (tcp_set_peek_offset(conn->sock, 0)) {
>  				tcp_rst(c, conn);
>  			} else {

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-12  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-11 19:51 [PATCH] tcp: Implement conservative zero-window probe on ACK timeout Stefano Brivio
2025-02-12  0:44 ` David Gibson

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).