RDMA/cma: Use the right net namespace for the rdma_cm_id
authorParav Pandit <parav@mellanox.com>
Mon, 8 Jan 2018 15:04:43 +0000 (17:04 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 11 Jan 2018 05:00:33 +0000 (22:00 -0700)
The net namespace is set in addr during create_rdma_id(),
cma_resolve_iboe_route() should use that instead of the
init namespace.

The original code was added in commit fa20105e09e9 ("IB/cma: Add support
for network namespaces"), but this path wasn't in use back then.

This patch updates the code to use right namespace, as preparation
for improving namespace support.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cma.c

index 65c55f79444a3a26dc5e7eb6d1ad341d701e00a3..7db2355541f624145b1520c2ab74f65a7a8049e1 100644 (file)
@@ -2566,7 +2566,8 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
                goto err2;
        }
 
-       ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if);
+       ndev = dev_get_by_index(addr->dev_addr.net,
+                               addr->dev_addr.bound_dev_if);
        if (!ndev) {
                ret = -ENODEV;
                goto err2;
@@ -2582,7 +2583,7 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
                gid_type = ib_network_to_gid_type(addr->dev_addr.network);
        route->path_rec->rec_type = sa_conv_gid_to_pathrec_type(gid_type);
 
-       sa_path_set_ndev(route->path_rec, &init_net);
+       sa_path_set_ndev(route->path_rec, addr->dev_addr.net);
        sa_path_set_ifindex(route->path_rec, ndev->ifindex);
        sa_path_set_dmac(route->path_rec, addr->dev_addr.dst_dev_addr);