From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=icSvgkyG; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 537155A0262 for ; Wed, 20 May 2026 22:28:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779308922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cltXxMjH7pccSxzwtFQUB6KQsVtd0S7EA+Ll+aj2XZI=; b=icSvgkyGdRGqtlyZhUEjydqFGO1YUyHSPHbweEqJTOyhnOkMH9INgErO7elZiWPWfGqzW7 GIoLXRyiB1pX1+Eg+amedXSimUlKFrjQuPoJUzvJCdXUW1q4j+JoPHAvcEEeGHYjSDuo+l hyp4cYMgWuIdSgd5W61Bc5uGzozgZI4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-2jO3TIm_P1GT27-yZ8wJFA-1; Wed, 20 May 2026 16:28:39 -0400 X-MC-Unique: 2jO3TIm_P1GT27-yZ8wJFA-1 X-Mimecast-MFC-AGG-ID: 2jO3TIm_P1GT27-yZ8wJFA_1779308919 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-44f56d5523eso5145837f8f.1 for ; Wed, 20 May 2026 13:28:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779308918; x=1779913718; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cltXxMjH7pccSxzwtFQUB6KQsVtd0S7EA+Ll+aj2XZI=; b=OmTfEqGHsXHF/iDrXAfST3BV5pAK6lL21S2OKZPpeRunLH3M35DxfuIYCdgLrOyixg rKnuKUFSeUFrTwvHQ7qayze9oUg8fZgXGXeVa9tg3Tcy3T/9am+E4dsrUOvj4ZT4yb50 6GEHAiiEd8VVnYkiLeQ63DlbrEOmPDYinXWvJ3n06SGq2WFg6EeRscuDJIAIsd1M/bX4 P1CJfZUkSDZUGJTIt4gF0jud2JFmWl2KSSJ3RRsKKm/unWDMdfrEmsXgsWkPLPgUMwNF g77LCdzqvTSBVJHix9lxRlluksQn3GscU8RjIW6tFq7CS11HXgJwJlIj9sr6AV0hcqo8 FALQ== X-Gm-Message-State: AOJu0Yz3RKHVgONnUpw9zTjS1n+dKeFrl2qpU6p+emnMBziOEu0irelc JGrSkzYS/3jRqXbROiZOAy5kUhBxJYMmdpVtGvDxfuGO5DDJHCMEirZOuTo8EiYLPqYRqxakwcH PkyUufoVASlKHgPAYN5svNFdy10/KwHBe04sWA+VrzTzX5sHyYbVc8Q== X-Gm-Gg: Acq92OHQGzvRS/nIK9pBWI2I4+sqH43I2aoaVdvVzLsOeUp1MtPhRlIGmKY8+CnThTD qFbyGj1r7woeiUCH/hgUbTuqexY3k5i2pJUdvIvhXiGwXbeERGG6AfTj+r/c4QIPiM8/DFmp8vx 31yo4lSbDD3nJykYLe0ApHO9otOpT0EKHPevILtO6ODxa+p4BvqPjyds5SF9R4uIkCafZL76JLX PWC/INxzBIZr6wp0y62HLWS9pUa/Ut2Xy76Uf+/s7ua2WgwGTWrPLfFfH4m09oRjPcnwZdNnvXY 8pGRWHlAznO/mJqX/fc2HOevc2tR0qr8d18vXrfouLODUA+/2uYzRVkgGtO+MkA+6r5LCfd/fgQ MBB7XBN/LrfPfOHPPdU/pfYXx+fMCL6m9OJlCoOB3sfsfudmZiabWR7lJA4YA X-Received: by 2002:a05:600c:8184:b0:48f:d1b8:9aa5 with SMTP id 5b1f17b1804b1-48fe60ecd7dmr384102425e9.8.1779308918456; Wed, 20 May 2026 13:28:38 -0700 (PDT) X-Received: by 2002:a05:600c:8184:b0:48f:d1b8:9aa5 with SMTP id 5b1f17b1804b1-48fe60ecd7dmr384102095e9.8.1779308917899; Wed, 20 May 2026 13:28:37 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49033d4be58sm12837265e9.9.2026.05.20.13.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 13:28:37 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/6] tcp_splice: Avoid missing EOF recognition while forwarding Message-ID: <20260520222835.768600be@elisabeth> In-Reply-To: <20260520130851.436931-3-david@gibson.dropbear.id.au> References: <20260520130851.436931-1-david@gibson.dropbear.id.au> <20260520130851.436931-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Wed, 20 May 2026 22:28:36 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Vc_ZluxrNj5Np3i0VSxV1KhTam8ssdzKjABjmY5f8F0_1779308919 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: BUEH44OOLGAMQZN3ZN4T3IHNRFLTKNYL X-Message-ID-Hash: BUEH44OOLGAMQZN3ZN4T3IHNRFLTKNYL X-MailFrom: sbrivio@redhat.com 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: passt-dev@passt.top, Paul Holzinger 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: On Wed, 20 May 2026 23:08:47 +1000 David Gibson wrote: > tcp_splice_sock_handler() has an optimised path for the common case where > the amount we splice(2) into the pipe is exactly the same as the amount we > splice(2) out again. If the pipe is empty at that point, we stop > forwarding until we get another epoll event. > > However, via a subtle chain of events, this can cause a bug for a > half-closed connection. Suppose the connection is already half-closed in > the other direction - that is, we've already called shutdown(SHUT_WR) on > the socket for which we're getting the event. In this event we're getting > the last batch of data in the other direction, and also a FIN. This can > result in EPOLLIN, EPOLLRDHUP and EPOLLHUP events simultaneously. > > We read the last data from the socket and successfully splice it to the > other side. Since there is no data in the pipe, we exit the forwarding > loop. However, because we did read data, we don't set the eof flag. > > Because we don't set eof, we don't (yet) propagate the FIN to the other > side, or set FIN_SENT_(!fromsidei). Therefore we don't (yet) recognize > this as a clean termination and set the CLOSING flag. We would correct > this when we get our next event, however before we can do so we process > the EPOLLHUP event. Because we haven't recognized this as a clean close > we assume it is an abrupt close and send an RST to the other side. > > To avoid this, don't stop attempting to forward data on this path. > Continue for at least one more loop. If we're at EOF, we'll recognize it > on the next splice(2). If not it gives us an opportunity to forward more > data without returning to the mail epoll loop. Oops. The fix looks correct to me, but I wonder: is it clear to you why the issue only started occurring in this release? This code had "always" been there. I see a few possible directions but I'm not quite sure. Not that important anyway, if you could reproduce the issue and this fixes it. Just one nit: > Link: https://bugs.passt.top/show_bug.cgi?id=202 > Signed-off-by: David Gibson Reported-by: Paul Holzinger > --- > tcp_splice.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tcp_splice.c b/tcp_splice.c > index 1359d6b8..34ffea73 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -605,7 +605,7 @@ retry: > } > } > > - break; > + continue; > } > > conn->read[fromsidei] += readlen > 0 ? readlen : 0; -- Stefano