Commit 643d213a authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/cma: Do not ignore net namespace for unbound cm_id

Currently if the cm_id is not bound to any netdevice, than for such cm_id,
net namespace is ignored; which is incorrect.

Regardless of cm_id bound to a netdevice or not, net namespace must
match. When a cm_id is bound to a netdevice, in such case net namespace
and netdevice both must match.

Fixes: 4c21b5bc ("IB/cma: Add net_dev and private data checks to RDMA CM")
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent d274e45c
...@@ -1474,9 +1474,16 @@ static bool cma_match_net_dev(const struct rdma_cm_id *id, ...@@ -1474,9 +1474,16 @@ static bool cma_match_net_dev(const struct rdma_cm_id *id,
return (!id->port_num || id->port_num == port_num) && return (!id->port_num || id->port_num == port_num) &&
(addr->src_addr.ss_family == AF_IB); (addr->src_addr.ss_family == AF_IB);
return !addr->dev_addr.bound_dev_if || /*
(net_eq(dev_net(net_dev), addr->dev_addr.net) && * Net namespaces must match, and if the listner is listening
addr->dev_addr.bound_dev_if == net_dev->ifindex); * on a specific netdevice than netdevice must match as well.
*/
if (net_eq(dev_net(net_dev), addr->dev_addr.net) &&
(!!addr->dev_addr.bound_dev_if ==
(addr->dev_addr.bound_dev_if == net_dev->ifindex)))
return true;
else
return false;
} }
static struct rdma_id_private *cma_find_listener( static struct rdma_id_private *cma_find_listener(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment