From patchwork Mon Nov 22 11:53:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 12631791 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D711C433EF for ; Mon, 22 Nov 2021 11:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbhKVL5O (ORCPT ); Mon, 22 Nov 2021 06:57:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:32938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239451AbhKVL5N (ORCPT ); Mon, 22 Nov 2021 06:57:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17AD760240; Mon, 22 Nov 2021 11:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637582047; bh=+WfgAau+hYSje8yRBW+PXBBqEqMtRy+awEinDB0lNqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/UYotcEdAIuT60s2//IGh0yXjT9kOBkL3XCNpFqjbcUtt2xsLnE6J/dxDf4sC0qG NEsPBbI1l19Er68hoTNwlDVviYqgdWlN59DS7P6cGlEIYHpspsGAb7X/O7Up0U2tNr IW/8WCMo1n1j3MwNNnqTeKPp91p5Wf/Al8x+4Pf+AdCv238FkcydeS8pIxzcED/TC6 aE8f3Iim21PchGDeElJvoAUgESfC3C5K+8rNgsnWufsFTPj+1pzIdre5By5tv3cVbk CJHb5YiIkn0GtE/iOKfTFEtAX2V6UsHc1YpuJFpXQaW5OF87VUGBd9kukBLkJCLAta Zh/Ujlf8EOLzw== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Avihai Horon , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Mark Zhang , "Michael S. Tsirkin" Subject: [PATCH rdma-next 2/3] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 22 Nov 2021 13:53:57 +0200 Message-Id: X-Mailer: git-send-email 2.33.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Avihai Horon Currently, ib_find_gid() will stop searching after encountering the first empty GID table entry. This behavior is wrong since neither IB nor RoCE spec enforce tightly packed GID tables. For example, when a valid GID entry exists at index N, and if a GID entry is empty at index N-1, ib_find_gid() will fail to find the valid entry. Fix it by making ib_find_gid() continue searching even after encountering missing entries. Fixes: 5eb620c81ce3 ("IB/core: Add helpers for uncached GID and P_Key searches") Signed-off-by: Avihai Horon Reviewed-by: Mark Zhang Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 22a4adda7981..b5d8443030d4 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2460,8 +2460,11 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid, for (i = 0; i < device->port_data[port].immutable.gid_tbl_len; ++i) { ret = rdma_query_gid(device, port, i, &tmp_gid); + if (ret == -ENOENT) + continue; if (ret) return ret; + if (!memcmp(&tmp_gid, gid, sizeof *gid)) { *port_num = port; if (index)