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=ivE9de0L; 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 B05455A0265 for ; Thu, 21 May 2026 07:40:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779342042; 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=2QN1YQ8ko3ak2M8W8hvltJxsXnvno+JEa3g4uV/vQaU=; b=ivE9de0LGNprrIqenmK9sTqoANlAqyHXuOYVUx9FrdXbajtxA0a4rmJ2bSGE02Po82YnNM pEhf5Iic5DG2ntzOkM0ukBSUSSFhXds4y4q3GLktJKIIVUAxr0h7Vn6TCov0sohTUEG6SL rlFSwvtEcCXDiFUSbobCDqS8v7GXVJo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-sNntFLohMDOWcA7wE12RAQ-1; Thu, 21 May 2026 01:40:40 -0400 X-MC-Unique: sNntFLohMDOWcA7wE12RAQ-1 X-Mimecast-MFC-AGG-ID: sNntFLohMDOWcA7wE12RAQ_1779342040 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-48eb0da933fso40839675e9.0 for ; Wed, 20 May 2026 22:40:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779342039; x=1779946839; 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=2QN1YQ8ko3ak2M8W8hvltJxsXnvno+JEa3g4uV/vQaU=; b=K+0q3KAIqaQNope+ThpRF1oou2v34VogShRdH4F/9LzR6UeMgVFdeSG+etp31b4EGY 0VaH0NQD/u2c2avRJ+CLEDeYhfol07xj1BpvtU5CpnQEvzyBq210w9PKpuMdSX97nows PfG/RGuGvS6pljPxLbGuHL7hFOUwulqtkGcvE/DfwejzNZgTG/iIFQ4CZbHqYL/RvH52 ccfleII9k5iYMTagnog8q1CTrO0Wvh1LJY5zsFj7KJpBvpx60LHzAf0dE1Td2nHSJPiW Rqu8Tz9P2F4Zv7+omIkKdwCWU1n+ov2P9AUnGLZIny+EKriPwlB77RzpWZlLhRhwBHWQ ILLA== X-Gm-Message-State: AOJu0Yy2WKmFA3VlnHqmRyo4ZS5acIOOah5ytvhmX1S0qEbHFWI6o/EV 7oRt0+eTODRc/M+C7bulPdOEdJ4Mc4lMkWz8aOH5jUKm7pECjFv8a226Yzm7bzh4pzTGfoRwuWD 9+Pl2hFWwIiKCPKfG8foNBkc6Ml8cCRyNf1I0mMzqWUXwUO7ChLrdqwaKZoiCjw== X-Gm-Gg: Acq92OEeEZDsRICrF5fEjdDArBrMHTLShBPmVwezEELV9aqyyflQckDSeJS73woQwGp oHBQ+sz3ZTUT++VoxYcEHv4MEO55O8SWcuhQzCkTids8AYo19IKVoMUGLwYYZqUngY9HCCEnUD+ lh8w9sUUj5SwXBniAMoAUsY+XxlZuEqSS+1EIQIqUfSRg4UP0525lkIdmOCLyzq5/zCLgUXN8Ui GefM9INshv3p3mE6ogObo+o3o3OdKWWx6pNgMzU+aPvRz1YXu2GxeUS8GZD7k8exUVqAzDRzFwn QlUUoU7sAvsbm0DUqfNd8eKUiT2rGDCMbtSfAAV9ojXvNYebw3WNMc13icqR97cBqDEXm5vtTeC HGhmGl5LYe652GbIs7tfTHUYrc+qYjVbV9FTgyd2WD/h5IhFFLw== X-Received: by 2002:a05:600c:4445:b0:48f:d1b8:9aa5 with SMTP id 5b1f17b1804b1-4903605494fmr15749795e9.8.1779342039243; Wed, 20 May 2026 22:40:39 -0700 (PDT) X-Received: by 2002:a05:600c:4445:b0:48f:d1b8:9aa5 with SMTP id 5b1f17b1804b1-4903605494fmr15749205e9.8.1779342038651; Wed, 20 May 2026 22:40:38 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49033d3e9cbsm33470805e9.4.2026.05.20.22.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 22:40:37 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 6/6] tcp_splice: Simplify shutdown(2) handling Message-ID: <20260521074035.0fe217d5@elisabeth> In-Reply-To: References: <20260520130851.436931-1-david@gibson.dropbear.id.au> <20260520130851.436931-7-david@gibson.dropbear.id.au> <20260520223022.43916fc2@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 21 May 2026 07:40:36 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mOrkj3uDttMOH4YPXuPaVaVF5SrJspkkAuJC9LIqcyM_1779342040 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DZQGW725FVE7BYGBFMNT54AOUG5QPGE3 X-Message-ID-Hash: DZQGW725FVE7BYGBFMNT54AOUG5QPGE3 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 Thu, 21 May 2026 12:11:49 +1000 David Gibson wrote: > On Wed, May 20, 2026 at 10:30:23PM +0200, Stefano Brivio wrote: > > 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? > > Yes, because tcp_splice_forward() is (now) the only place that *sets* > FIN_RCVD (or FIN_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. > > tcp_splice_forward() only touches FIN_RCVD(fromsidei). So, we only > need to examine FIN_RCVD(fromsidei). If FIN_RCVD is set for the other > side, it must be in another call to tcp_splice_forward() which will > also examine that other flag and shutdown() as necessary. Okay, fair. That's what I call "not really obvious" but it's probably obvious enough. > > > 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