Skip to content

Commit fac5159

Browse files
matanb10dledford
authored andcommitted
IB/cma: cma_match_net_dev needs to take into account port_num
Previously, cma_match_net_dev called cma_protocol_roce which tried to verify that the IB device uses RoCE protocol. However, if rdma_id wasn't bound to a port, then the check would occur against the first port of the device without regard to whether that port was even of the same type as the type of port the incoming packet was received on. Fix this by passing the port of the request and only checking against the same port of the device. Reported-by: Or Gerlitz <gerlitz.or@gmail.com> Fixes: b8cab5d ('IB/cma: Accept connection without a valid netdev on RoCE') Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent ab5cdc3 commit fac5159

File tree

1 file changed

+9
-7
lines changed
  • drivers/infiniband/core

1 file changed

+9
-7
lines changed

drivers/infiniband/core/cma.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,15 +1265,17 @@ static bool cma_protocol_roce(const struct rdma_cm_id *id)
12651265
return cma_protocol_roce_dev_port(device, port_num);
12661266
}
12671267

1268-
static bool cma_match_net_dev(const struct rdma_id_private *id_priv,
1269-
const struct net_device *net_dev)
1268+
static bool cma_match_net_dev(const struct rdma_cm_id *id,
1269+
const struct net_device *net_dev,
1270+
u8 port_num)
12701271
{
1271-
const struct rdma_addr *addr = &id_priv->id.route.addr;
1272+
const struct rdma_addr *addr = &id->route.addr;
12721273

12731274
if (!net_dev)
12741275
/* This request is an AF_IB request or a RoCE request */
1275-
return addr->src_addr.ss_family == AF_IB ||
1276-
cma_protocol_roce(&id_priv->id);
1276+
return (!id->port_num || id->port_num == port_num) &&
1277+
(addr->src_addr.ss_family == AF_IB ||
1278+
cma_protocol_roce_dev_port(id->device, port_num));
12771279

12781280
return !addr->dev_addr.bound_dev_if ||
12791281
(net_eq(dev_net(net_dev), addr->dev_addr.net) &&
@@ -1295,13 +1297,13 @@ static struct rdma_id_private *cma_find_listener(
12951297
hlist_for_each_entry(id_priv, &bind_list->owners, node) {
12961298
if (cma_match_private_data(id_priv, ib_event->private_data)) {
12971299
if (id_priv->id.device == cm_id->device &&
1298-
cma_match_net_dev(id_priv, net_dev))
1300+
cma_match_net_dev(&id_priv->id, net_dev, req->port))
12991301
return id_priv;
13001302
list_for_each_entry(id_priv_dev,
13011303
&id_priv->listen_list,
13021304
listen_list) {
13031305
if (id_priv_dev->id.device == cm_id->device &&
1304-
cma_match_net_dev(id_priv_dev, net_dev))
1306+
cma_match_net_dev(&id_priv_dev->id, net_dev, req->port))
13051307
return id_priv_dev;
13061308
}
13071309
}

0 commit comments

Comments
 (0)