From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=144.76.82.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796215109; b=s2FtRpV5iFj2a6XzF4FQ7TJQgxol/DhNpOFYbEsyHOlvms7WgC6PsucpFrfjDCH3G66H JRm8dyRrNGhuaRBQbqCZkYl85jkK1DP1+F5cq4uVRAKEmgjlAe7kEDGJZmbYL/UXIUEMY BtIX0WLVdrSW68JQ2/iPQF0QXaifz6U1192GNzU937cW6E8CXWI92f6kjY91ZSE9aODzA t/ePC2QDiYR8OT8XCIiwxjIGdmXbjVodTKoYlDt9o+Cv1skR27ktPjGiSjCw5HZ1XRsuS 76x5x/SNlC48mTO6HQMaxKo6O0tRR8iAQ4D08TNRjZzATVvhZn+kZatfZMNnnJrcFDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215109; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=UO4P+981qXKwlkfiJ+gCHjiH9RxglId1iF4p/KIebcg=; b=GBEoC9RVz9Kr3TccD0zb3rfHaKGcI1807GlOxXWKyZwvMnVcW1H7GHewGRGMOHgcbK9E EexDMZr9/vI2QjLPZUcEqbMYNcQu1iKZCR16LEqaUL+phqhdhGUuH4sgM/aNyDMTHMs+U O5G0f0qAkFblaCIa/F6Qy6MX0Bv14H7QDd/+IbnR6eaPOGhy5ZXEd2MCbzkLuOtgn8IfB RFj6AMOBrUfnEVUbGHy54LeUkHTI5TAfaDiQlxtep7+egMhvq0zSSL8YkYVu+z3TM2P4P S7Dg0H9MZcosnbyhG9XRBiyqTsVC6mx5rCjn1k07sasZQT9bxOa6UzyDmNWfPD+sj8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samba.org; spf=pass smtp.mailfrom=samba.org; dkim=pass header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b="xCSFZ/iZ"; arc=none smtp.remote-ip=144.76.82.148 Received: from hr2.samba.org (hr2.samba.org [144.76.82.148]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76DDD606A682; Wed, 2 Dec 2026 12:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 76DDD606A682 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=samba.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samba.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b=xCSFZ/iZ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-ID:Date:Cc:To:From; bh=UO4P+981qXKwlkfiJ+gCHjiH9RxglId1iF4p/KIebcg=; b=xCSFZ/iZuzS1T+wbSPyCKVT1Z4 hh0Cs8H7ZfyMmfjjpXlEzocjCO2CzmrLF1gyu6furm6RkaYnL6qvamWovzUMuXTseWKOF44NyOAz1 nWVaMPn29G8y2qvziQI45KHQ/7ppEykHHRMMVi8fZGRwoSq7ZvHXt/lFkskpJMA845w6YGH4ozuvC /ahmt/wnDDYhmkNPi1nC24EnSnwNJj1XECxN8pLOCWnWCHA5PImRCGPYd6e0cHd9Kmy+EsEkIaDUx Hx0oi8xFINeQlGgChkWTqFO9udTPvnniB4YMCqMkaRPucQWLwV4iVe18C8EsJi5bRdZqFr8ZDieSO 9gijPbzAAXWmWUng0/xV0P8utfIFWm2iDWbDQ33HG9CJZGJQQ3qWXYYmVm+WDp7kbmQ2NdCcGytNw 6uwNSaMpJWvLIOr0UBi/l235SOxyqHlbDEA5QaSUUm+95FEoSej4r/cRu0txv//uBD9PCJKctrjhi 0uL+i62gSISY7xWp6VGK5BD0; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1xYjbK-00000000fgt-0Dyi; Wed, 02 Dec 2026 12:38:22 +0000 From: Stefan Metzmacher To: Jason Gunthorpe , Leon Romanovsky Cc: metze@samba.org, Ammar Ratnani , Chuck Lever , Bernard Metzler , Yunseong Kim , Yunseong Kim , Jacob Moroni , Bart Van Assche , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Anna Schumaker , Dai Ngo , Jeff Layton , Li Xiasong , NeilBrown , Olga Kornievskaia , Tim Menninger , Tom Talpey , Trond Myklebust , Trond Myklebust , Wei Yongjun , Yue Haibing , Zhang Changzhong , linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 0/3] RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect() Date: Wed, 2 Dec 2026 13:38:10 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, if rdma_disconnect() is called while an active IB/RoCE connect is still waiting for the REP, ib_send_cm_dreq() and ib_send_cm_drep() fail, as the connection is not established. Since commit ba88a28b47a7 ("RDMA/core: Force disconnect if DREP and DREQ fail") the caller then gets RDMA_CM_EVENT_DISCONNECTED for a connection that was never established, while the REQ is still pending in ib_cm. RDMA_CM_CONNECT covers both a pending and an established connection, so the rdma_cm state doesn't distinguish them. - The first patch lets ib_send_cm_rej() cancel our outstanding REQ (or REP), otherwise a following rdma_destroy_id() waits about 76 seconds until all retries of the REQ timed out. - The second patch adds ib_cm_reject_pending_connect(), which rejects a pending active connect and returns the former state, with the check and the REJ done atomically, so the caller knows whether a REP arrived in between. - The third patch uses it in rdma_disconnect(): a connect still waiting for the REP is rejected and reported as RDMA_CM_EVENT_CONNECT_ERROR with -ECONNABORTED. If the REP is already being processed, only the REJ is sent, as the REP upcall reports the failed connect itself. Without a QP (rdma_ucm), the caller keeps getting RDMA_CM_EVENT_DISCONNECTED as before. If ib_cm is already idle, a pending REJECTED or UNREACHABLE event reports the failed connect, so no second event is forced. An established connection still gets the forced RDMA_CM_EVENT_DISCONNECTED. This came up in the discussion about ba88a28b47a7 with Ammar and Chuck: https://lore.kernel.org/linux-nfs/f491838c-f364-41a3-b886-ec75d281bf03@gmail.com/ A larger series lets rdma_disconnect() abort a connection setup for iWarp as well, on top of these two patches, I'll post it later. These patches were developed with the help of Claude (Anthropic), which was used for code analysis, writing parts of the code and the commit messages. I reviewed all changes and take full responsibility for them. Testing: two hosts with rxe, Intel E810 (irdma) and ConnectX (mlx5) in RoCEv2 mode: SMB over RDMA (cifs.ko/ksmbd.ko) connects against a listener that never answers, aborted after about 5 seconds and by killing the mounting processes, without waiting for the REQ retries, and a user space rdma_cm test that aborts pending connects with rdma_disconnect() or by destroying the QP or the rdma_cm_id first. The established case (address removed or link down while connected) works as before. Base: linux-rdma/for-next (a8671ee9bde1). Stefan Metzmacher (3): RDMA/cm: cancel the outstanding REQ or REP in ib_send_cm_rej() RDMA/cm: add ib_cm_reject_pending_connect() RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect() drivers/infiniband/core/cm.c | 45 +++++++++++- drivers/infiniband/core/cma.c | 110 ++++++++++++++++++++++++++++ drivers/infiniband/core/cma_trace.h | 1 + include/rdma/ib_cm.h | 17 +++++ 4 files changed, 171 insertions(+), 2 deletions(-) -- 2.43.0