From patchwork Wed Aug 28 06:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13780705 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 131031553BB; Wed, 28 Aug 2024 06:14:42 +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=1724825683; cv=none; b=bSL7E8IZjWy+XyzFBPWwJ9IW4TlDG/c1eJJsnqBL5QzqSNvIMFb+J5+8hMf94j2SJbstR0gCnbEfokL6MjzK5nXyqr65P6wdODaYHGc3m5DP2vZiTSTXM9jDbYSy5LnQutItf7IkZoS5Us+LGT0l7iedCToRt4hWkdErV0JYmzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724825683; c=relaxed/simple; bh=53z/tJGrwfftOJtkqVESOfZkmshP3WMv+7Y1+hRdczM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=utDLzZf7LCLfKamd66eD9nVLgHg+jJd4zepGfu5v1UaUKmFfgmlPU9VO+gWr00XLN4RT2vd64R7I4jP9Rs5HvX4qEw/lMsXa2fiYGDrAPl01tCzRR7HZ12KIFyRU8Ogf/LWdIFLuCzw9WihQMPyT/8Wkcz1wygRFgItrgdxj1UA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L3XKHtD1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L3XKHtD1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8F8BC4AF0E; Wed, 28 Aug 2024 06:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724825682; bh=53z/tJGrwfftOJtkqVESOfZkmshP3WMv+7Y1+hRdczM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L3XKHtD1wI1UkNygSSE3d6pBxBnxNnxNW+Q8BuPXyFC+Wx9z/McaKV/TodYKIX7q+ 1Bj8bYbQb1ZcwDSzw/s1AojpBuintXCgEM8BliFoTv44L2pwVDGx76HREcp0LPp4wR oGjKo0x6lJjmjxgf+N5pgGcsgLLyc8MlQTS+zN4sZZ/NdgH4EFPWRNncV7zxhpOglw s9WJgk3SOSVrEMQR/XrCh8GTCkPn7o/4UC3p3FqO5uuH9DTYtVBOEsmOWMmnUIWKvv v1DS3YXDMaIXruLTymyduEI8j8VhZm646JvtXoy/fGaMRYw+AE7kZcHYTtooMz/nuX ejzw7XO2KnhIQ== From: "Matthieu Baerts (NGI0)" Date: Wed, 28 Aug 2024 08:14:25 +0200 Subject: [PATCH net v2 02/15] mptcp: pm: fix RM_ADDR ID for the initial subflow Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240828-net-mptcp-more-pm-fix-v2-2-7f11b283fff7@kernel.org> References: <20240828-net-mptcp-more-pm-fix-v2-0-7f11b283fff7@kernel.org> In-Reply-To: <20240828-net-mptcp-more-pm-fix-v2-0-7f11b283fff7@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5045; i=matttbe@kernel.org; h=from:subject:message-id; bh=53z/tJGrwfftOJtkqVESOfZkmshP3WMv+7Y1+hRdczM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmzsBHmdvAGSl3tvubQFCC/3AuHXncIRBBgLPy4 1fkIG4UzlCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZs7ARwAKCRD2t4JPQmmg c/S1D/9VGsN9FmWlrzGQC3v/mdf7v9euPJxP3T6V+dI2WTDhqDpY5ir7ms6imuiOh37ObvXwaXf BaQJLWvnNaH1i0mRxkbPe5xl5YWYt6f/lCqdn5QaX3g/zuH68uOqV1A6idgak63p+OF9rh75gxI Kh/erl7VO83yRklNJfK6ydT0wiNd5cXoyMwCjgUEnFmdTPsYbgCddzXHSkQlKMdSMQh1jCfnseh pzjLiO1o7TQ+tlDns+10Tefh3wS9Zp9+Kg/xjKW/neYIyQIXf2LQXkCv3FConKcLuNIvs/tr6wm aI22iMrKKqAp0Q4PnAhOCRP3IVMB4PFW+Q2zDWc7DFFvvlisrNz/DVrutOERubZxd+7fdiawUjd 0nVqx3CxiTEYCaknfxLmGSnoSp+70mr7M07c3YXWgvXM+q53G2cCMwTiOFcpixdUo7x//oKcjmW jFeK/MXuK+5SW9I6td5Yrbjs5hzYUIiZixGnC/sDwtrjgk8NPiLxz+twTCXYhxG4Txb8cypjSM+ /Y6UxvlM83dMtKRvsAtrLLo8p+94p9IlbLbiXyYO5M7h7uXyvXm48C2A/6jcVFll7DEHuL4YHZS 4n9MoF0udEmRIYXbX5nyBI2sC4nF2x6zLL0x1muZP41Oxz86XWKAzi1mX5pH+lTE0irkghxXeyF zoCu00NEq8dsWyw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The initial subflow has a special local ID: 0. When an endpoint is being deleted, it is then important to check if its address is not linked to the initial subflow to send the right ID. If there was an endpoint linked to the initial subflow, msk's mpc_endpoint_id field will be set. We can then use this info when an endpoint is being removed to see if it is linked to the initial subflow. So now, the correct IDs are passed to mptcp_pm_nl_rm_addr_or_subflow(), it is no longer needed to use mptcp_local_id_match(). Fixes: 3ad14f54bd74 ("mptcp: more accurate MPC endpoint tracking") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ec45ab4c66ab..42d4e7b5f65d 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -800,11 +800,6 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, return -EINVAL; } -static bool mptcp_local_id_match(const struct mptcp_sock *msk, u8 local_id, u8 id) -{ - return local_id == id || (!local_id && msk->mpc_endpoint_id == id); -} - static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list, enum linux_mptcp_mib_field rm_type) @@ -839,7 +834,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMADDR && remote_id != rm_id) continue; - if (rm_type == MPTCP_MIB_RMSUBFLOW && !mptcp_local_id_match(msk, id, rm_id)) + if (rm_type == MPTCP_MIB_RMSUBFLOW && id != rm_id) continue; pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u\n", @@ -1448,6 +1443,12 @@ static bool remove_anno_list_by_saddr(struct mptcp_sock *msk, return false; } +static u8 mptcp_endp_get_local_id(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr) +{ + return msk->mpc_endpoint_id == addr->id ? 0 : addr->id; +} + static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool force) @@ -1455,7 +1456,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, struct mptcp_rm_list list = { .nr = 0 }; bool ret; - list.ids[list.nr++] = addr->id; + list.ids[list.nr++] = mptcp_endp_get_local_id(msk, addr); ret = remove_anno_list_by_saddr(msk, addr); if (ret || force) { @@ -1482,14 +1483,12 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, const struct mptcp_pm_addr_entry *entry) { const struct mptcp_addr_info *addr = &entry->addr; - struct mptcp_rm_list list = { .nr = 0 }; + struct mptcp_rm_list list = { .nr = 1 }; long s_slot = 0, s_num = 0; struct mptcp_sock *msk; pr_debug("remove_id=%d\n", addr->id); - list.ids[list.nr++] = addr->id; - while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) { struct sock *sk = (struct sock *)msk; bool remove_subflow; @@ -1507,6 +1506,7 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, mptcp_pm_remove_anno_addr(msk, addr, remove_subflow && !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); + list.ids[0] = mptcp_endp_get_local_id(msk, addr); if (remove_subflow) { spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list); @@ -1613,6 +1613,7 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) return ret; } +/* Called from the userspace PM only */ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) { struct mptcp_rm_list alist = { .nr = 0 }; @@ -1641,6 +1642,7 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) } } +/* Called from the in-kernel PM only */ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, struct list_head *rm_list) { @@ -1650,11 +1652,11 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, list_for_each_entry(entry, rm_list, list) { if (slist.nr < MPTCP_RM_IDS_MAX && lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) - slist.ids[slist.nr++] = entry->addr.id; + slist.ids[slist.nr++] = mptcp_endp_get_local_id(msk, &entry->addr); if (alist.nr < MPTCP_RM_IDS_MAX && remove_anno_list_by_saddr(msk, &entry->addr)) - alist.ids[alist.nr++] = entry->addr.id; + alist.ids[alist.nr++] = mptcp_endp_get_local_id(msk, &entry->addr); } spin_lock_bh(&msk->pm.lock); @@ -1951,7 +1953,7 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, { struct mptcp_rm_list list = { .nr = 0 }; - list.ids[list.nr++] = addr->id; + list.ids[list.nr++] = mptcp_endp_get_local_id(msk, addr); spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list);