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 1/4] tcp: Split handling of DUP_ACK from ACK
Date: Tue, 26 Mar 2024 16:42:21 +1100	[thread overview]
Message-ID: <20240326054224.716874-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240326054224.716874-1-david@gibson.dropbear.id.au>

The DUP_ACK flag to tcp_send_flag() has two effects: first it forces the
setting of the ACK flag in the packet, even if we otherwise wouldn't.
Secondly, it causes a duplicate of the flags packet to be sent immediately
after the first.

Setting the ACK flag to tcp_send_flag() also has the first effect, so
instead of having DUP_ACK also do that, pass both flags when we need both
operations.  This slightly simplifies the logic of tcp_send_flag() in a way
that makes some future changes easier.

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

diff --git a/tcp.c b/tcp.c
index a1860d10..edd3d899 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1677,7 +1677,7 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 
 		th->ack = !!(flags & ACK);
 	} else {
-		th->ack = !!(flags & (ACK | DUP_ACK)) ||
+		th->ack = !!(flags & ACK)) ||
 			  conn->seq_ack_to_tap != prev_ack_to_tap ||
 			  !prev_wnd_to_tap;
 	}
@@ -2503,7 +2503,7 @@ out:
 		 */
 		if (conn->seq_dup_ack_approx != (conn->seq_from_tap & 0xff)) {
 			conn->seq_dup_ack_approx = conn->seq_from_tap & 0xff;
-			tcp_send_flag(c, conn, DUP_ACK);
+			tcp_send_flag(c, conn, ACK | DUP_ACK);
 		}
 		return p->count - idx;
 	}
-- 
@@ -1677,7 +1677,7 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
 
 		th->ack = !!(flags & ACK);
 	} else {
-		th->ack = !!(flags & (ACK | DUP_ACK)) ||
+		th->ack = !!(flags & ACK)) ||
 			  conn->seq_ack_to_tap != prev_ack_to_tap ||
 			  !prev_wnd_to_tap;
 	}
@@ -2503,7 +2503,7 @@ out:
 		 */
 		if (conn->seq_dup_ack_approx != (conn->seq_from_tap & 0xff)) {
 			conn->seq_dup_ack_approx = conn->seq_from_tap & 0xff;
-			tcp_send_flag(c, conn, DUP_ACK);
+			tcp_send_flag(c, conn, ACK | DUP_ACK);
 		}
 		return p->count - idx;
 	}
-- 
2.44.0


  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 ` David Gibson [this message]
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 ` [PATCH 4/4] tcp: Unconditionally force ACK for all !SYN, !RST packets David Gibson
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-2-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).