public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Jason Chu <jaschu@janestreet.com>
Cc: passt-dev@passt.top, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] tcp: Keep window from tap below MAX_WINDOW
Date: Tue, 24 Nov 2026 13:14:43 +0100 (CET)	[thread overview]
Message-ID: <20261124131443.4f55445e@elisabeth> (raw)
In-Reply-To: <20261123211602.3188010-1-jaschu@janestreet.com>

On Mon, 23 Nov 2026 16:16:00 -0500
Jason Chu <jaschu@janestreet.com> wrote:

> In tcp_internal.h, SEQ_GE(a, b) checks
> (uint32_t)(a) - (uint32_t)(b) < MAX_WINDOW, so a sequence number
> exactly MAX_WINDOW (16 MiB) ahead is treated as out of range.
> 
> tcp_tap_window_update() clamps the advertised window from tap to
> MAX_WINDOW inclusive, and pasta sends up to that full window. If the
> peer negotiates a window scale above MAX_WS (9 to 14) and advertises
> at least 16 MiB, pasta can put exactly MAX_WINDOW bytes in flight.
> When the peer acknowledges all of them in one ACK, tcp_data_from_tap()
> fails SEQ_GE(ack_seq, conn->seq_ack_from_tap) and ignores the ACK.
> pasta then rewinds on each ACK timeout and retransmits the same 16 MiB,
> which the peer drops as duplicate data while repeating the same ACK,
> so the connection stalls.
> 
> We hit this on Linux with a raised net.ipv4.tcp_rmem maximum (and it
> also reproduces via SO_RCVBUF) when the receiver pauses while more
> than 16 MiB arrives. In that case the kernel only sends a delayed ACK,
> and pasta delivers all 16 MiB before the delayed ACK timer fires.
> With a 6 MiB tcp_rmem maximum, the default on older kernels, the peer
> uses a window scale of 7 and the window never reaches 16 MiB. Current
> kernels default to up to 32 MiB, which we haven't tested.
> 
> Clamp the window in tcp_tap_window_update() to MAX_WINDOW - 1 instead.
> For window scales 9 to 14, the right shift rounds the stored window
> down by one scale unit, keeping every valid ACK within SEQ_GE() range.
> Window scales up to MAX_WS cannot represent MAX_WINDOW anyway.
> 
> Assisted-by: Claude:claude-fable-5-2
> Signed-off-by: Jason Chu <jaschu@janestreet.com>

Wow, crazy that this can actually happen, I couldn't imagine.  On the
other hand, if the receiver pauses for long enough, that might obviously
becomes the case.

Thanks for the report and for the fix, applied.  Welcome to the git log!

-- 
Stefano


      reply	other threads:[~2026-11-24 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 21:16 Jason Chu
2026-11-24 12:14 ` Stefano Brivio [this message]

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=20261124131443.4f55445e@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=jaschu@janestreet.com \
    --cc=passt-dev@passt.top \
    /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).