public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: maxi.rostock@outlook.de, pholzing@redhat.com,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 4/4] tcp: Unconditionally force ACK for all !SYN, !RST packets
Date: Tue, 26 Mar 2024 16:42:24 +1100	[thread overview]
Message-ID: <20240326054224.716874-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240326054224.716874-1-david@gibson.dropbear.id.au>

Currently we set ACK on flags packets only when the acknowledged byte
pointer has advanced, or we hadn't previously set a window.  This means
in particular that we can send a window update with no ACK flag, which
doesn't appear to be correct.  RFC 9293 requires a receiver to ignore such
a packet [0], and indeed it appears that every non-SYN, non-RST packet
should have the ACK flag.

The reason for the existing logic, rather than always forcing an ACK seems
to be to avoid having the packet mistaken as a duplicate ACK which might
trigger a fast retransmit.  However, earlier tests in the function mean we
won't reach here if we don't have either an advance in the ack pointer -
which will already set the ACK flag, or a window update - which shouldn't
trigger a fast retransmit.

[0] https://www.ietf.org/rfc/rfc9293.html#section-3.10.7.4-2.5.2.1

Link: https://github.com/containers/podman/issues/22146
Link: https://bugs.passt.top/show_bug.cgi?id=84

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 tcp.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tcp.c b/tcp.c
index b65ddeb5..28562b7f 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1593,8 +1593,6 @@ static void tcp_update_seqack_from_tap(const struct ctx *c,
  */
 static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 {
-	uint32_t prev_ack_to_tap = conn->seq_ack_to_tap;
-	uint32_t prev_wnd_to_tap = conn->wnd_to_tap;
 	struct tcp4_l2_flags_buf_t *b4 = NULL;
 	struct tcp6_l2_flags_buf_t *b6 = NULL;
 	struct tcp_info tinfo = { 0 };
@@ -1675,9 +1673,7 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 		*data++ = OPT_WS_LEN;
 		*data++ = conn->ws_to_tap;
 	} else if (!(flags & RST)) {
-		if (conn->seq_ack_to_tap != prev_ack_to_tap ||
-		    !prev_wnd_to_tap)
-			flags |= ACK;
+		flags |= ACK;
 	}
 
 	th->doff = (sizeof(*th) + optlen) / 4;
-- 
@@ -1593,8 +1593,6 @@ static void tcp_update_seqack_from_tap(const struct ctx *c,
  */
 static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 {
-	uint32_t prev_ack_to_tap = conn->seq_ack_to_tap;
-	uint32_t prev_wnd_to_tap = conn->wnd_to_tap;
 	struct tcp4_l2_flags_buf_t *b4 = NULL;
 	struct tcp6_l2_flags_buf_t *b6 = NULL;
 	struct tcp_info tinfo = { 0 };
@@ -1675,9 +1673,7 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 		*data++ = OPT_WS_LEN;
 		*data++ = conn->ws_to_tap;
 	} else if (!(flags & RST)) {
-		if (conn->seq_ack_to_tap != prev_ack_to_tap ||
-		    !prev_wnd_to_tap)
-			flags |= ACK;
+		flags |= ACK;
 	}
 
 	th->doff = (sizeof(*th) + optlen) / 4;
-- 
2.44.0


  parent reply	other threads:[~2024-03-26  5:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26  5:42 [PATCH 0/4] Corrections to seeting of ACK flag in TCP packets David Gibson
2024-03-26  5:42 ` [PATCH 1/4] tcp: Split handling of DUP_ACK from ACK David Gibson
2024-03-26  5:42 ` [PATCH 2/4] tcp: Rearrange logic for setting ACK flag in tcp_send_flag() David Gibson
2024-03-26  5:42 ` [PATCH 3/4] tcp: Never automatically add the ACK flag to RST packets David Gibson
2024-03-26  5:42 ` David Gibson [this message]
2024-03-26  8:54 ` [PATCH 0/4] Corrections to seeting of ACK flag in TCP packets 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=20240326054224.716874-5-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=maxi.rostock@outlook.de \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    --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).