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=czT8O1qE; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 7B8725A0262 for ; Wed, 20 May 2026 22:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779309028; 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=k0j4ATtYV7KrOjNV/mIi7Ao902zpH1lO+3NSbdSvo2E=; b=czT8O1qEm8xgQ9/0/4rFRZOn7Se/frw6JNChCyFQyR0wHg2k8OkM6Mz+OR+Lz+A4YyIQZu 07Ci9FTf4bn/EVKEKIKUlWCga0U6vDYyns/ukDQvpS5yCBouRVZW81pCQ+OgEon3KGWxXH W3kDgPCg0D1883zK4n4g9lyWnHAsPJg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-L0cE3-hoMdOqSj5gV-_aGw-1; Wed, 20 May 2026 16:30:27 -0400 X-MC-Unique: L0cE3-hoMdOqSj5gV-_aGw-1 X-Mimecast-MFC-AGG-ID: L0cE3-hoMdOqSj5gV-_aGw_1779309026 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-45e55c44ac1so4291159f8f.0 for ; Wed, 20 May 2026 13:30:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779309025; x=1779913825; 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=k0j4ATtYV7KrOjNV/mIi7Ao902zpH1lO+3NSbdSvo2E=; b=legMC/wJSbEuNdv0sntHLoPQgmGDlBCz+UodGM+1+Q9+GlibYCfXYdRrV3zNwM4CP+ duaA3gx0tRbH/yjMQMw5lUbImrpU7a815g6AICTRdQDIrA2hVfX65b6RRPeRe3butJnC 5VkEvoPsxtqKOtJh+9WciBsOBydnAbHxTbqgHjc5gQEsQ0CnbWL7W7nm5W7hazaJ7VL0 eHcrvq/VFqJ5Q4foteCiUF2IhU+yA7HZWYqjpze5fEtftThIUMYHBEL54sHqKDhkZE7H sQcOff1TKfM1TZwiavYKRUtuqA7BdhmZ7omuhyTjmBbGi0F2hAquo3HYzE2vRV7mmKhX Meqg== X-Gm-Message-State: AOJu0YwdOqzc+JcYcUdaVa3u/6G/909fuiFffM1p22G3ivfVPxquWMUn t9iEyZ0n/aaJLNoAvyCsnFwhgPWoTZDa8R4+OtARkdnPPWglVoFhrsCmAiD3GA9Fi6x1syDYiI7 rEZueDJAeLxJHn/pN1emno951dxCXifpxZPbO5TdnyCSkj707noUiEmSU62PfLw== X-Gm-Gg: Acq92OE+u9orrf3NKnm8xxF3YSstNq7hZq5NUKe1vYitxLrX3MDMDI3cPGAEc26WJTv WvnzcrxgKHyoHWhsVkGYoGkZmYbjO7XufJYGBb+xA2f/JbY7W0POxLS9tr7m3NxPefnSn6hHqIT C1eOCsKQ2elLa/aOsu3Bi8D3g91jGLkXki5PMnAiD7FcfqLZddEgUrUdSFdYov8MF6uy6grSAyn 7gYy6GKzCTN/jzMIXvhCVxur5bcI5WM9d08OUIKKxpNLrZ6kbsylRe6uJ5ZJ9pLACf3BIoH1gZS kQzWl32qtEGA1LFcPp+qRjTpY6TUYFZiDtrYtNvE5VkWoVU1OGUOhoFYtKLhkHKlaY2BxId3yDP LqIxu11ox8HxZRtO9Q7zcrLqufkuac0WtCQOOR8KSaq3pDVRxMGANr2sqU8g5 X-Received: by 2002:a05:6000:2482:b0:454:811:9207 with SMTP id ffacd0b85a97d-45e5c5af469mr41394464f8f.17.1779309024984; Wed, 20 May 2026 13:30:24 -0700 (PDT) X-Received: by 2002:a05:6000:2482:b0:454:811:9207 with SMTP id ffacd0b85a97d-45e5c5af469mr41394425f8f.17.1779309024547; Wed, 20 May 2026 13:30:24 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a178adsm60108340f8f.18.2026.05.20.13.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 13:30:23 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 6/6] tcp_splice: Simplify shutdown(2) handling Message-ID: <20260520223022.43916fc2@elisabeth> In-Reply-To: <20260520130851.436931-7-david@gibson.dropbear.id.au> References: <20260520130851.436931-1-david@gibson.dropbear.id.au> <20260520130851.436931-7-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:30:23 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aehKrxTk-35epSgGAN3DsyL7D-Vbp5TDrgBKBo_Tq0M_1779309026 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: RIXLNJRIFFSZVKT5U27BHCS7N5DIBWOO X-Message-ID-Hash: RIXLNJRIFFSZVKT5U27BHCS7N5DIBWOO 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:51 +1000 David Gibson wrote: > At the end of tcp_splice_forward(), we check for half-closed connections > and propagate the FIN to the other side with a shutdown(2). Currently we > check for a half closed connection in either direction. That's unnecessary > here, because tcp_splice_forward() will already be called for each > direction if there are any relevant events. True, but do we have the guarantee that tcp_splice_forward() will also be called once all relevant FIN_RCVD / FIN_SENT flags have been sent? The reason why we check both sides here is that we might have updated flags for one side, and now we need to double check if it's time to call shutdown() as a consequence. Maybe we never have to, but I think it's not really obvious to prove. > > Signed-off-by: David Gibson > --- > tcp_splice.c | 22 ++++++++-------------- > 1 file changed, 8 insertions(+), 14 deletions(-) > > diff --git a/tcp_splice.c b/tcp_splice.c > index b45f0060..e5018f2e 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -582,21 +582,15 @@ retry: > break; > } > > - if (!conn->pending[fromsidei] && > - conn->events & FIN_RCVD(fromsidei)) { > - unsigned sidei; > - > - flow_foreach_sidei(sidei) { > - if ((conn->events & FIN_RCVD(sidei)) && > - !(conn->events & FIN_SENT(!sidei))) { > - if (shutdown(conn->s[!sidei], SHUT_WR) < 0) { > - flow_perror(conn, "shutdown() on %s", > - pif_name(conn->f.pif[!sidei])); > - return -1; > - } > - conn_event(conn, FIN_SENT(!sidei)); > - } > + if ((conn->events & FIN_RCVD(fromsidei)) && > + !(conn->events & FIN_SENT(!fromsidei)) && > + !conn->pending[fromsidei]) { > + if (shutdown(conn->s[!fromsidei], SHUT_WR) < 0) { > + flow_perror(conn, "shutdown() on %s", > + pif_name(conn->f.pif[!fromsidei])); > + return -1; > } > + conn_event(conn, FIN_SENT(!fromsidei)); > } > > return 0; -- Stefano