From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 971245A0272 for ; Tue, 26 Mar 2024 06:42:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1711431746; bh=4C4eccsFRec8r8hs1T52JrtjF7P/tkLC1cvaJZm27VQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyJoAkP/X9UYMwK85EiFNA/nciDTlOE9UMuBKBDMVhU36Z64dCblOWnQPLQGTDHzK 1nLBZW3+Xu9n4+HSHk7ifsJ0yeDrOQjy6p0uzdpKZ3OrgIP/RviZBSMnsigx+F4RZC ie6w1j3Y0xxpe6jMEdNGIAfb2HwJCmJl8SFe/J4kvjCx+0zn3XsrArWPPQaPMCNZJU yXC0EZo8KSLyls259XQqG1hJDWS4glNDchqBRsekIcChQKl2Vr9fqeVu0TG99AZweg gLC6i3S8LFrf8lF2bUKMtGune7/jbrLApNIP1I2x7PLT0F4UwjaTuskzbwyIiuigur /AfIPTWVglTZg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4V3dwy6Cjmz4wqN; Tue, 26 Mar 2024 16:42:26 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 3/4] tcp: Never automatically add the ACK flag to RST packets Date: Tue, 26 Mar 2024 16:42:23 +1100 Message-ID: <20240326054224.716874-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326054224.716874-1-david@gibson.dropbear.id.au> References: <20240326054224.716874-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: Z64X3OI2C5HIWFLSII3RKSWBDZ6JZXXD X-Message-ID-Hash: Z64X3OI2C5HIWFLSII3RKSWBDZ6JZXXD X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: maxi.rostock@outlook.de, pholzing@redhat.com, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: tcp_send_flag() will sometimes force on the ACK flag for all !SYN packets. This doesn't make sense for RST packets, where plain RST and RST+ACK have somewhat different meanings. AIUI, RST+ACK indicates an abrupt end to a connection, but acknowledges data already sent. Plain RST indicates an abort, when one end receives a packet that doesn't seem to make sense in the context of what it knows about the connection. All of the cases where we send RSTs are the second, so we don't want an ACK flag, but we currently could add one anyway. Change that, so we won't add an ACK to an RST unless the caller explicitly requests it. Signed-off-by: David Gibson --- tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcp.c b/tcp.c index 47954d11..b65ddeb5 100644 --- a/tcp.c +++ b/tcp.c @@ -1674,7 +1674,7 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags) *data++ = OPT_WS; *data++ = OPT_WS_LEN; *data++ = conn->ws_to_tap; - } else { + } else if (!(flags & RST)) { if (conn->seq_ack_to_tap != prev_ack_to_tap || !prev_wnd_to_tap) flags |= ACK; -- 2.44.0