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=I6MPOhVu; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 988D65A0271 for ; Tue, 09 Dec 2025 01:26:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1765239959; bh=ZWH+FyNcLyMVjVPzagc3hgyLBSH/YN5+e0IoM4So11o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I6MPOhVuTqnHX6OzueMGUy28tMpCxNsp4lQBTkv0OfNXPbreANhLVDDOrKHPbQTJZ bum0Yu/dV7MW4K9We2DBov94Ku3MNtofuE38QaYAWU8uzZXmRBUuqdHYHHtwM80fnf eShB4KrLHlah9t3bEpINPF72tojM1D++foZwH11ICeqGJ8RCxRBc5j482vJdRMRtkg V/E5pQmd52FL/YA+ln89ybKTDg7hZb8/5AS88+fCN5rfXKAxmXSQL3zK0AODyQhyaG cQPX8Ezw0BTOCXZf3mc04tJ4swlLqW9f2FhKSlczwXW7wnPWPzP69rx+2JySW94EdJ oMi70cvIYc22Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dQKQH2BJPz4wMG; Tue, 09 Dec 2025 11:25:59 +1100 (AEDT) Date: Tue, 9 Dec 2025 11:25:58 +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> <20251209012144.3239b1a9@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EB0ofjiMka73kP8Z" Content-Disposition: inline In-Reply-To: <20251209012144.3239b1a9@elisabeth> Message-ID-Hash: MJREHDDZGIZGO2ZNIVJIUMZFPY55WLRO X-Message-ID-Hash: MJREHDDZGIZGO2ZNIVJIUMZFPY55WLRO 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: --EB0ofjiMka73kP8Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 09, 2025 at 01:21:44AM +0100, Stefano Brivio wrote: > On Tue, 9 Dec 2025 11:09:33 +1100 > David Gibson wrote: >=20 > > 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#= comment-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]; > > > + } =20 > >=20 > > This LGTM for safety's sake, although it's conceptually ugly. >=20 > Well it's much uglier to have containers crashing randomly... Certainly. > > > 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); =20 > >=20 > > I don't really understand the rationale for this. >=20 > If we call connect(), I think we should be ready to handle events on > the socket/flow at that point. >=20 > Now, it's all synchronous so we won't actually get events before we > call conn_event(), but it makes more sense than the alternative, that > is, having a potentially connect()ed socket around not in any epoll set. Ok, that makes sense. Reviewed-by: David Gibson > > > } else { > > > conn_event(c, conn, SPLICE_ESTABLISHED); > > > return tcp_splice_connect_finish(c, conn); =20 > >=20 > > 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 > I need to re-run tests anyway so I can merge another patch doing that > but I'm trying to hurry now. A few minutes is fine though. >=20 > --=20 > Stefano >=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 --EB0ofjiMka73kP8Z Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmk3bJUACgkQzQJF27ox 2Gf6MQ/9FfileL8AE1IhI/g2nQUOI94+C6UsNU0SSI4RQkiU1C4GNNmFfcN9Wuab DxPKuFE4L8vFNM8XNzKfM2oLVuJuHTqX3xTpgOCSxwMUqOJV2w2Iu6TsGrJIxtML OB4Pv5tdFukjzD62lhz9q2ZcsLSIwTLGZuNC0sXqAd/hBMjzfAxDcW1L1p5f7lpJ tdoBPfEgZ3MK399kULDnsTMmjPjlQB64Yd2l8Y89rclcZdpYRbQOV8BPpWMI/FAG RvxJeJ1m5rzxOT5qmXrg005nf+PKaE5K5fXENlbYCLnmqkOC/u5OMRhY64U6k2Fd UVbE16PE+OQiepLtqzBEPPCbkB6bzdKLJW2kTrpWclXERr9SKTtrEaGmj+aDDFZ/ xpikSlItgCyyHgyEpChGt5bG2lXgfolfYfiAG+pFZCS66LidnXb1EWiJdxm/c8Wm y+/d4+LUMKZy9nozMSyybZ/tZ2lTW5CFkAmFfCw8VEhy+8+lDyGdgWq5sYZW3w0O TIHQkIH7xT0bZgctZ372J8LXuIs4UEAbfHyg3vh9Bl+3yjs611UhpATax80ptnS/ vvI28VoMvS/4JGTC4XuY4+Y5SFE31SZSw8lNmElrkmdl73GiZRTggzqTZtKPG7uQ oeHyiz2W1pEUutYAFTDKKcJTYGn8JtuHbj5jew4ZCb67HWoSpCw= =bwpo -----END PGP SIGNATURE----- --EB0ofjiMka73kP8Z--