From patchwork Tue Dec 6 11:16:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9462373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59CB36074E for ; Tue, 6 Dec 2016 11:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E9C283C2 for ; Tue, 6 Dec 2016 11:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3795C283E1; Tue, 6 Dec 2016 11:17:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18392283C2 for ; Tue, 6 Dec 2016 11:17:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752400AbcLFLRf (ORCPT ); Tue, 6 Dec 2016 06:17:35 -0500 Received: from mail-oi0-f42.google.com ([209.85.218.42]:33659 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751745AbcLFLRc (ORCPT ); Tue, 6 Dec 2016 06:17:32 -0500 Received: by mail-oi0-f42.google.com with SMTP id w63so374453395oiw.0 for ; Tue, 06 Dec 2016 03:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=0S27YdJAM9EJA2V6cpJWUhl38MNlFzFJ3PgOlmzVKqQ=; b=uBsL/dvy867IQx0PqIrf7WTVVtk8mseQgZ1Cy4cgJ/t2Ie5jhFlUiOP9wK2yJP5JkA 28JKNPPaLohvLAOhqQDEhY8YykTkCUtmx6Cd5hwPCeCt2Pnyht/ZnHIRT32k9wc2vCUx VanUfLC30OoqX577eykb0VMQLRIgpiINf80QNH0nvju4TFtswQHK3UUjEcHCsmvWChbJ 5VwVJu+dHQFJtQEZGrXW9rHTdS7gtsMPHomkGHzRyPH30Rm2aPLVdqqNjD6lzgz+XAzD eMtClE4mw3MUPKbQ+wpw9m3lPA1FZ3DXVSv6KsUReaGRM8wwVQ8Eh/RtjPBNL0i/XwgC OErA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=0S27YdJAM9EJA2V6cpJWUhl38MNlFzFJ3PgOlmzVKqQ=; b=IxL3Zct4uANS/3LGM6/hazCGaS+jO3sGJxrA9Ye/AFiHXJhot5l7aHohrKwgUFwShB ifxkvescugh5+KRsGNL94Nhg0iHZDFRQsNFoc5W2weEUbi3R5ze14dKvR3hytmcnkuH9 mgqE42OBRtt/k46GB8x9uSXJ7HdjWy0G3fy73G+0WndgTj5xHh+sI+CJjVJdb2cpNcLC p6UhE34gPfhhIyf84wOUu8rqWNW8/YVg5nm4UHj8K53dodBA59s9ECjSpOQOii5KkzGF vf4SGCSQXUn+v52Ao7dsZzd4T5JuHAG/vvysmxarLHGXkak5sD1l6kcRCeZQGywW3Krf ctVw== X-Gm-Message-State: AKaTC00e5UolTOVMdjIAO4xGOIvhs7a5eosho0UOk520xLoSkqxL3YqgGrslXQgnaeDbdVY85bwMQtr5oTnAzrLV X-Received: by 10.157.46.149 with SMTP id w21mr31582008ota.219.1481023010334; Tue, 06 Dec 2016 03:16:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.165.135 with HTTP; Tue, 6 Dec 2016 03:16:29 -0800 (PST) From: Jinpu Wang Date: Tue, 6 Dec 2016 12:16:29 +0100 Message-ID: Subject: [PATCH] cma: resolve to first active IB port To: Doug Ledford , Sean Hefty , Hal Rosenstock , "linux-rdma@vger.kernel.org" Cc: Michael Wang Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Doug, Sean and Hal, We have problem when connect connection from second port with AF_IB, when first port is down. We will fail when resovle route. It turned out when resolve addr, in cma_resolve_ib_dev, we will choose the first port if subnet_prefix is the same, in our case we use default well known prefix. I proposal fix below to resolve to first acrive IB port: Note: I will attach another one for easily apply if the format mangled by gmail. Patch created based on Linux 4.9-rc7. From b42e51deb8da3c1b596cb4332b6815e5ac8658a7 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Tue, 6 Dec 2016 09:01:04 +0100 Subject: [PATCH] cma: resolve to first active ib_port When resolve addr if we don't give src addr, cma core will try to resolve to ib device on itself, current logic is only check if it has same subnet_prefix, which is not enough if we use default well known gid, we should also check if port is active. Signed-off-by: Jack Wang --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) sgid = gid; @@ -692,7 +694,9 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) } if (!cma_dev && (gid.global.subnet_prefix == - dgid->global.subnet_prefix)) { + dgid->global.subnet_prefix) && + (!ib_query_port(cur_dev->device, p, &attr) && + attr.state == IB_PORT_ACTIVE)) { cma_dev = cur_dev; sgid = gid; id_priv->id.port_num = p; From b42e51deb8da3c1b596cb4332b6815e5ac8658a7 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Tue, 6 Dec 2016 09:01:04 +0100 Subject: [PATCH] cma: resolve to first active ib_port When resolve addr if we don't give src addr, cma core will try to resolve to ib device on itself, current logic is only check if it has same subnet_prefix, which is not enough if we use default well known gid, we should also check if port is active. Signed-off-by: Jack Wang --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 2a6fc47..9e46b42 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -684,6 +684,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, &gid, NULL); i++) { + struct ib_port_attr attr; + if (!memcmp(&gid, dgid, sizeof(gid))) { cma_dev = cur_dev; sgid = gid; @@ -692,7 +694,9 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) } if (!cma_dev && (gid.global.subnet_prefix == - dgid->global.subnet_prefix)) { + dgid->global.subnet_prefix) && + (!ib_query_port(cur_dev->device, p, &attr) && + attr.state == IB_PORT_ACTIVE)) { cma_dev = cur_dev; sgid = gid; id_priv->id.port_num = p; -- 2.7.4