From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=NUL1iOax; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 103BE5A061A for ; Thu, 27 Feb 2025 06:55:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1740635720; bh=lKlu8pOhq+U5wmCDQJtY4RXjHPQe7ZlsUyAiDjRy9HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NUL1iOaxUPD03UpXOXdN2rnqW7/G0AOBkXt2s8xcQ/jJLzILFFIF/dK1JmXi1VnJT efPubdd/UJJPVwWrEvCgCDHGsGrsD9K5HA3U1GIED+Cqrzd0LTQyjhE2BQMq/wI+7S jRYKSdu6O0Kt5SQLFdnYexGjIu070kQtpZnjNFX9nBTdUSMy/oqYfBSPtFkjd+HbJ2 qSCAN4OZCmgTI/j2TFmEKMcOx4wCB+OmAWafq0Z6QeJk98dSoD0tD1jcJjBeBFvXzu xTmscSbWK63gZJIY9M/f1tudb+X/5zSbWxjKIoYLq9YPC0lcbAVZ49bAKxaEb8hPRM hfmiQBzA/56/A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Z3LCr0mf4z4x5f; Thu, 27 Feb 2025 16:55:20 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v4 4/5] tcp: Unconditionally move to CLOSED state on tcp_rst() Date: Thu, 27 Feb 2025 16:55:16 +1100 Message-ID: <20250227055517.497347-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250227055517.497347-1-david@gibson.dropbear.id.au> References: <20250227055517.497347-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: BNXEX2T6MWZZJAYW5Q7EXIGGKNAECCUN X-Message-ID-Hash: BNXEX2T6MWZZJAYW5Q7EXIGGKNAECCUN 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: 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_rst() attempts to send an RST packet to the guest, and if that succeeds moves the flow to CLOSED state. However, even if the tcp_send_flag() fails the flow is still dead: we've usually closed the socket already, and something has already gone irretrievably wrong. So we should still mark the flow as CLOSED. That will cause it to be cleaned up, meaning any future packets from the guest for it won't match a flow, so should generate new RSTs (they don't at the moment, but that's a separate bug). Signed-off-by: David Gibson --- tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index 8528ee35..d23b6d94 100644 --- a/tcp.c +++ b/tcp.c @@ -1214,8 +1214,8 @@ void tcp_rst_do(const struct ctx *c, struct tcp_tap_conn *conn) if (conn->events == CLOSED) return; - if (!tcp_send_flag(c, conn, RST)) - conn_event(c, conn, CLOSED); + tcp_send_flag(c, conn, RST); + conn_event(c, conn, CLOSED); } /** -- 2.48.1