RDMA/cma: Fix rdma_cm raw IB path setting for RoCE
authorParav Pandit <parav@mellanox.com>
Mon, 8 Jan 2018 15:04:47 +0000 (17:04 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 11 Jan 2018 05:00:33 +0000 (22:00 -0700)
rdma_set_ib_path() missed setting path record fields for RoCE
transport when RoCE support was added.

This results in setting incorrect ndev, destination mac address,
incorrect GID type etc errors when user space attempts to set a raw
IB path using the roce IB path compatibility mapping from userspace.

Fixes: 3c86aa70bf67 ("RDMA/cm: Add RDMA CM support for IBoE devices")
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 5c158cda08e31d5d474608cf56f5d64bf04e046c..30d1c32a816f91b4e9fcd7bf1dd00b3a801ff655 100644 (file)
@@ -2521,6 +2521,7 @@ int rdma_set_ib_path(struct rdma_cm_id *id,
                     struct sa_path_rec *path_rec)
 {
        struct rdma_id_private *id_priv;
+       struct net_device *ndev;
        int ret;
 
        id_priv = container_of(id, struct rdma_id_private, id);
@@ -2535,8 +2536,21 @@ int rdma_set_ib_path(struct rdma_cm_id *id,
                goto err;
        }
 
+       if (rdma_protocol_roce(id->device, id->port_num)) {
+               ndev = cma_iboe_set_path_rec_l2_fields(id_priv);
+               if (!ndev) {
+                       ret = -ENODEV;
+                       goto err_free;
+               }
+               dev_put(ndev);
+       }
+
        id->route.num_paths = 1;
        return 0;
+
+err_free:
+       kfree(id->route.path_rec);
+       id->route.path_rec = NULL;
 err:
        cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_ADDR_RESOLVED);
        return ret;