Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+24 −33
Original line number Diff line number Diff line
@@ -1629,26 +1629,16 @@ static void cma_release_port(struct rdma_id_private *id_priv)
	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) {
		struct rdma_dev_addr *dev_addr =
			&id_priv->id.route.addr.dev_addr;
		struct net_device *ndev = NULL;

		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);
		if (ndev) {
			cma_igmp_send(ndev,
@@ -1656,9 +1646,26 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
				      false);
			dev_put(ndev);
		}
		mc->igmp_joined = false;
	}
	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)
				ib_sa_free_multicast(mc->multicast.ib);
				kfree(mc);
			} else if (rdma_protocol_roce(id->device, id->port_num)) {
				if (mc->igmp_joined) {
					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);
				cma_leave_roce_mc_group(id_priv, mc);
			}
			return;
		}