From 5894a245b93f3c848c3a42d1c625eef3656b2eec Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 26 Mar 2024 16:42:23 +1100 Subject: tcp: Never automatically add the ACK flag to RST packets 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 Signed-off-by: Stefano Brivio --- tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcp.c b/tcp.c index 47954d1..b65ddeb 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; -- cgit v1.2.3