Commit 88145678 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/cma: Consider net namespace while leaving multicast group

When sending multicast leave request, consider the net ns in which this
cm_id is created.

Code was duplicated in cma_leave_mc_groups() and rdma_leave_multicast(),
which is now done using a helper function cma_leave_roce_mc_group().

Fixes: bee3c3c9 ("IB/cma: Join and leave multicast groups with IGMP")
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 321d7863
...@@ -1629,26 +1629,16 @@ static void cma_release_port(struct rdma_id_private *id_priv) ...@@ -1629,26 +1629,16 @@ static void cma_release_port(struct rdma_id_private *id_priv)
mutex_unlock(&lock); mutex_unlock(&lock);
} }
static void cma_leave_mc_groups(struct rdma_id_private *id_priv) static void cma_leave_roce_mc_group(struct rdma_id_private *id_priv,
struct cma_multicast *mc)
{ {
struct cma_multicast *mc;
while (!list_empty(&id_priv->mc_list)) {
mc = container_of(id_priv->mc_list.next,
struct cma_multicast, list);
list_del(&mc->list);
if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
id_priv->id.port_num)) {
ib_sa_free_multicast(mc->multicast.ib);
kfree(mc);
} else {
if (mc->igmp_joined) { if (mc->igmp_joined) {
struct rdma_dev_addr *dev_addr = struct rdma_dev_addr *dev_addr =
&id_priv->id.route.addr.dev_addr; &id_priv->id.route.addr.dev_addr;
struct net_device *ndev = NULL; struct net_device *ndev = NULL;
if (dev_addr->bound_dev_if) if (dev_addr->bound_dev_if)
ndev = dev_get_by_index(&init_net, ndev = dev_get_by_index(dev_addr->net,
dev_addr->bound_dev_if); dev_addr->bound_dev_if);
if (ndev) { if (ndev) {
cma_igmp_send(ndev, cma_igmp_send(ndev,
...@@ -1656,8 +1646,25 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv) ...@@ -1656,8 +1646,25 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
false); false);
dev_put(ndev); dev_put(ndev);
} }
mc->igmp_joined = false;
} }
kref_put(&mc->mcref, release_mc); kref_put(&mc->mcref, release_mc);
}
static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
{
struct cma_multicast *mc;
while (!list_empty(&id_priv->mc_list)) {
mc = container_of(id_priv->mc_list.next,
struct cma_multicast, list);
list_del(&mc->list);
if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
id_priv->id.port_num)) {
ib_sa_free_multicast(mc->multicast.ib);
kfree(mc);
} else {
cma_leave_roce_mc_group(id_priv, mc);
} }
} }
} }
...@@ -4268,23 +4275,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) ...@@ -4268,23 +4275,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
ib_sa_free_multicast(mc->multicast.ib); ib_sa_free_multicast(mc->multicast.ib);
kfree(mc); kfree(mc);
} else if (rdma_protocol_roce(id->device, id->port_num)) { } else if (rdma_protocol_roce(id->device, id->port_num)) {
if (mc->igmp_joined) { cma_leave_roce_mc_group(id_priv, mc);
struct rdma_dev_addr *dev_addr =
&id->route.addr.dev_addr;
struct net_device *ndev = NULL;
if (dev_addr->bound_dev_if)
ndev = dev_get_by_index(dev_addr->net,
dev_addr->bound_dev_if);
if (ndev) {
cma_igmp_send(ndev,
&mc->multicast.ib->rec.mgid,
false);
dev_put(ndev);
}
mc->igmp_joined = false;
}
kref_put(&mc->mcref, release_mc);
} }
return; return;
} }
......
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