RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect()
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | RDMA/cm: cancel the outstanding REQ or REP in ib_send_cm_rej()drivers/ | +9 | 0 replies | |
| 2/3 | RDMA/cm: add ib_cm_reject_pending_connect()drivers/ include/ | +51 | 0 replies | |
| 3/3 | RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect()drivers/ drivers/ | +111 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] RDMA/cma: reject a pending IB/RoCE connect in rdma_disconnect()
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/[email protected]/
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(-)
Signature · 1 line
2.43.0