Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/core: Check id_priv->restricted_node_type in cma_listen_on_dev()

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>

authored by

Stefan Metzmacher and committed by
Leon Romanovsky
93a4a9b7 faa72102

+6 -2
+5 -1
drivers/infiniband/core/cma.c
··· 2729 2729 *to_destroy = NULL; 2730 2730 if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1)) 2731 2731 return 0; 2732 + if (id_priv->restricted_node_type != RDMA_NODE_UNSPECIFIED && 2733 + id_priv->restricted_node_type != cma_dev->device->node_type) 2734 + return 0; 2732 2735 2733 2736 dev_id_priv = 2734 2737 __rdma_create_id(net, cma_listen_handler, id_priv, ··· 2739 2736 if (IS_ERR(dev_id_priv)) 2740 2737 return PTR_ERR(dev_id_priv); 2741 2738 2739 + dev_id_priv->restricted_node_type = id_priv->restricted_node_type; 2742 2740 dev_id_priv->state = RDMA_CM_ADDR_BOUND; 2743 2741 memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv), 2744 2742 rdma_addr_size(cma_src_addr(id_priv))); ··· 4198 4194 } 4199 4195 4200 4196 mutex_lock(&lock); 4201 - if (id_priv->cma_dev) 4197 + if (READ_ONCE(id_priv->state) != RDMA_CM_IDLE) 4202 4198 ret = -EALREADY; 4203 4199 else 4204 4200 id_priv->restricted_node_type = node_type;
+1 -1
include/rdma/rdma_cm.h
··· 181 181 * 182 182 * It needs to be called before the RDMA identifier is bound 183 183 * to an device, which mean it should be called before 184 - * rdma_bind_addr(), rdma_bind_addr() and rdma_listen(). 184 + * rdma_bind_addr(), rdma_resolve_addr() and rdma_listen(). 185 185 */ 186 186 int rdma_restrict_node_type(struct rdma_cm_id *id, u8 node_type); 187 187