Linux NFS development
 help / color / mirror / Atom feed
From: Stefan Metzmacher <metze@samba.org>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>
Cc: metze@samba.org, Ammar Ratnani <ammrat13@gmail.com>,
	Chuck Lever <cel@kernel.org>,
	Bernard Metzler <bernard.metzler@linux.dev>,
	Yunseong Kim <yunseong.kim@est.tech>,
	Yunseong Kim <yunseong.kim@ericsson.com>,
	Jacob Moroni <jmoroni@google.com>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Anna Schumaker <anna@kernel.org>,
	Dai Ngo <Dai.Ngo@oracle.com>, Jeff Layton <jlayton@kernel.org>,
	Li Xiasong <lixiasong1@huawei.com>, NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Tim Menninger <tmenninger@everpuredata.com>,
	Tom Talpey <tom@talpey.com>, Trond Myklebust <trondmy@gmail.com>,
	Trond Myklebust <trondmy@kernel.org>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	Yue Haibing <yuehaibing@huawei.com>,
	Zhang Changzhong <zhangchangzhong@huawei.com>,
	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	[thread overview]
Message-ID: <cover.1796215022.git.metze@samba.org> (raw)

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


             reply	other threads:[~2026-12-02 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:38 Stefan Metzmacher [this message]
2026-12-02 12:38 ` [PATCH 1/3] RDMA/cm: cancel the outstanding REQ or REP in ib_send_cm_rej() Stefan Metzmacher
2026-12-02 12:38 ` [PATCH 2/3] RDMA/cm: add ib_cm_reject_pending_connect() Stefan Metzmacher
2026-12-02 12:38 ` [PATCH 3/3] RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect() Stefan Metzmacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1796215022.git.metze@samba.org \
    --to=metze@samba.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=ammrat13@gmail.com \
    --cc=anna@kernel.org \
    --cc=bernard.metzler@linux.dev \
    --cc=bvanassche@acm.org \
    --cc=cel@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jlayton@kernel.org \
    --cc=jmoroni@google.com \
    --cc=leon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lixiasong1@huawei.com \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tmenninger@everpuredata.com \
    --cc=tom@talpey.com \
    --cc=trondmy@gmail.com \
    --cc=trondmy@kernel.org \
    --cc=weiyongjun1@huawei.com \
    --cc=yuehaibing@huawei.com \
    --cc=yunseong.kim@ericsson.com \
    --cc=yunseong.kim@est.tech \
    --cc=zhangchangzhong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox