]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
RDMA/core: Check id_priv->restricted_node_type in cma_listen_on_dev()
authorStefan Metzmacher <metze@samba.org>
Tue, 24 Feb 2026 16:59:52 +0000 (17:59 +0100)
committerLeon Romanovsky <leon@kernel.org>
Wed, 25 Feb 2026 12:50:10 +0000 (07:50 -0500)
When listening on wildcard addresses we have a global list for the application
layer rdma_cm_id and for any existing device or any device added in future we
try to listen on any wildcard listener.

When the listener has a restricted_node_type we should prevent listening on
devices with a different node type.

While there fix the documentation comment of rdma_restrict_node_type()
to include rdma_resolve_addr() instead of having rdma_bind_addr() twice.

Fixes: a760e80e90f5 ("RDMA/core: introduce rdma_restrict_node_type()")
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: linux-rdma@vger.kernel.org
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Link: https://patch.msgid.link/20260224165951.3582093-2-metze@samba.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/cma.c
include/rdma/rdma_cm.h

index e54c07c745754d0f8a6ac2a5fa00e98d1646f272..9480d1a51c116ef088277983175a11ca5c898d58 100644 (file)
@@ -2729,6 +2729,9 @@ static int cma_listen_on_dev(struct rdma_id_private *id_priv,
        *to_destroy = NULL;
        if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
                return 0;
+       if (id_priv->restricted_node_type != RDMA_NODE_UNSPECIFIED &&
+           id_priv->restricted_node_type != cma_dev->device->node_type)
+               return 0;
 
        dev_id_priv =
                __rdma_create_id(net, cma_listen_handler, id_priv,
@@ -2736,6 +2739,7 @@ static int cma_listen_on_dev(struct rdma_id_private *id_priv,
        if (IS_ERR(dev_id_priv))
                return PTR_ERR(dev_id_priv);
 
+       dev_id_priv->restricted_node_type = id_priv->restricted_node_type;
        dev_id_priv->state = RDMA_CM_ADDR_BOUND;
        memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv),
               rdma_addr_size(cma_src_addr(id_priv)));
@@ -4194,7 +4198,7 @@ int rdma_restrict_node_type(struct rdma_cm_id *id, u8 node_type)
        }
 
        mutex_lock(&lock);
-       if (id_priv->cma_dev)
+       if (READ_ONCE(id_priv->state) != RDMA_CM_IDLE)
                ret = -EALREADY;
        else
                id_priv->restricted_node_type = node_type;
index 6de6fd8bd15eec7a486938031f34216d363c55ff..d639ff889e649369bae20ede83206c19c38191fb 100644 (file)
@@ -181,7 +181,7 @@ void rdma_destroy_id(struct rdma_cm_id *id);
  *
  * It needs to be called before the RDMA identifier is bound
  * to an device, which mean it should be called before
- * rdma_bind_addr(), rdma_bind_addr() and rdma_listen().
+ * rdma_bind_addr(), rdma_resolve_addr() and rdma_listen().
  */
 int rdma_restrict_node_type(struct rdma_cm_id *id, u8 node_type);