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=G/x4Rpfs; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id E5BA25A0271 for ; Tue, 09 Dec 2025 01:09:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1765238975; bh=gZEHSSoEzBdAj0Z8mwu5OsJkqygCxGSIsE1a9JNHZFw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G/x4RpfsujiBHGznBxd3TrYyVCg3nzEiznlAtXNM2fu586gCRApLlETIqFPN0fBPu IE0huT1IVfoX9DVMPowxLeR9U9Nq1tXO9ErsN1yHw1cFHOrZVw0FCSZL5lfHAAfndV E0Swqk9QU29ajYulhjIv4gaWd1FFgmLo/YPGwCH7XpxGGWvd861aOgBmnrhUX6bdex 4O/n3kcxJYxoVMtxF5CUp29AasVI6XdevecVJepaFNx797/tvhmrrIPa8Et4AXJrNK hucD1l5wnlmK0be4PDMEBtES10moZFnfyk2RPGTEMQx+23AjXL/TzWLdEL0j35HMJy 4mei78PNCe9Dg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dQK3M30cXz4wCB; Tue, 09 Dec 2025 11:09:35 +1100 (AEDT) Date: Tue, 9 Dec 2025 11:09:33 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp_splice, flow: Add socket to epoll set before connect(), drop assert Message-ID: References: <20251208235333.2864818-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="g6vjl5uhB6kQhg+1" Content-Disposition: inline In-Reply-To: <20251208235333.2864818-1-sbrivio@redhat.com> Message-ID-Hash: YTV3CONJRBDMQDZZ2LZUDXGFTFNNGQBM X-Message-ID-Hash: YTV3CONJRBDMQDZZ2LZUDXGFTFNNGQBM 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, Laurent Vivier 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: --g6vjl5uhB6kQhg+1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 09, 2025 at 12:53:33AM +0100, Stefano Brivio wrote: > ...otherwise, if we have a real error on connect() (that is, not > EINPROGRESS), we'll return early from tcp_splice_connect() and later > try to fetch the epoll file descriptor: >=20 > ASSERTION FAILED in flow_epollfd (flow.c:362): f->epollid < ((1 << 8) -= 1) >=20 > which is still (correctly) EPOLLFD_ID_INVALID. >=20 > Replace the ASSERT() in flow_epollfd() with a warning, as it looks > like there might be harmless cases where the socket is not in the > epoll set yet, and we'll just crash for nothing. We can turn this back > to an ASSERT() once we audit these paths in more detail. >=20 > Link: https://bodhi.fedoraproject.org/updates/FEDORA-2025-93b4eb64c3#comm= ent-4473411 > Signed-off-by: Stefano Brivio > --- > I might merge this in a bit even without review as we might now have > broken distribution packages around. >=20 > flow.c | 7 ++++++- > tcp_splice.c | 4 ++-- > 2 files changed, 8 insertions(+), 3 deletions(-) >=20 > diff --git a/flow.c b/flow.c > index 8d72965..4f53486 100644 > --- a/flow.c > +++ b/flow.c > @@ -359,7 +359,12 @@ bool flow_in_epoll(const struct flow_common *f) > */ > int flow_epollfd(const struct flow_common *f) > { > - ASSERT(f->epollid < EPOLLFD_ID_MAX); > + if (f->epollid >=3D EPOLLFD_ID_MAX) { > + flow_log_(f, true, LOG_WARNING, > + "Invalid epollid %i for flow, assuming default", > + f->epollid); > + return epoll_id_to_fd[EPOLLFD_ID_DEFAULT]; > + } This LGTM for safety's sake, although it's conceptually ugly. > =20 > return epoll_id_to_fd[f->epollid]; > } > diff --git a/tcp_splice.c b/tcp_splice.c > index 717766a..4405224 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -381,14 +381,14 @@ static int tcp_splice_connect(const struct ctx *c, = struct tcp_splice_conn *conn) > =20 > pif_sockaddr(c, &sa, tgtpif, &tgt->eaddr, tgt->eport); > =20 > + conn_event(c, conn, SPLICE_CONNECT); > + > if (connect(conn->s[1], &sa.sa, socklen_inany(&sa))) { > if (errno !=3D EINPROGRESS) { > flow_trace(conn, "Couldn't connect socket for splice: %s", > strerror_(errno)); > return -errno; > } > - > - conn_event(c, conn, SPLICE_CONNECT); I don't really understand the rationale for this. > } else { > conn_event(c, conn, SPLICE_ESTABLISHED); > return tcp_splice_connect_finish(c, conn); I think the true fix for this specific failure on the connect-error path is to check flow_in_epoll() before calling flow_epollfd() / epoll_del() in the CLOSING path of conn_flag_do(). --=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 --g6vjl5uhB6kQhg+1 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmk3aLwACgkQzQJF27ox 2GcFWhAAkncPed9k5JMy1iHq0gZDkCjjC/MwdanXeUHIoamLvdxLDkQ/W+eJkgYv Jf8+sSzGYtjyj2TurBUSYPwNLA8WoiYGDzj4irw049gK0dcLidQyPt1Rbxqd0C1w GEiYS6X93aWCtTRLqKZWpq+sF9CmpgOoFCBy3hmg1YrAir+ra0c949dhlvVVN/h0 2UrQgWfj1yBgyy8V3cd37qX/q8BOEXHBeJE6DiskDdqhm/nnKaDTJowoYAIubCsD bagfTbN7Qtromh2MWCnqEKk1lfIU6Z6Z1c6OXPR+CQEGEQOqLCKRlQQQWYoiR7cY JYNcKu/S2hks5/MWCQg3N2uwwxVFBMVoCNzk4dpjODIMfm6zSKniTHnp30qIV0fB WVaR1aY0p1ytxZqlzLvb653jPjn8ddRDKid1QHvyFj2PeCZtLwo7SST8x2WJu/J8 FT4+xkslipHQRtRrhAYsd55ucrA+gAJDBHYqbQ3HAi2msCsBwToz5ZeGGJUIUwXg nKG+5IhMTpDSVmfwP6fs5g4CGxnlZjEK5Oor0OjxMPLA0xuSFrD7A3FeE2GZzo39 LqP/WxOBcv9qgiZg8j13tztMplKpDASB/ZA2lCZeDbTPn3KJjJ4ekWETPgs+XE0W IDl+aHzxs8Zvl8MHLcO5JIXaOMpbze4dYM81V24GEAV5UfKS9YU= =hDoL -----END PGP SIGNATURE----- --g6vjl5uhB6kQhg+1--