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=202512 header.b=UTzDV9iB; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 9838D5A0271 for ; Tue, 20 Jan 2026 01:09:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768867773; bh=87adQumj3HyANGkIQCwgqYq9EtxEz9nBthDbrfF8r4U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UTzDV9iBDnbdI/QcnQuimWWNtHxz+bW45QpM1xbo17NdEWV5VCOksIkQ8lJkqUDR/ WslGw5zbNv8TmW5P3SnTHT0aq5am6cX2g1KhXXXC8GOp1xD2FfsVES+Fvdu92cvasn faKrGLBVNS16h/sFd1qfgDagnh8bwCpRy1T9KqeVA5/uBBUY4eAnC1+ZB72Oof/zVC Try1Xcpocy8jP2KkftLeXP6Q/gXcwCgZQAYwNu3CX5rpjpaTGdl6Xkaog2dcX18bTr JgH1M6XDEwtvrv3Iuv//0+BrNsAs1wERXMUr7AKtCoFFBMwOq+eWwWAbRoG5vJpy5d +HPbv3fbilL6Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dw73x44mRz4wB9; Tue, 20 Jan 2026 11:09:33 +1100 (AEDT) Date: Tue, 20 Jan 2026 11:06:44 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v2 1/3] tcp_splice: Register fds with epoll at flow creation Message-ID: References: <20260119161915.4014677-1-lvivier@redhat.com> <20260119161915.4014677-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Kt46xZbhBzdFJ0KP" Content-Disposition: inline In-Reply-To: <20260119161915.4014677-2-lvivier@redhat.com> Message-ID-Hash: GBHLRLGVJGFAUYR6NOBI6IK7AOUYLKHQ X-Message-ID-Hash: GBHLRLGVJGFAUYR6NOBI6IK7AOUYLKHQ 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: passt-dev@passt.top 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: --Kt46xZbhBzdFJ0KP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 19, 2026 at 05:19:13PM +0100, Laurent Vivier wrote: > Register both splice connection sockets with epoll using empty events > (events=3D0) in tcp_splice_connect(), before initiating the connection. >=20 > This allows tcp_splice_epoll_ctl() to always use EPOLL_CTL_MOD, removing > the need to check whether fds are already registered. As a result, the > conditional ADD/MOD logic is no longer needed, simplifying the function. >=20 > If the second flow_epoll_set() fails after the first succeeds, we don't > need explicit rollback: tcp_splice_conn_from_sock() sets the CLOSING > flag on error, and conn_flag() handles it by calling epoll_del() for > both sockets. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp_splice.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) >=20 > diff --git a/tcp_splice.c b/tcp_splice.c > index a7c04ca8652a..cb81e012ee4b 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -142,20 +142,12 @@ static uint32_t tcp_splice_conn_epoll_events(uint16= _t events, unsigned sidei) > static int tcp_splice_epoll_ctl(struct tcp_splice_conn *conn) > { > uint32_t events[2]; > - int m; > - > - if (flow_in_epoll(&conn->f)) { > - m =3D EPOLL_CTL_MOD; > - } else { > - flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT); > - m =3D EPOLL_CTL_ADD; > - } > =20 > events[0] =3D tcp_splice_conn_epoll_events(conn->events, 0); > events[1] =3D tcp_splice_conn_epoll_events(conn->events, 1); > =20 > - if (flow_epoll_set(&conn->f, m, events[0], conn->s[0], 0) || > - flow_epoll_set(&conn->f, m, events[1], conn->s[1], 1)) { > + if (flow_epoll_set(&conn->f, EPOLL_CTL_MOD, events[0], conn->s[0], 0) || > + flow_epoll_set(&conn->f, EPOLL_CTL_MOD, events[1], conn->s[1], 1)) { > int ret =3D -errno; > flow_perror(conn, "ERROR on epoll_ctl()"); > return ret; > @@ -368,6 +360,14 @@ static int tcp_splice_connect(const struct ctx *c, s= truct tcp_splice_conn *conn) > =20 > pif_sockaddr(c, &sa, tgtpif, &tgt->eaddr, tgt->eport); > =20 > + flow_epollid_set(&conn->f, EPOLLFD_ID_DEFAULT); > + if (flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->s[0], 0) || > + flow_epoll_set(&conn->f, EPOLL_CTL_ADD, 0, conn->s[1], 1)) { > + int ret =3D -errno; > + flow_perror(conn, "Cannot register to epollfd"); > + return ret; > + } > + > conn_event(conn, SPLICE_CONNECT); > =20 > if (connect(conn->s[1], &sa.sa, socklen_inany(&sa))) { > --=20 > 2.52.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --Kt46xZbhBzdFJ0KP Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmluxwEACgkQzQJF27ox 2GeNABAAlnb75Y1mjdf/rD0KawGQxWj4bSE5RQ9AXgvHN03lTBqneQs7HdNYKTZ+ g9szcOmwxXdCKkFrsPBtvW60/RcxZXjDfrZQeRDiigNlJlI0X6KpAov8ef4W/pOW lBwoDxWebe3/f0VpFO+RvxNxzfoc2WP4hTbjssxqvlrYKn7pS5BJGWznJC5dXFyV /L/gL7HEsOs/LS9u3vVdtTAkt7zo+TojHEnEBvIS39SVnBMjTVAONnS2BKb6dP9M 1e7+vJ+rCRTbnu7yswHU5ItWV/eTULtounMXThuvPsEZubvCLn5Di5hAxBimqHPQ 2Icd21qtch3Zhe/OeZuCvqoghbLjaKPcrjyDMkEgDsHKp8AkZjmPCAhlFkNKJqDh 7fQTbQ2uP+9eae8itT6uAELYEif2e2qABxhV+8KVFKIVg6eSiyu4debvTqU7tSN6 faCct0Fr26UX20jLo3hr8BRTIj/S/67UaSSzKQYvem4+qupGYpneP7tCgPpHo6pZ Q5qTWT6dfEr/OpX7zwROlT++3bTPsXy3yev0/3KbzLH9lV+z5QGIAzEGrc7BRNgZ to/CCeeVkwxQYlYukXXaUAAEV/hvQsCfL3IBVdTYEsklqe2KWB1P/+WctoslYr3x QowAWW2uoDjLLrNmBs91wHkw6gKaw1JnhUjuj8sakUKNpPTAzxU= =qkdL -----END PGP SIGNATURE----- --Kt46xZbhBzdFJ0KP--