From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 2/4] tcp: Completely ignore data segment in CLOSE-WAIT state, log a message
Date: Thu, 2 Oct 2025 12:44:08 +1000 [thread overview]
Message-ID: <aN3m-C8ktv9ZISmb@zatzit> (raw)
In-Reply-To: <20251002000646.2136202-3-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3030 bytes --]
On Thu, Oct 02, 2025 at 02:06:44AM +0200, Stefano Brivio wrote:
> According to RFC 9293 we should ignore data (note: not data segments)
> in CLOSE-WAIT state (indicated by TAP_FIN_RCVD), see 3.10.7.4
> "Other states":
>
> [...]
>
> Seventh, process the segment text:
>
> [...]
>
> CLOSE-WAIT STATE
>
> This should not occur since a FIN has been received from the remote
> side. Ignore the segment text.
>
> and we almost do that, except that we would look at the data length
> to decide whether it's a request for fast re-transmission, so fix
> that, and while at it, log a message, so that cases such as the
> following one are more apparent in debug logs:
>
> 28692 0.009758 88.198.0.164 → 93.235.151.95 54 TCP 55414 → 47080 [FIN, ACK] Seq=121441 Ack=141 Win=65536 Len=0
>
> we should ignore this FIN flag, because we didn't accept data up
> to this sequence (see next segment), but we don't do it, so, here:
>
> 28693 0.000036 93.235.151.95 → 88.198.0.164 54 TCP 47080 → 55414 [ACK] Seq=141 Ack=90722 Win=32128 Len=0
> 28694 0.034597 93.235.151.95 → 88.198.0.164 54 TCP 47080 → 55414 [FIN, ACK] Seq=141 Ack=90722 Win=121216 Len=0
> 28695 0.000019 88.198.0.164 → 93.235.151.95 54 TCP 55414 → 47080 [ACK] Seq=121442 Ack=142 Win=65536 Len=0
> 28696 0.162968 88.198.0.164 → 93.235.151.95 30773 TCP [TCP Retransmission] 55414 → 47080 [FIN, PSH, ACK] Seq=90722 Ack=142 Win=65536 Len=30719 [TCP segment of a reassembled PDU]
>
> we are erroneously in CLOSE-WAIT (TAP_FIN_RCVD) state, and this
> segment would look pretty strange there.
>
> This specific case is fixed by the next patch, so it should never
> happen again.
>
> Link: https://archives.passt.top/passt-dev/20250910115726.432bbb8d@elisabeth/
> Link: https://bugs.passt.top/show_bug.cgi?id=126
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tcp.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tcp.c b/tcp.c
> index 48b1ef2..3f7dc82 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -2130,9 +2130,15 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
>
> /* Established connections not accepting data from tap */
> if (conn->events & TAP_FIN_RCVD) {
> + size_t dlen;
> bool retr;
>
> - retr = th->ack && !tcp_packet_data_len(th, l4len) && !th->fin &&
> + if ((dlen = tcp_packet_data_len(th, l4len))) {
> + flow_dbg(conn, "data segment in CLOSE-WAIT (%zu B)",
> + dlen);
> + }
> +
> + retr = th->ack && !th->fin &&
> ntohl(th->ack_seq) == conn->seq_ack_from_tap &&
> ntohs(th->window) == conn->wnd_from_tap;
>
> --
> 2.43.0
>
--
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 --]
next prev parent reply other threads:[~2025-10-02 2:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 0:06 [PATCH 0/4] tcp: Fix bad switch to CLOSE-WAIT state and surrounding issues Stefano Brivio
2025-10-02 0:06 ` [PATCH 1/4] tcp: Fix ACK sequence on FIN to tap Stefano Brivio
2025-10-02 2:41 ` David Gibson
2025-10-02 11:58 ` Stefano Brivio
2025-10-03 3:19 ` David Gibson
2025-10-06 22:32 ` Stefano Brivio
2025-10-06 23:31 ` David Gibson
2025-10-02 0:06 ` [PATCH 2/4] tcp: Completely ignore data segment in CLOSE-WAIT state, log a message Stefano Brivio
2025-10-02 2:44 ` David Gibson [this message]
2025-10-02 0:06 ` [PATCH 3/4] tcp: Don't consider FIN flags with mismatching sequence Stefano Brivio
2025-10-02 2:52 ` David Gibson
2025-10-02 3:02 ` David Gibson
2025-10-02 11:51 ` Stefano Brivio
2025-10-03 3:43 ` David Gibson
2025-10-06 22:32 ` Stefano Brivio
2025-10-06 23:34 ` David Gibson
2025-10-02 0:06 ` [PATCH 4/4] tcp: On partial send (incomplete sendmsg()), request a retransmission right away Stefano Brivio
2025-10-02 3:00 ` David Gibson
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=aN3m-C8ktv9ZISmb@zatzit \
--to=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).