Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3128814rdg; Tue, 17 Oct 2023 05:43:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2u9bLaksHgEGaw8crefvJTjAsnue6JPuO9RUhU9/15/sh7lL5Ltpo1dWBcTeIy2K45mk2 X-Received: by 2002:a05:6a20:a384:b0:153:39d9:56fe with SMTP id w4-20020a056a20a38400b0015339d956femr1526585pzk.47.1697546583785; Tue, 17 Oct 2023 05:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697546583; cv=none; d=google.com; s=arc-20160816; b=I8+SNoFaLjL8RZHBuk+kgSLh5rq0lWY3MniSfvkzEPPsw7TIzcafxURFd/8ZzzrDz5 QA+wykGgBNi911VaXQ8H1qWArEBFfFk1m1Dq1782Pdf0lWsXihznm/zCl+4gROdwtigg bndv5ivS4xfsJ/Ft7lyR5S/jQXnMh1p2kefK/U/7MO+IUqd5+6aa08+i6/vT73Xz4mML /LfqdX7a+h12xiktEEFR8HnCsI6Ax4QlIF8hHua7BOCR8WBnZs0b7R6MxTm1sqJ4QsVU Q5x4M8ePPpvM84G2t548fosJjwDdBLU+00A25QRx3KKLTyAyz6IDFl91yERGdsyrTWah cmEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=J4rQqBHe4zcfb4kQdgFtsHuTis1hQmed+ZOMIG2p2p0=; fh=bqCLTmKd7a94lwczbPziWIXwJo6LRuvipCBdtuKMQIk=; b=c1O2nBHlBXBzTsx/U4LXTZuB4eda9kMsr78gh8O9Ks/cTpVZH3AXsHDGmsI1UrCtAK wteHof17y4QZei8aRKrMRjTWkLLEOfU5j0s7FBbDyGaBOOqePieWrgWqsW06H//zjk9N 7v4cNY9C1ONrv5+J+ONoV0dX7oNOkOU7SZ0ImZDg9dtT6QOTyaINDLj8g0oRJ4c9dbhD mtOn80KS7X0tmLKt/6psmtYY/WsfIKZKGor6anweZKPtMpT8utfbKugMITyoeUwSYavs dX0xSBn6g4ZoygOqd6DZ58TOSUOxHOWb/7SfFJRkmaTvd/QnmiXqdP/tiobPNa2G6MVX /QcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id kx14-20020a170902f94e00b001c9af7debb2si1547354plb.525.2023.10.17.05.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4CA648079B69; Tue, 17 Oct 2023 05:43:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234760AbjJQMmv (ORCPT + 99 others); Tue, 17 Oct 2023 08:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234612AbjJQMms (ORCPT ); Tue, 17 Oct 2023 08:42:48 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A26EF7; Tue, 17 Oct 2023 05:42:45 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=guangguan.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VuNiO3D_1697546559; Received: from localhost.localdomain(mailfrom:guangguan.wang@linux.alibaba.com fp:SMTPD_---0VuNiO3D_1697546559) by smtp.aliyun-inc.com; Tue, 17 Oct 2023 20:42:39 +0800 From: Guangguan Wang To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: tonylu@linux.alibaba.com, alibuda@linux.alibaba.com, guwen@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2 2/2] net/smc: correct the reason code in smc_listen_find_device when fallback Date: Tue, 17 Oct 2023 20:42:34 +0800 Message-Id: <20231017124234.99574-3-guangguan.wang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20231017124234.99574-1-guangguan.wang@linux.alibaba.com> References: <20231017124234.99574-1-guangguan.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 17 Oct 2023 05:43:01 -0700 (PDT) The ini->rc is used to store the last error happened when finding usable ism or rdma device in smc_listen_find_device, and is set by calling smc_ find_device_store_rc. Once the ini->rc is assigned to an none-zero value, the value can not be overwritten anymore. So the ini-rc should be set to the error reason only when an error actually occurs. When finding ISM/RDMA devices, device not found is not a real error, as not all machine have ISM/RDMA devices. Failures after device found, when initializing device or when initializing connection, is real errors, and should be store in ini->rc. SMC_CLC_DECL_DIFFPREFIX also is not a real error, as for SMC-RV2, it is not require same prefix. Signed-off-by: Guangguan Wang --- net/smc/af_smc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index b3a67a168495..21e9c6ec4d01 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2163,10 +2163,8 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc, } mutex_unlock(&smcd_dev_list.mutex); - if (!ini->ism_dev[0]) { - smc_find_device_store_rc(SMC_CLC_DECL_NOSMCD2DEV, ini); + if (!ini->ism_dev[0]) goto not_found; - } smc_ism_get_system_eid(&eid); if (!smc_clc_match_eid(ini->negotiated_eid, smc_v2_ext, @@ -2216,9 +2214,9 @@ static void smc_find_ism_v1_device_serv(struct smc_sock *new_smc, rc = smc_listen_ism_init(new_smc, ini); if (!rc) return; /* V1 ISM device found */ + smc_find_device_store_rc(rc, ini); not_found: - smc_find_device_store_rc(rc, ini); ini->smcd_version &= ~SMC_V1; ini->ism_dev[0] = NULL; ini->is_smcd = false; @@ -2267,10 +2265,8 @@ static void smc_find_rdma_v2_device_serv(struct smc_sock *new_smc, ini->smcrv2.saddr = new_smc->clcsock->sk->sk_rcv_saddr; ini->smcrv2.daddr = smc_ib_gid_to_ipv4(smc_v2_ext->roce); rc = smc_find_rdma_device(new_smc, ini); - if (rc) { - smc_find_device_store_rc(rc, ini); + if (rc) goto not_found; - } if (!ini->smcrv2.uses_gateway) memcpy(ini->smcrv2.nexthop_mac, pclc->lcl.mac, ETH_ALEN); @@ -2331,8 +2327,6 @@ static int smc_listen_find_device(struct smc_sock *new_smc, /* check for matching IP prefix and subnet length (V1) */ prfx_rc = smc_listen_prfx_check(new_smc, pclc); - if (prfx_rc) - smc_find_device_store_rc(prfx_rc, ini); /* get vlan id from IP device */ if (smc_vlan_by_tcpsk(new_smc->clcsock, ini)) -- 2.24.3 (Apple Git-128)