Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp640964rdg; Wed, 11 Oct 2023 00:49:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0y0jRCkN7lkpT4lqDCbIjAA/3sww/LKQy8poqscpzTjmsz7tj6H6dhPF5zx/RwlU7yKUK X-Received: by 2002:a05:6300:8089:b0:173:f8c9:94ef with SMTP id ap9-20020a056300808900b00173f8c994efmr180505pzc.41.1697010577033; Wed, 11 Oct 2023 00:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697010577; cv=none; d=google.com; s=arc-20160816; b=BiqtILDwHbaJqAR2Wuevk5XgDX6PDsJQmsn3sufYR3QMOLuwLGMRuSLu/Hne6gNZe5 3SSPCEQKQEb1r/gzdSqsEYk/jEcI+VkMqnfHlhV/9wPx9omMepPxmbQJBGhV2DxKRkXL inuvo50qcN0YJBycml+z64s5J760VfSozcdSCD5ptX0ITEJKmHNsqiPBdtW84XX0TvOn DCYzD1DOFLSw/VMGiqTZvphRo45naUp6YGNk3XyBVx2i354JPm0B/2P28HqPutK4xmvE A1OZMqecEM+ollVAmV7JmzJiTlK/qtf1290+aIuTVwSBtwD4wC0Kh5IXW3vYC6SBHgFN LdhQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YFdj5CLJdNz+//giZZucR/OWu0lsyTJv2DBHSoR3lfg=; fh=w/HN+/RDhyzjBtvHDDQy5SmFSFXr83NvVClCJ3n181M=; b=RTAnsGX8vxPeHfeIjCvWOgx3JnYMLDkrXm8VbOgb++3XR5Z/kItNqPKSlYIf5cClMT FO3NHTfsGHGEVYpGSSbUWJlmLZ2cWQF4xBEwAFl11FmyVqLD0BxDqK7jsiCaBY/7mwXF cqMKIg9WiApQzFUnGoTTnVn9UpHATtAPkBrW7e72zXd7zVlpQkkE6m89sAvs8XXykjpO 5jScqHJUPRBP//dygh5zFLhtRKJ628FHDgs7IoHHCGlU4M/E/zB1PMxo0XsLTcTi6bMp C8xnoD2B/6oO8Dtld4POjAR1WsZxb8UgN90+PASVJdgzLWC8xSh9I9/Qo47Q8P7HQ+On 6e1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=J8YyDLbL; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f13-20020a170902ce8d00b001b9e9fa3a38si3279272plg.646.2023.10.11.00.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:49:37 -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; dkim=pass header.i=@bytedance.com header.s=google header.b=J8YyDLbL; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id F0BAB8066699; Wed, 11 Oct 2023 00:49:32 -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 S230154AbjJKHtQ (ORCPT + 99 others); Wed, 11 Oct 2023 03:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbjJKHtN (ORCPT ); Wed, 11 Oct 2023 03:49:13 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC0A692 for ; Wed, 11 Oct 2023 00:49:10 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c61bde0b4bso56112575ad.3 for ; Wed, 11 Oct 2023 00:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697010550; x=1697615350; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YFdj5CLJdNz+//giZZucR/OWu0lsyTJv2DBHSoR3lfg=; b=J8YyDLbL3F3wWm7UL5vmnth/P2d0Md3x+dd5DCd2cnM4laYk92Rm85a9IsNZ5fl38H /hBzE6LP6LNxK2OcJOr+QOVJOhsAkVIRnfoStBCauBL9XZObHcG6OE/7hZYTXj8HLv2p mpzk0+TH9UXPfMZ7nsSkNUhItqwsEXH6230zm6Y1IpH0yvtr5d/gNR9pWhRGXGTLsqeK /E6kuNYXYKLzjHUdsq+TBuxYWJPRXw9zWY5HawfLB6AXcOhg12vzIQi8lEOatGDGz1O7 WHZDKh9KTA+5ihIAoKWQVKoIupr7A726wp0z2Sse4BZ9hSPKMbaBQKbOmE2OLgCxXmjc sinw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697010550; x=1697615350; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YFdj5CLJdNz+//giZZucR/OWu0lsyTJv2DBHSoR3lfg=; b=hxHp9fBMjDU5QmiTzCo4gIQOD2R94kJZoa7qAyjBoGpIN/dDHoE2UJtRcCnN9UzrBZ FPbY70iXG6asHO8rwbkU+EKFr5MF1yk8nCndmO0zvvDyJsic9bLUOJ91/18IAEm6AitA 2qkM2CrGe7ugWZUrucwrscSj7JZtu4pl9Mj0eYN+9dnsC75inTCZj52q3JRSc6zZpzbv aQNXNjgUOaiHcjSlNQ0BmngWTIU2MDO+s8WEPPAFZT3hAqzHAMZipolXV9Z/Ub1JxFDM E8DF8nmg6xS5hDx6aHUARe7/8G5Cv8Yn5jBn488sZdq+0i+vShAkW/IEz2pN7Gq8qO1p m/lA== X-Gm-Message-State: AOJu0Yyb/9LSGB+95K/Apq7Rkz4+IBTrNS9dPcjysfwRQCzajoz6WhPz QZ2GgzLcfb/qJkWELf4E15SHNQ== X-Received: by 2002:a17:902:c40c:b0:1c8:90bf:4234 with SMTP id k12-20020a170902c40c00b001c890bf4234mr18546713plk.61.1697010550331; Wed, 11 Oct 2023 00:49:10 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([203.208.189.8]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001a98f844e60sm13193921plf.263.2023.10.11.00.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:49:09 -0700 (PDT) From: Albert Huang To: Karsten Graul , Wenjia Zhang , Jan Karcher , Tony Lu , Wen Gu Cc: Albert Huang , "D. Wythe" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net] net/smc: fix smc clc failed issue when netdevice not in init_net Date: Wed, 11 Oct 2023 15:48:51 +0800 Message-Id: <20231011074851.95280-1-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Wed, 11 Oct 2023 00:49:33 -0700 (PDT) X-Spam-Level: ** 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. 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.20.1