Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2223206rwo; Thu, 3 Aug 2023 06:35:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnGoXTQCPpOy/lZ2kUVvBjVG14oWlpvGlDkeADlPsDjiXrLtGHejXVoBZAgXEIYHGbQSRX X-Received: by 2002:a05:6402:100c:b0:523:d51:bb2 with SMTP id c12-20020a056402100c00b005230d510bb2mr1665908edu.15.1691069721894; Thu, 03 Aug 2023 06:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691069721; cv=none; d=google.com; s=arc-20160816; b=JyGXQsGOQhkH6z+qNrjx/D63pwv0xhpy9sF+YoCNaOQA+iNu6oXrWchHT+BQnilxTK gdNx/HZ+fcumexsO61ofF3UFBn93M8pNQwqqs4I26AC2TbjUI1itzHc74pWK252LRzsx qfFtG5DxenbWajTnTH5JNX/OGZu8AdyXnQw83cJKTObIsx0re28rejfd1hjxVHVFKDmo MADPwsIaYavkUJg/WeWYNnKD1FD0OHTeo14yt/Sm/Y8gcYy22FMRlFjNPvAVgvf8ERId cu4jCOJmJ4EAxr73DLW3A+c4ZjyVMQ+9sMk/FxJTce5sdYkgAVZmKPFKe6jSopCVrz1C tUag== 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=1SD1cb478K5ZjHjz1VwcoZ4LZ4rh/myvJq+rzsXhLgM=; fh=8ip4DUddnTzabERi8TVpNN2xDOzoY7hIlOifJESapF8=; b=Y0p9zAkd+OvOPQy/VE6f4ruoSccSmdhAlz+Hr0m4vqX9OQXy4l+HC0+1HidUVs1cJB j/UIk+NhRsZYD6RE9TPPp8yxBwft3YInhatJS4WEvM1qjhqjak+ryRArvU/euM1yhjoQ WpVtqXblPEa3FwmaF4e0RVfocsi1LfRhDJTZvRxrmA86Fvhba6+3rjkFUeiMQ1ZllI8K D9d1+TKe4Apdsa/B3vGJLn2XPAYbRbr2NXWMqqZLCTqjDZ6dvNPIjjr2AC4hYZ65Kgp0 ptmUto0QqgxOvkvijWkxw+qdVffG7KEqETYzFLHW2DmatdgrmsC6swnCgT4q05KVUOdT r3kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a056402161300b00522216bf150si8818408edv.578.2023.08.03.06.34.55; Thu, 03 Aug 2023 06:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234849AbjHCNYh (ORCPT + 99 others); Thu, 3 Aug 2023 09:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234935AbjHCNYc (ORCPT ); Thu, 3 Aug 2023 09:24:32 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9058B1702; Thu, 3 Aug 2023 06:24:30 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=guangguan.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0Voz-FR6_1691069066; Received: from localhost.localdomain(mailfrom:guangguan.wang@linux.alibaba.com fp:SMTPD_---0Voz-FR6_1691069066) by smtp.aliyun-inc.com; Thu, 03 Aug 2023 21:24:26 +0800 From: Guangguan Wang To: wenjia@linux.ibm.com, jaka@linux.ibm.com, kgraul@linux.ibm.com, tonylu@linux.alibaba.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: alibuda@linux.alibaba.com, guwen@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 3/6] net/smc: support smc v2.x features validate Date: Thu, 3 Aug 2023 21:24:19 +0800 Message-Id: <20230803132422.6280-4-guangguan.wang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230803132422.6280-1-guangguan.wang@linux.alibaba.com> References: <20230803132422.6280-1-guangguan.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support smc v2.x features validate for smc v2.1. Signed-off-by: Guangguan Wang Reviewed-by: Tony Lu --- net/smc/af_smc.c | 18 ++++++++++++++++++ net/smc/smc_clc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc_clc.h | 7 +++++++ 3 files changed, 71 insertions(+) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 52279bdc100a..fd58e25beddf 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1169,6 +1169,7 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc, struct smc_clc_first_contact_ext *fce = (struct smc_clc_first_contact_ext *) (((u8 *)clc_v2) + sizeof(*clc_v2)); + int rc; if (!ini->first_contact_peer || aclc->hdr.version == SMC_V1) return 0; @@ -1191,6 +1192,9 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc, if (fce->release > SMC_RELEASE) return SMC_CLC_DECL_VERSMISMAT; ini->release_ver = fce->release; + rc = smc_clc_cli_v2x_features_validate(fce, ini); + if (rc) + return rc; return 0; } @@ -1367,6 +1371,9 @@ static int smc_connect_ism(struct smc_sock *smc, if (fce->release > SMC_RELEASE) return SMC_CLC_DECL_VERSMISMAT; ini->release_ver = fce->release; + rc = smc_clc_cli_v2x_features_validate(fce, ini); + if (rc) + return rc; } rc = smc_v2_determine_accepted_chid(aclc_v2, ini); @@ -2417,6 +2424,10 @@ static void smc_listen_work(struct work_struct *work) if (rc) goto out_decl; + rc = smc_clc_srv_v2x_features_validate(pclc, ini); + if (rc) + goto out_decl; + mutex_lock(&smc_server_lgr_pending); smc_close_init(new_smc); smc_rx_init(new_smc); @@ -2449,6 +2460,13 @@ static void smc_listen_work(struct work_struct *work) goto out_decl; } + rc = smc_clc_v2x_features_confirm_check(cclc, ini); + if (rc) { + if (!ini->is_smcd) + goto out_unlock; + goto out_decl; + } + /* finish worker */ if (!ini->is_smcd) { rc = smc_listen_rdma_finish(new_smc, cclc, diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index df8d17491a25..b25a72f1c9ac 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -1158,6 +1158,52 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact, return len > 0 ? 0 : len; } +int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc, + struct smc_init_info *ini) +{ + struct smc_clc_v2_extension *pclc_v2_ext; + + if ((!(ini->smcd_version & SMC_V2) && !(ini->smcr_version & SMC_V2)) || + ini->release_ver < SMC_RELEASE_1) + return 0; + + pclc_v2_ext = smc_get_clc_v2_ext(pclc); + if (!pclc_v2_ext) + return SMC_CLC_DECL_NOV2EXT; + + return 0; +} + +int smc_clc_cli_v2x_features_validate(struct smc_clc_first_contact_ext *fce, + struct smc_init_info *ini) +{ + if (ini->release_ver < SMC_RELEASE_1) + return 0; + + return 0; +} + +int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc, + struct smc_init_info *ini) +{ + struct smc_clc_msg_accept_confirm_v2 *clc_v2 = + (struct smc_clc_msg_accept_confirm_v2 *)cclc; + struct smc_clc_first_contact_ext *fce = + smc_get_clc_first_contact_ext(clc_v2, ini->is_smcd); + + if (cclc->hdr.version == SMC_V1 || + !(cclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK)) + return 0; + + if (ini->release_ver != fce->release) + return SMC_CLC_DECL_RELEASEERR; + + if (fce->release < SMC_RELEASE_1) + return 0; + + return 0; +} + void smc_clc_get_hostname(u8 **host) { *host = &smc_hostname[0]; diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h index 6133276a8839..66932bfdc6d0 100644 --- a/net/smc/smc_clc.h +++ b/net/smc/smc_clc.h @@ -45,6 +45,7 @@ #define SMC_CLC_DECL_NOSEID 0x03030006 /* peer sent no SEID */ #define SMC_CLC_DECL_NOSMCD2DEV 0x03030007 /* no SMC-Dv2 device found */ #define SMC_CLC_DECL_NOUEID 0x03030008 /* peer sent no UEID */ +#define SMC_CLC_DECL_RELEASEERR 0x03030009 /* release version negotiate failed */ #define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/ #define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */ #define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */ @@ -415,6 +416,12 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact, u8 version, u8 *eid, struct smc_init_info *ini); int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact, u8 version, u8 *negotiated_eid, struct smc_init_info *ini); +int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc, + struct smc_init_info *ini); +int smc_clc_cli_v2x_features_validate(struct smc_clc_first_contact_ext *fce, + struct smc_init_info *ini); +int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc, + struct smc_init_info *ini); void smc_clc_init(void) __init; void smc_clc_exit(void); void smc_clc_get_hostname(u8 **host); -- 2.24.3 (Apple Git-128)