IB/cma: Print warning on different inner and header P_Keys
authorHaggai Eran <haggaie@mellanox.com>
Mon, 29 Feb 2016 13:45:12 +0000 (15:45 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 1 Mar 2016 16:04:07 +0000 (11:04 -0500)
Commit 4c21b5bcef73 ("IB/cma: Add net_dev and private data checks to RDMA
CM") added checks for incoming RDMA CM requests that they can be matched to
a netdev based on the P_Key in the BTH of the request. This behavior was
reverted in commit ab3964ad2acf ("IB/cma: Use inner P_Key to determine
netdev"), since the mlx5 and ipath drivers didn't send the correct value
in the BTH P_Key.

Since the ipath driver was removed, and the mlx5 driver can now send GSI
packets on different P_Keys, we could revert the patch to let the rdma_cm
module look on the BTH P_Key when deciding to what netdev a packet belongs.
However, that still breaks compatibility with the older drivers.

Change the behavior to print a warning when receiving a request that has a
different BTH P_Key and inner payload P_Key. In the future, after users
have seen the warnings and upgraded their setups, remove the warning and
block these requests.

Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cma.c

index 9729639df407abdc382959ef8151fbbcc3370589..7eace1ffa74d45fb9ed41da41852510cf6d6b0ef 100644 (file)
@@ -1206,6 +1206,10 @@ static int cma_save_req_info(const struct ib_cm_event *ib_event,
                req->has_gid    = true;
                req->service_id = req_param->primary_path->service_id;
                req->pkey       = be16_to_cpu(req_param->primary_path->pkey);
+               if (req->pkey != req_param->bth_pkey)
+                       pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and primary path P_Key (0x%x)\n"
+                                           "RDMA CMA: in the future this may cause the request to be dropped\n",
+                                           req_param->bth_pkey, req->pkey);
                break;
        case IB_CM_SIDR_REQ_RECEIVED:
                req->device     = sidr_param->listen_id->device;
@@ -1213,6 +1217,10 @@ static int cma_save_req_info(const struct ib_cm_event *ib_event,
                req->has_gid    = false;
                req->service_id = sidr_param->service_id;
                req->pkey       = sidr_param->pkey;
+               if (req->pkey != sidr_param->bth_pkey)
+                       pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and SIDR request payload P_Key (0x%x)\n"
+                                           "RDMA CMA: in the future this may cause the request to be dropped\n",
+                                           sidr_param->bth_pkey, req->pkey);
                break;
        default:
                return -EINVAL;