From patchwork Thu Mar 17 22:14:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12784624 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D335C433F5 for ; Thu, 17 Mar 2022 22:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbiCQWQE (ORCPT ); Thu, 17 Mar 2022 18:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiCQWQD (ORCPT ); Thu, 17 Mar 2022 18:16:03 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD55F36E29 for ; Thu, 17 Mar 2022 15:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647555286; x=1679091286; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LBH3oVPpZUWhACuFbLsRx6LPCOq5e55Un5nLgYAZFN8=; b=CuPgix/IsZWuQETBVlu6l+B+HKEVOAR/V30xqH8MxWeJSvXW8kySWWKr hKRh3BwJ6XZnbbYgWqGUeBCtnfTA8lBJJmKtb0Fu8OAT16EcOMn47eRyw 72CYoLtp7CHysJIWkWsloEpUpyV1qkCAM1axQXGD346m4ODylHMn0WQ3g uN1iDt7MJqY94RGC/IC2QdD6OnqOx4GBaNvDHhfMmwexm8hBrrQuViwnm UDdAlBIdhTW2qSMvSbyS9VVkLyAlvm4M+dLHO8nkbJ1DOn65uX3mtNvQ8 ouPSv/z1+ODf5L4vX1iyNSTKrug0OHGJsZ/hKTf0HImvu1WH/KMneesjB A==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="244449382" X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="244449382" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 15:14:46 -0700 X-IronPort-AV: E=Sophos;i="5.90,190,1643702400"; d="scan'208";a="499002728" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.251.9.212]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 15:14:46 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Yonglong Li , davem@davemloft.net, kuba@kernel.org, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Paolo Abeni , Mat Martineau Subject: [PATCH net-next] mptcp: send ADD_ADDR echo before create subflows Date: Thu, 17 Mar 2022 15:14:44 -0700 Message-Id: <20220317221444.426335-1-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yonglong Li In some corner cases, the peer handing an incoming ADD_ADDR option, can receive a retransmitted ADD_ADDR for the same address before the subflow creation completes. We can avoid the above issue by generating and sending the ADD_ADDR echo before starting the MPJ subflow connection. This slightly changes the behaviour of the packetdrill tests as the ADD_ADDR echo packet is sent earlier. Acked-by: Paolo Abeni Signed-off-by: Yonglong Li Signed-off-by: Mat Martineau --- net/mptcp/pm_netlink.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) base-commit: 1abea24af42c35c6eb537e4402836e2cde2a5b13 diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 800515fe5e1d..b5e8de6f7507 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -650,7 +650,6 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) unsigned int add_addr_accept_max; struct mptcp_addr_info remote; unsigned int subflows_max; - bool reset_port = false; int i, nr; add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk); @@ -661,14 +660,15 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) msk->pm.remote.family); remote = msk->pm.remote; + mptcp_pm_announce_addr(msk, &remote, true); + mptcp_pm_nl_addr_send_ack(msk); + if (lookup_subflow_by_daddr(&msk->conn_list, &remote)) - goto add_addr_echo; + return; /* pick id 0 port, if none is provided the remote address */ - if (!remote.port) { - reset_port = true; + if (!remote.port) remote.port = sk->sk_dport; - } /* connect to the specified remote address, using whatever * local address the routing configuration will pick. @@ -684,14 +684,6 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) for (i = 0; i < nr; i++) __mptcp_subflow_connect(sk, &addrs[i], &remote); spin_lock_bh(&msk->pm.lock); - - /* be sure to echo exactly the received address */ - if (reset_port) - remote.port = 0; - -add_addr_echo: - mptcp_pm_announce_addr(msk, &remote, true); - mptcp_pm_nl_addr_send_ack(msk); } void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk)