提交 b8cab5da 编写于 作者: H Haggai Eran 提交者: Doug Ledford

IB/cma: Accept connection without a valid netdev on RoCE

The netdev checks recently added to RDMA CM expect a valid netdev to be
found for both InfiniBand and RoCE, but the code that find a netdev is
only implemented for InfiniBand.

Currently RoCE doesn't provide an API to find the netdev matching a
given set of parameters, so this patch just disables the netdev enforcement
for each incoming connections when the link layer is RoCE.

Fixes: 4c21b5bc ("IB/cma: Add net_dev and private data checks to RDMA CM")
Reported-by: NKamal Heib <kamalh@mellanox.com>
Signed-off-by: NHaggai Eran <haggaie@mellanox.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 f022fa88
...@@ -1232,14 +1232,32 @@ static bool cma_match_private_data(struct rdma_id_private *id_priv, ...@@ -1232,14 +1232,32 @@ static bool cma_match_private_data(struct rdma_id_private *id_priv,
return true; return true;
} }
static bool cma_protocol_roce_dev_port(struct ib_device *device, int port_num)
{
enum rdma_link_layer ll = rdma_port_get_link_layer(device, port_num);
enum rdma_transport_type transport =
rdma_node_get_transport(device->node_type);
return ll == IB_LINK_LAYER_ETHERNET && transport == RDMA_TRANSPORT_IB;
}
static bool cma_protocol_roce(const struct rdma_cm_id *id)
{
struct ib_device *device = id->device;
const int port_num = id->port_num ?: rdma_start_port(device);
return cma_protocol_roce_dev_port(device, port_num);
}
static bool cma_match_net_dev(const struct rdma_id_private *id_priv, static bool cma_match_net_dev(const struct rdma_id_private *id_priv,
const struct net_device *net_dev) const struct net_device *net_dev)
{ {
const struct rdma_addr *addr = &id_priv->id.route.addr; const struct rdma_addr *addr = &id_priv->id.route.addr;
if (!net_dev) if (!net_dev)
/* This request is an AF_IB request */ /* This request is an AF_IB request or a RoCE request */
return addr->src_addr.ss_family == AF_IB; return addr->src_addr.ss_family == AF_IB ||
cma_protocol_roce(&id_priv->id);
return !addr->dev_addr.bound_dev_if || return !addr->dev_addr.bound_dev_if ||
(net_eq(dev_net(net_dev), &init_net) && (net_eq(dev_net(net_dev), &init_net) &&
...@@ -1294,6 +1312,10 @@ static struct rdma_id_private *cma_id_from_event(struct ib_cm_id *cm_id, ...@@ -1294,6 +1312,10 @@ static struct rdma_id_private *cma_id_from_event(struct ib_cm_id *cm_id,
if (PTR_ERR(*net_dev) == -EAFNOSUPPORT) { if (PTR_ERR(*net_dev) == -EAFNOSUPPORT) {
/* Assuming the protocol is AF_IB */ /* Assuming the protocol is AF_IB */
*net_dev = NULL; *net_dev = NULL;
} else if (cma_protocol_roce_dev_port(req.device, req.port)) {
/* TODO find the net dev matching the request parameters
* through the RoCE GID table */
*net_dev = NULL;
} else { } else {
return ERR_CAST(*net_dev); return ERR_CAST(*net_dev);
} }
...@@ -1593,11 +1615,16 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, ...@@ -1593,11 +1615,16 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
if (ret) if (ret)
goto err; goto err;
} else { } else {
/* An AF_IB connection */ if (!cma_protocol_roce(listen_id) &&
WARN_ON_ONCE(ss_family != AF_IB); cma_any_addr(cma_src_addr(id_priv))) {
rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND;
cma_translate_ib((struct sockaddr_ib *)cma_src_addr(id_priv), rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
&rt->addr.dev_addr); ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
} else if (!cma_any_addr(cma_src_addr(id_priv))) {
ret = cma_translate_addr(cma_src_addr(id_priv), &rt->addr.dev_addr);
if (ret)
goto err;
}
} }
rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
...@@ -1635,13 +1662,12 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, ...@@ -1635,13 +1662,12 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
if (ret) if (ret)
goto err; goto err;
} else { } else {
/* An AF_IB connection */ if (!cma_any_addr(cma_src_addr(id_priv))) {
WARN_ON_ONCE(ss_family != AF_IB); ret = cma_translate_addr(cma_src_addr(id_priv),
&id->route.addr.dev_addr);
if (!cma_any_addr(cma_src_addr(id_priv))) if (ret)
cma_translate_ib((struct sockaddr_ib *) goto err;
cma_src_addr(id_priv), }
&id->route.addr.dev_addr);
} }
id_priv->state = RDMA_CM_CONNECT; id_priv->state = RDMA_CM_CONNECT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册