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=ezkTzd26; 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 AA7B65A0271 for ; Tue, 09 Dec 2025 01:21:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765239716; 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=xw8Mw1RAdPWMdQDsFb2dgKKlQxQHeHGar25EwDcqo+4=; b=ezkTzd26m/EFA9XxSOZJfOORZlHT9BNJ+LdVX/COGkFbkpvrkYpF0Ikl1ziDCxz4uTjl+k zY9BS1mRe+c1FvJPa0RInZRG86MclMJhpUR41GpF9YrKeVvnskU8OFkdQkpRwfPBwVKs0N RfREdSnpYmcRtEAjHCaFGCHfiB3Ffyk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-JfARkXceP4-YMGFmWrfmEQ-1; Mon, 08 Dec 2025 19:21:49 -0500 X-MC-Unique: JfARkXceP4-YMGFmWrfmEQ-1 X-Mimecast-MFC-AGG-ID: JfARkXceP4-YMGFmWrfmEQ_1765239708 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-477a11d9f89so21427225e9.3 for ; Mon, 08 Dec 2025 16:21:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765239708; x=1765844508; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xw8Mw1RAdPWMdQDsFb2dgKKlQxQHeHGar25EwDcqo+4=; b=fKKiX67bRFqb2b3R/ZENcE3ZVsO1DOpoJYQBZVxjFMrqH7cEQSoZk/tLz92xUYfkT6 +Fn4y90naOlD1QcHxLy69Af6m3jgd++7vj7p+ZF9n7X69AZu4Aj7Q3VS4JtOMZ8qT+Wx KTrxVp9MMP99JCQyz2uLXrbQurUJymUB9RG29bZUOaH4i22g8J9CiNsm2CGTlQ8X5mzN vJlcxWIoeRHfuPgFWyG7tur6+edwnQSjmzUZq0viQJEWA1IndlbJ6g1HyWOZlsHkY9OP MvlWiCcoS46ZFtIq949fiffwSaVLhsOpVtUZndqEj8YH9QFekfcRt5JGfe+Fk49Wau3o sFNg== X-Gm-Message-State: AOJu0Yy8WVTy1k2otkcI4WpBEJYWNrzngsTAXHdiC7KDwQxbTUZBCD8p ZAfkgPL2qrIbZcTjTDvpg+lOlv+Tj9lM9gbSXB3elnXRR6gunko15JXVa6fALh/w0TOFpy/lWV5 nho0c4HzffeZ+eJ9nzAAMY3TN+wvYvbhHte4IxUkqN9XhxhqwifFSQQ== X-Gm-Gg: ASbGncuIj0WvZDgKhYS+ABh6b8QVug0kAq6yXCsGah0QOnzspsB/6pHPpEJxmhMvEGd u1aWicBPvheXYhA9ecTEo11v2HImKvkUDeWBgmXYqU7sMqFIRj2+BtGTSNq+8xApv9TRCgh6A2w 0PzZzKEJNVP47fqZPUCnq7R/5Rj8COFO9hTHsY89akaPJSNmUxqO9BHUoGRxF/tqE5lKFdlTl4J k3S59DJSVBHNsA9h9Zpm/5+jVZl9k+J24QO83E9ijD6pXIXmth+fa3ZX/gCAB4jfYHiwJnx3Lv0 s40JBLskveYppQDfKknhETGFv6brLHc07WxynttrvqQcDghwq0ShOWlrwvoS8E/3r4AT+s346KR LSIYfhDuAgElDrFRHy5Fu X-Received: by 2002:a05:600c:4e92:b0:477:79f8:daa8 with SMTP id 5b1f17b1804b1-47939e1ba32mr100093475e9.17.1765239707423; Mon, 08 Dec 2025 16:21:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFm23p3yxDCeRn+Ks4K2/Hv01gUzY0L8VBREzeJv9xIZybwIdqF4eMXjyaFTap2ozFulx+GXQ== X-Received: by 2002:a05:600c:4e92:b0:477:79f8:daa8 with SMTP id 5b1f17b1804b1-47939e1ba32mr100093375e9.17.1765239707022; Mon, 08 Dec 2025 16:21:47 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d70fc24sm10360485e9.10.2025.12.08.16.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Dec 2025 16:21:46 -0800 (PST) Date: Tue, 9 Dec 2025 01:21:44 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] tcp_splice, flow: Add socket to epoll set before connect(), drop assert Message-ID: <20251209012144.3239b1a9@elisabeth> In-Reply-To: References: <20251208235333.2864818-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: KeiM6jxtiGlBY0z-HbPNh45QZvkyDr-9Hsei_hs5mNo_1765239708 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: JG2VU5HOZLZZXSEPILVL2RBTMGW7UZUC X-Message-ID-Hash: JG2VU5HOZLZZXSEPILVL2RBTMGW7UZUC 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, 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: On Tue, 9 Dec 2025 11:09:33 +1100 David Gibson wrote: > 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: > > > > ASSERTION FAILED in flow_epollfd (flow.c:362): f->epollid < ((1 << 8) - 1) > > > > which is still (correctly) EPOLLFD_ID_INVALID. > > > > 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. > > > > 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. > > > > flow.c | 7 ++++++- > > tcp_splice.c | 4 ++-- > > 2 files changed, 8 insertions(+), 3 deletions(-) > > > > 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 >= 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. Well it's much uglier to have containers crashing randomly... > > 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) > > > > pif_sockaddr(c, &sa, tgtpif, &tgt->eaddr, tgt->eport); > > > > + conn_event(c, conn, SPLICE_CONNECT); > > + > > if (connect(conn->s[1], &sa.sa, socklen_inany(&sa))) { > > if (errno != 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. If we call connect(), I think we should be ready to handle events on the socket/flow at that point. 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. > > } 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(). 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. -- Stefano