Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2353141rdh; Tue, 26 Sep 2023 23:05:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4uggxu9KHbD08PwQdSOEUVMNieUMA17dpHz1N2FZCgY/wGc6Mw9tTyqVdYQK0mDVDxCIM X-Received: by 2002:a17:902:eb4c:b0:1c6:25c2:e78e with SMTP id i12-20020a170902eb4c00b001c625c2e78emr752799pli.24.1695794739265; Tue, 26 Sep 2023 23:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695794739; cv=none; d=google.com; s=arc-20160816; b=jkws0Bak+lrDelxKdsXodXCe3ZN8Hi3J4FoNCr+Oz5QhIZPPST8BN9oDgyGqAmbcmS rATW8/lh1Epa6LTXuBpdDd2U5wFEX2a/bDzGHAJ2LzXJ6sGVxtCJgF3fhVRfxXUpg3R8 li7yn9vU8CQr9jug9bTb7xCdHCVhDyWpn+qNUvo3Fed1Oq1JNA5XNHUjH9AqEQgD62zP PehvzX/arjQQ16OigscfGv3n+rQq5Un1g0lVEWSkqGARk+iDgHjlnsO6fbugd6nSX6ql 0jsynTgW2LIX7IqXmAkpa0FZHc/LhYADWwfVERKdL9eWEakleOv7gyt99NgrjiGcqPh5 Btcw== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=Zbcktj2CdlUqyNttmPQPeu6MitHPtRswR0uZVgqClmM=; fh=A7s6njOz+q1jtrshiGkU+9okImFJLMrXLg6+yDMhNjM=; b=o2h315QrmBpTFaO4qlINBHsuoXD2eeXIcnYLjTCKPH+iFkRDfNGCIK+MGmwxG0p15H r/++LEOQBsjZiTQ0YrmSJARCowDB1wVtxTlN/0Mc/p1HcRWx4nTJEzMfBEtN+if0HCs3 TGmoVv3FyhDKWN6oiGKyC72XogyLmU7opVeMShm/J39mwSSS+k8Y7C4Swy/RMfiYHLZQ V1CJHMW36o9jOtLMNEATdBwRP/gQgvJoNG5cunXbXy5C4Pp/SA3O2e8OdAecLR2CODOf y/mL7o7Wb++Ftl77U9InDyzTndWeKLyqLGJ9xtI7igxAb+jqxxjlvauYCJO+ZD2YBH9g m/Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J90fN2w5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kv11-20020a17090328cb00b001c3cbccf116si13953850plb.403.2023.09.26.23.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J90fN2w5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 91321804ACD9; Tue, 26 Sep 2023 22:56:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjI0F4S (ORCPT + 99 others); Wed, 27 Sep 2023 01:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjI0Fzh (ORCPT ); Wed, 27 Sep 2023 01:55:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D968CDE; Tue, 26 Sep 2023 22:55:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 450A0C433C7; Wed, 27 Sep 2023 05:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695794133; bh=PS/DrRUCszB6uX0dXeIxFFme7S+AAfTHo23ufuCd1jw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J90fN2w540AAQBs38jLZ5lBDyABNI1rj8qR5gszHVNYgU5InzUoC1G5VLNc8FufX6 ObZcBvqFgj6ikAvMWz9WpHQIhX90bMXqN+/xa+viDiXwFbTGGKXSmBEIA7Lf+qXc5/ xX9yOJEouAvfOhjMrSGENSm6+0yXtsbu/oogahuMYgncpQNoaWz4CQWDMIOiR76J5P JXpaq0an4ii9XHBBVf0QfZJMYtvPqy+00flqfV+Y0fcmQ+vvwiKYXUlegz1D3YzwLt 2PqGOHz6TpqaG8EcB8rcZTLEwfdCJtKHe2z4OmsZLfHhYk4tdJiG58tIzwMTCEsomG hheFD2E2IHZDg== Date: Wed, 27 Sep 2023 08:55:28 +0300 From: Leon Romanovsky To: Dust Li Cc: Albert Huang , Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , 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-next] net/smc: add support for netdevice in containers. Message-ID: <20230927055528.GP1642130@unreal> References: <20230925023546.9964-1-huangjie.albert@bytedance.com> <20230927034209.GE92403@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230927034209.GE92403@linux.alibaba.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 22:56:39 -0700 (PDT) On Wed, Sep 27, 2023 at 11:42:09AM +0800, Dust Li wrote: > On Mon, Sep 25, 2023 at 10:35:45AM +0800, Albert Huang wrote: > >If the netdevice is within a container and communicates externally > >through network technologies like VXLAN, we won't be able to find > >routing information in the init_net namespace. To address this issue, > > Thanks for your founding ! > > I think this is a more generic problem, but not just related to VXLAN ? > If we use SMC-R v2 and the netdevice is in a net namespace which is not > init_net, we should always fail, right ? If so, I'd prefer this to be a bugfix. BTW, does this patch take into account net namespace of ib_device? Thanks > > Best regards, > Dust > > >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. > > > >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) >