From patchwork Wed Oct 25 23:37:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 13436964 X-Patchwork-Delegate: kuba@kernel.org 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 52A60381AD; Wed, 25 Oct 2023 23:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i26CsGYC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA49EC433B9; Wed, 25 Oct 2023 23:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698277032; bh=GyNOg92sM3p0ShPkfaGKDtFNcD8NFmdnpi3MEJceRfk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=i26CsGYCgYdBKFtgsah5O2+wzT/iEI/7yNx9bC1bXOTLlEHi3xsQ2QErM28QtOsx1 SFiMhissGcWr1b5NNTlbLel7kvxXIsJttmD5dkZoRaykTtNV0Imwl5wBJey5WEZ0AO B0VfGHaWj0FRcg0HxQr8rYG+5ou/knGgtDy7xzfELIPy7YRSfa0AM57Ud5xqxq3uqT kWSo9A8TE6TOGNkedqJkjmXUIl0e9Q88WKHEP672Tg+XWWTfsyUa7yb+H0S5qwdBx2 XTvbrmRIsUNF+R1gEctEI3jfhAWeWgZM9/Y2xbsyK6X2g3Yx85L28NEB+65/dk3bCk opar4hKmoirFQ== From: Mat Martineau Date: Wed, 25 Oct 2023 16:37:04 -0700 Subject: [PATCH net-next 03/10] mptcp: userspace pm send RM_ADDR for ID 0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231025-send-net-next-20231025-v1-3-db8f25f798eb@kernel.org> References: <20231025-send-net-next-20231025-v1-0-db8f25f798eb@kernel.org> In-Reply-To: <20231025-send-net-next-20231025-v1-0-db8f25f798eb@kernel.org> To: Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geliang Tang , Kishen Maloor Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, Mat Martineau , stable@vger.kernel.org X-Mailer: b4 0.12.4 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch adds the ability to send RM_ADDR for local ID 0. Check whether id 0 address is removed, if not, put id 0 into a removing list, pass it to mptcp_pm_remove_addr() to remove id 0 address. There is no reason not to allow the userspace to remove the initial address (ID 0). This special case was not taken into account not letting the userspace to delete all addresses as announced. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/379 Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE") Cc: stable@vger.kernel.org Reviewed-by: Matthieu Baerts Signed-off-by: Geliang Tang Signed-off-by: Mat Martineau --- net/mptcp/pm_userspace.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 0f92e5b13a8a..25fa37ac3620 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -208,6 +208,40 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) return err; } +static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk, + struct genl_info *info) +{ + struct mptcp_rm_list list = { .nr = 0 }; + struct mptcp_subflow_context *subflow; + struct sock *sk = (struct sock *)msk; + bool has_id_0 = false; + int err = -EINVAL; + + lock_sock(sk); + mptcp_for_each_subflow(msk, subflow) { + if (subflow->local_id == 0) { + has_id_0 = true; + break; + } + } + if (!has_id_0) { + GENL_SET_ERR_MSG(info, "address with id 0 not found"); + goto remove_err; + } + + list.ids[list.nr++] = 0; + + spin_lock_bh(&msk->pm.lock); + mptcp_pm_remove_addr(msk, &list); + spin_unlock_bh(&msk->pm.lock); + + err = 0; + +remove_err: + release_sock(sk); + return err; +} + int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; @@ -239,6 +273,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) goto remove_err; } + if (id_val == 0) { + err = mptcp_userspace_pm_remove_id_zero_address(msk, info); + goto remove_err; + } + lock_sock((struct sock *)msk); list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {