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=202602 header.b=iZo39QDK; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 950D15A026E for ; Thu, 28 May 2026 07:02:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1779944535; bh=NJ3S72vsD2yHpOlBxS5Jbr6+ZOzTJ1ACinr4sz40aPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZo39QDKChdO8RCKwnpWscseod0Rahcm1wTLPVuR+xGXud9EREpOxD7pqwNJ7AkjL SmhOcSiApV3rx39Hs/2RYy8uDqKT9tbpMuXrsIO76dtEWR/qrSWjK3BWaA5Xx/KODI 4/bexRvo/55uOUF7zQsnvEgNvfYmcoZR/GtEX9YDF1tili2leuqKgRgeD+O41mFq07 tp0bMnCzEr+SyX8qgX+ecJz4tS6aDUVv0KhFx3+qOGyL5zDBEzTvGlTAYVqYDjSn89 r2YOZmuxICdaowd0mo3b/s4KziufSnc2vVt4bQN//vZK1i1F0J3EsRNesI6O+lprLm B7e5ZIUnWCmyg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gQvVb00vwz4wLq; Thu, 28 May 2026 15:02:14 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 3/8] tcp_splice: Improve EOF exit condition for the loop Date: Thu, 28 May 2026 15:02:08 +1000 Message-ID: <20260528050213.679685-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528050213.679685-1-david@gibson.dropbear.id.au> References: <20260528050213.679685-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 3HQPOOXXW5GUINY4LFMYVBB6YYGGZPEF X-Message-ID-Hash: 3HQPOOXXW5GUINY4LFMYVBB6YYGGZPEF 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: In tcp_splice_forward() we exit the forwarding loop if we have an EOF on the read side. However, this potentially leaves data in the pipe, even if the write side hasn't yet blocked. It's not clear to me whether this could leave data indefinitely in the pipe with no events to keep it moving, but it's not clear to me that it couldn't either. Stay in the loop until either the write side blocks or we've emptied the pipe. Secondly, this test is after several tests on how much we wrote which might also cause a retry. However, if we've reached EOF and the pipe is empty, there's nothing more to do, regardless of how much we wrote, so we should exit, regardless of those conditions. So move this exit test above the retry conditions. Signed-off-by: David Gibson --- tcp_splice.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tcp_splice.c b/tcp_splice.c index 25e5d097..943dc214 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -543,15 +543,16 @@ retry: break; } + if (conn->events & FIN_RCVD(fromsidei) && + !conn->pending[fromsidei]) + break; + if (never_read && written == (long)(c->tcp.pipe_size)) goto retry; if (!never_read && written > 0 && written < conn->pending[fromsidei]) goto retry; - - if (conn->events & FIN_RCVD(fromsidei)) - break; } if (!conn->pending[fromsidei] && -- 2.54.0