Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp863867rdb; Sat, 7 Oct 2023 02:14:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+GZ1SzDf6qy1iAH50HuVkvsE8+ibNpXuSx3ulmUJpg/8sZx0R8tWvH1R7+ae4bUPpEGYT X-Received: by 2002:a05:6808:210b:b0:3a7:2456:6af6 with SMTP id r11-20020a056808210b00b003a724566af6mr12456489oiw.31.1696670044124; Sat, 07 Oct 2023 02:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696670044; cv=none; d=google.com; s=arc-20160816; b=VXq05Tb1VlBZJllZ0AzaH5EiW/K6xvN+RX8hLULBQvPaKtXjr2oKLH5pN6QGEH8TVf SwDM8hiUmzZgP87eBBh619ffhZmbq6NQ4t5FAiHcJ83vevgntSgTBwSfwwpucgF9H9fc K8gg1wGNlH43qP40av4cEFV2y88HWRDYquIA9njqhbMb8/KM51GVTwCUFhX55ltaNQtT IwUUZ+vZnilFqU9Oa6pGVU3jjGtQ/YIE1oE2tjFHkoGCoEBSZ1nUkGS7eWQwycBa+vPA bKsi/ZNOeEjihgX5Y4e0cqfHAujnyWiMZDq/HBRPw0V61I9Tzl15mOPAsNbEn783LXnX k03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=xCw8Ix4BFUZ8tJ/NwHbxaDU6H8uDR3CgRAxgMuDdVyU=; fh=4+JimgV76FTCU5F7qw4LI7HKU8VCG/PglFvn+GNnNp0=; b=pMk7Mj9xqwyayg1bl+qp51qAz4DWCj9YknV2b6vMSXbJ3dbQrjBMTAfXulZl7MScZ+ 9eyJe0+Pnn2QjUtIK+kPT2F4egBqqvdZNr7zBx97UIGZp49L9s+aLUCqkrtiLlPD82/a 484w4d1xRA4+D2Rw4gdot/EcGCOYMhMLLM/UwyzrZEp2jnotTnEKbMliusW6BX3Xb3Yt Lb+yz4yfiAKkTCcEKSBy2egZS0KTE+/Fa++WpvlO5Jalm5RIBmHgXvN7f5SwRqqXZVSn 9kxjfVlBBKyVa09J76iwnWgIKZtaoFPSvv+c2jJxbXYOLVgFHRUqQYTeU4wSRWaRI+Vk YzCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x128-20020a636386000000b00565342470c4si5464807pgb.801.2023.10.07.02.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 02:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 6EFFD80ACC5E; Sat, 7 Oct 2023 02:14:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343661AbjJGJNq (ORCPT + 99 others); Sat, 7 Oct 2023 05:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjJGJNp (ORCPT ); Sat, 7 Oct 2023 05:13:45 -0400 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CCBDB9; Sat, 7 Oct 2023 02:13:43 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=dust.li@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0VtZZePq_1696670019; Received: from localhost(mailfrom:dust.li@linux.alibaba.com fp:SMTPD_---0VtZZePq_1696670019) by smtp.aliyun-inc.com; Sat, 07 Oct 2023 17:13:40 +0800 Date: Sat, 7 Oct 2023 17:13:39 +0800 From: Dust Li To: Albert Huang , Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu Cc: Wen Gu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net/smc: fix smc clc failed issue when netdevice not in init_net Message-ID: <20231007091339.GH92403@linux.alibaba.com> Reply-To: dust.li@linux.alibaba.com References: <20231007084420.80236-1-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231007084420.80236-1-huangjie.albert@bytedance.com> X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sat, 07 Oct 2023 02:14:01 -0700 (PDT) X-Spam-Level: ** On Sat, Oct 07, 2023 at 04:44:19PM +0800, Albert Huang wrote: >If the netdevice is within a container and communicates externally >through network technologies such as VxLAN, we won't be able to find >routing information in the init_net namespace. To address this issue, >we need to add a struct net parameter to the smc_ib_find_route function. >This allow us to locate the routing information within the corresponding >net namespace, ensuring the correct completion of the SMC CLC interaction. > You should add a Fixes tag here, I think it should be: Fixes: e5c4744cfb59 ("net/smc: add SMC-Rv2 connection establishment") >Signed-off-by: Albert Huang >--- > net/smc/af_smc.c | 3 ++- > net/smc/smc_ib.c | 7 ++++--- > net/smc/smc_ib.h | 2 +- > 3 files changed, 7 insertions(+), 5 deletions(-) > >diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c >index bacdd971615e..7a874da90c7f 100644 >--- a/net/smc/af_smc.c >+++ b/net/smc/af_smc.c >@@ -1201,6 +1201,7 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc, > (struct smc_clc_msg_accept_confirm_v2 *)aclc; > struct smc_clc_first_contact_ext *fce = > smc_get_clc_first_contact_ext(clc_v2, false); >+ struct net *net = sock_net(&smc->sk); > int rc; > > if (!ini->first_contact_peer || aclc->hdr.version == SMC_V1) >@@ -1210,7 +1211,7 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc, > memcpy(ini->smcrv2.nexthop_mac, &aclc->r0.lcl.mac, ETH_ALEN); > ini->smcrv2.uses_gateway = false; > } else { >- if (smc_ib_find_route(smc->clcsock->sk->sk_rcv_saddr, >+ if (smc_ib_find_route(net, smc->clcsock->sk->sk_rcv_saddr, > smc_ib_gid_to_ipv4(aclc->r0.lcl.gid), > ini->smcrv2.nexthop_mac, > &ini->smcrv2.uses_gateway)) >diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c >index 9b66d6aeeb1a..89981dbe46c9 100644 >--- a/net/smc/smc_ib.c >+++ b/net/smc/smc_ib.c >@@ -193,7 +193,7 @@ bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport) > return smcibdev->pattr[ibport - 1].state == IB_PORT_ACTIVE; > } > >-int smc_ib_find_route(__be32 saddr, __be32 daddr, >+int smc_ib_find_route(struct net *net, __be32 saddr, __be32 daddr, > u8 nexthop_mac[], u8 *uses_gateway) > { > struct neighbour *neigh = NULL; >@@ -205,7 +205,7 @@ int smc_ib_find_route(__be32 saddr, __be32 daddr, > > if (daddr == cpu_to_be32(INADDR_NONE)) > goto out; >- rt = ip_route_output_flow(&init_net, &fl4, NULL); >+ rt = ip_route_output_flow(net, &fl4, NULL); > if (IS_ERR(rt)) > goto out; > if (rt->rt_uses_gateway && rt->rt_gw_family != AF_INET) >@@ -235,6 +235,7 @@ static int smc_ib_determine_gid_rcu(const struct net_device *ndev, > if (smcrv2 && attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP && > smc_ib_gid_to_ipv4((u8 *)&attr->gid) != cpu_to_be32(INADDR_NONE)) { > struct in_device *in_dev = __in_dev_get_rcu(ndev); >+ struct net *net = dev_net(ndev); > const struct in_ifaddr *ifa; > bool subnet_match = false; > >@@ -248,7 +249,7 @@ static int smc_ib_determine_gid_rcu(const struct net_device *ndev, > } > if (!subnet_match) > goto out; >- if (smcrv2->daddr && smc_ib_find_route(smcrv2->saddr, >+ if (smcrv2->daddr && smc_ib_find_route(net, smcrv2->saddr, > smcrv2->daddr, > smcrv2->nexthop_mac, > &smcrv2->uses_gateway)) >diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h >index 4df5f8c8a0a1..ef8ac2b7546d 100644 >--- a/net/smc/smc_ib.h >+++ b/net/smc/smc_ib.h >@@ -112,7 +112,7 @@ void smc_ib_sync_sg_for_device(struct smc_link *lnk, > int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport, > unsigned short vlan_id, u8 gid[], u8 *sgid_index, > struct smc_init_info_smcrv2 *smcrv2); >-int smc_ib_find_route(__be32 saddr, __be32 daddr, >+int smc_ib_find_route(struct net *net, __be32 saddr, __be32 daddr, > u8 nexthop_mac[], u8 *uses_gateway); > bool smc_ib_is_valid_local_systemid(void); > int smcr_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb); >-- >2.37.1 (Apple Git-137.1)