Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1102179lqt; Fri, 7 Jun 2024 08:05:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbps2JCtSImav4miKiEBvTEF+FUoSzO/ybX1DHBBJeKgevAYWt3spNxmb1WIagfXpYbCTXSRANbA7wFyBuUKWWNTH+bOxeQjjEu89XXQ== X-Google-Smtp-Source: AGHT+IHIFGxL5YhhnUNbTx0+UXtzLeRH+4n8q+77dIZiwBzgcl+4aL3Xti8gbxFrQSFcVz53Z+Bi X-Received: by 2002:a17:906:e9b:b0:a6e:f997:7d91 with SMTP id a640c23a62f3a-a6ef9978049mr2509166b.38.1717772717262; Fri, 07 Jun 2024 08:05:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717772717; cv=pass; d=google.com; s=arc-20160816; b=bqGtjoMFF8KlbflREv0EDw345meEJCTLA3cG8uf6INx6DP7iPA3pRASF7D3oZ9i4jf 4RuUwF5/SjGVR+Ep1YIZlHv6/STo0oMDcWmIMJX2tysx/DAO0liXMablUp2Wz3ZVJHWg 0kdCpM4/nRPG4BfAAO88MMnRjUnEm7XvJX0HoGnf7h7Z1Nfxx3h45FzYO8HX/4fTIchy ST6YzudJPy8RXp5ojn1pv6xVDpjHGbFBvYa5nMoVskipESaG2MrZ2ZT//K4QNhhhybqG o+QgVMF/lByQtO1t5TwDPX0aj9zwn/vRT/jKvkuvjIHJSItSmAvWU2B4sB89Xb9DRwRw SzhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=IokdtEFlvxBj8hdm7aZx30yKG/M88cB7tCYC6yiQ3LA=; fh=/RhOCwuF+ItzV9blT90vsxTPZbxcY1KYBlBZ2mXhCFM=; b=p4l6mvd059Igf3Ht5XGuN0Jl1i80xp4zDoTd22cqjpRB/aAPmXnyP3siNpgOasnv4J 3LJ5NTSUOHA1GEzfAxBcnE6Gj9as6k+EEjFAdmINL0QGZg+RD51Bl8y3L7W3KzUglSQv i5S+44K5tkN2kQe2yeo1bVk8wR+g5ewvr+PVESePh11kS/T1mFw1BBHREl5REmoPSI0Q c8Uqh6OJ1Z8HPV4FtvHWDjO4tfroZmjbdG77RuMD+LjimvTSICPHr8KqiihP9IPx1XGN hCTTj0FH4DiTnCUFyg9bPyQlgkSPh46eQGT4+19G/dTARgUG/7Ff98kBbqZ80SlUfot2 rX+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sg1kMVgT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c807280dfsi197598566b.795.2024.06.07.08.05.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 08:05:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sg1kMVgT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C99D91F23B25 for ; Fri, 7 Jun 2024 15:05:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83D8C19AD4B; Fri, 7 Jun 2024 15:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sg1kMVgT" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83E7319AA65; Fri, 7 Jun 2024 15:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717772544; cv=none; b=QKH3XaEdlinZ+HBAjgL/Dj7blRvTOD3leoHEqsCm+g6mZ4TAbbTyYNsZP8/2A/VHGMPCzKnm5q6dLZPCAN/N71N7myr6GSSh+QM8FEfrDL3j3W6uWagOGVLhypuwWf+MhO6ddxtW+v14DZZ3y1KSiGoJxxuOkCAUpRZlGspDTIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717772544; c=relaxed/simple; bh=8tlUhkdVvZTcWOukF/NW3k0yzLel5AlJwpWFwZu6gzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jgy/jPUqDg9uNSPovp0BtX35M333hHo45z018cSuhwvyUDWl0cDEcis1e2+llWh5vRWB3yS6XFiPN6efoWU2S+QZVl0qFX1k7+67RZJrhmBfUKf3dK/+RqaqHcXcljNxKjgCXOwkTwnwEhBLTP8C5oKXC4Sh2hZ/FdYLNuqqz2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sg1kMVgT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 369F9C3277B; Fri, 7 Jun 2024 15:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717772544; bh=8tlUhkdVvZTcWOukF/NW3k0yzLel5AlJwpWFwZu6gzs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Sg1kMVgTwMXjYpwi5mRNtHmrDYrZLnxgCB4A8KTAtmshKpTodpOy+YecwmEFQ7/jZ HX2UjoaeOZEpryiYjTneK/c0hu5CHZHa8wcic3qWGbLkDuyq90njh7Ui8PN7rVjfpb q26PBwXPQkX2eYPPfT5JcTKXMCPGkubfF1p0/ikBRKB1Mjc72QorxxhF2vCXPi3RZ+ SqzNRg21AqLshBNnxXxzcg7/N2NaoNti+W/fHBlkvUISkfc888kBq+l6IqAweNisgi ulwMgZ3UAPTuy4cPjhTI7vA7RGwXl9LWg1ZhLGBukY/DD6Qd1fKeeUntAQkCBHYJqo BRO0BfRfgxQ+Q== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 17:01:50 +0200 Subject: [PATCH net 3/4] mptcp: pm: update add_addr counters after connect Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240607-upstream-net-20240607-misc-fixes-v1-3-1ab9ddfa3d00@kernel.org> References: <20240607-upstream-net-20240607-misc-fixes-v1-0-1ab9ddfa3d00@kernel.org> In-Reply-To: <20240607-upstream-net-20240607-misc-fixes-v1-0-1ab9ddfa3d00@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , YonglongLi , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3982; i=matttbe@kernel.org; h=from:subject:message-id; bh=zuXyd/+by14MmL5k443XIsgq2Iec/EOQmFET7b08UhY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYyDyeZUx4kMdg4+lvbY3f/ebVuYWN8NXlYzYu 73X2AE0OfOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmMg8gAKCRD2t4JPQmmg czDeD/0Zf0M1V9mn2bjRhdU2EBrWLIH3EHax9QERfZSsc8q8SZQS/3VLgFnqInFAlFtGkBOavV1 kawZ1CRrdmCZ2UXpS3kAFePbhHc2/b2hWUlDlQyXvnwAjDfh5/jefCXa5G53salv9t8ujbg/Jir RHK8YqF1LqMUDcAxRXPexVLh4mcUyr1TVaq3HRqoHx8Dp5GgokQ7N8QifViAEO1Ka9/4ZOu0rsE n+l7qElW5stYlyFG0OdIN8XhbC7DOT0HVsL5EmRzh+TEvgTj8nRQmLbwl0yw+dEAflwLJiCv1il d1YkfSo+P3em+YcjEDVG1S4xPKjt7FmuDYnLhaAotaRVn/eF17bQx9w7k94fI89g/262/eyczrR AV4jn2Fo4El0NoZNtOYLZL0hl+GZyu7h9MEp+JM7SQPw2RDaP0E5MOra/DSZq8ETFcZ1j0G4hYO S3YQbJFXM5BxAb3QBsvhIIlleDx8FOyqiA7wTC+M9e+GvxfIVAQjxBFKhNifgmnNAtgT17Ykfbs +nnjmoTcyhW46NnoHK8tEaNvxpF5n43e8j1vtRvZyzbOPkh1koL3gD+mEBln6h+P0EU49rJaywF aLdPGNmH8vbg5JeE0TsgS2P4JJ/Da6FFNVq/udwku6RNRwPPEWvzJkty670jjqfZSFpLON4QYQZ BUmFV/91p6DTrVw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: YonglongLi The creation of new subflows can fail for different reasons. If no subflow have been created using the received ADD_ADDR, the related counters should not be updated, otherwise they will never be decremented for events related to this ID later on. For the moment, the number of accepted ADD_ADDR is only decremented upon the reception of a related RM_ADDR, and only if the remote address ID is currently being used by at least one subflow. In other words, if no subflow can be created with the received address, the counter will not be decremented. In this case, it is then important not to increment pm.add_addr_accepted counter, and not to modify pm.accept_addr bit. Note that this patch does not modify the behaviour in case of failures later on, e.g. if the MP Join is dropped or rejected. The "remove invalid addresses" MP Join subtest has been modified to validate this case. The broadcast IP address is added before the "valid" address that will be used to successfully create a subflow, and the limit is decreased by one: without this patch, it was not possible to create the last subflow, because: - the broadcast address would have been accepted even if it was not usable: the creation of a subflow to this address results in an error, - the limit of 2 accepted ADD_ADDR would have then been reached. Fixes: 01cacb00b35c ("mptcp: add netlink-based PM") Cc: stable@vger.kernel.org Co-developed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: YonglongLi Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 16 ++++++++++------ tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 766a8409fa67..ea9e5817b9e9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -677,6 +677,7 @@ 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 sf_created = false; int i, nr; add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk); @@ -704,15 +705,18 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) if (nr == 0) return; - msk->pm.add_addr_accepted++; - if (msk->pm.add_addr_accepted >= add_addr_accept_max || - msk->pm.subflows >= subflows_max) - WRITE_ONCE(msk->pm.accept_addr, false); - spin_unlock_bh(&msk->pm.lock); for (i = 0; i < nr; i++) - __mptcp_subflow_connect(sk, &addrs[i], &remote); + if (__mptcp_subflow_connect(sk, &addrs[i], &remote) == 0) + sf_created = true; spin_lock_bh(&msk->pm.lock); + + if (sf_created) { + msk->pm.add_addr_accepted++; + if (msk->pm.add_addr_accepted >= add_addr_accept_max || + msk->pm.subflows >= subflows_max) + WRITE_ONCE(msk->pm.accept_addr, false); + } } void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index aea314d140c9..108aeeb84ef1 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2249,10 +2249,10 @@ remove_tests() if reset "remove invalid addresses"; then pm_nl_set_limits $ns1 3 3 pm_nl_add_endpoint $ns1 10.0.12.1 flags signal - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal # broadcast IP: no packet for this address will be received on ns1 pm_nl_add_endpoint $ns1 224.0.0.1 flags signal - pm_nl_set_limits $ns2 3 3 + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal + pm_nl_set_limits $ns2 2 2 addr_nr_ns1=-3 speed=10 \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 1 -- 2.43.0