From patchwork Tue Sep 3 10:16:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13788453 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 29E9645003; Tue, 3 Sep 2024 10:17:01 +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=1725358622; cv=none; b=FXFZhejOOuOsSlHc8K6KzazmIReXCk9hi7oBQADHMvTb1TchSnu2NRqQryGGYgM/SoRNb6Z67de9RMcdKIXDJtnkUddojwPN4w5e/AZpbpOQBuAzmGfD1T7IT3BrhmG3BiJ1YEZcWupcGRvode/UUplS79arQNyl6lF4NCqR0/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725358622; c=relaxed/simple; bh=uYK0205hKRLrPQ+eEBOmJLuw3pivN/IYQljGnJA4NVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MLEYEhNhC4QxiFtuPbQ9lI2g8bKA93q1WnwKlTCGga14a1m0ZTl0vkmaZrEnogeDNx87v6qaXY7L5edwtgiFNrvFF9PhMZ68RwsryPD84FP8m591jOtWFN7LspfYO3rA0Nkn7XENI1lUZiKDQv/Eh/tBWrRFDzY+4mcfBk5D92s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=spedT5mw; 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="spedT5mw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AE7CC4CEC4; Tue, 3 Sep 2024 10:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725358621; bh=uYK0205hKRLrPQ+eEBOmJLuw3pivN/IYQljGnJA4NVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spedT5mwXG+Ftq5wFjuz8bUbIHNrzc5pU2el8oEegHPOQ7lde32cNFxhAfCq6ELqM fV6s2upepzh9uttSALjVOnN9s1bKkDa2IsWSWyWLpmu8XSCvYoIxskOjClithwxDtE LkHulEJdMdQbGCCu2fauAKOHY6JTWu2feoT5AE2axhsamfXa2uRvzvR4UCZ0ymcxGy FFAdn4wKe1TxSzg4XwDpnImmx3iN2hhRL7Vn/em44r0qvv2w9pnXldFHwGxF/oSMjU 7UIpEb+22wGll4wM2iW82BZJj/BbOrKk8rJkeYW4oyaK9/WghqdG3KT1Cy+Fn0EWJJ piJfAkTkevvKQ== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Geliang Tang , Matthieu Baerts , "David S . Miller" Subject: [PATCH 6.6.y 1/2] mptcp: make pm_remove_addrs_and_subflows static Date: Tue, 3 Sep 2024 12:16:56 +0200 Message-ID: <20240903101654.3376356-5-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <2024083044-banked-tapered-91df@gregkh> References: <2024083044-banked-tapered-91df@gregkh> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2063; i=matttbe@kernel.org; h=from:subject; bh=PUHHivcwFVptFcvNWpuHApfb3OeOiYvxwfM9LG/7xL0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBm1uIWsDZObPTsdiTMDTRB08f5oAhIRGPXHK1z5 WVAW0LH/RCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZtbiFgAKCRD2t4JPQmmg cw6FD/9swIC+SbgigHTuUI88RGEbOphUUBu1UjDdzv3RhNLO5Ga6A1fKUUZ7IHBB4A5oNWmEXfH 1dl2KJ/ki5hjuH2lC9d+Q1t26DOQVUYEYlwocAFO2yv+UDdhxm8WYfcyjV5+UEK+m2MCo2fLNfZ qlM/ZtmQ18bx1LIeEvlUmah9u9HqxGZCUCDuLCqwB/N/YQgtrLtYs12bbGRvM4VANzP+X09P8tR imEWhUEtiOPuNFL0Y+qDLULntSoyDarfq66+p2po3fXEyi8ALTS+aXW5uupIp5C05yCrcQLhl+v aG0hXNJr0ewpuMg8iUt1lB1ykL68odaJ4IyCmveRaBfEHdUbS2Ga41XZiqnZGGdeCy92px9d18a jCb+AwbRJGnp1qbet8s/tHSND+U69EW7edGe0nV5SHidt1w52jwYk9ipo4v0rqKr0q2v0PQ1QdM G9vpuyl3s5JUxn7alS182I9p0wDnpnZco8lSqs0Q4KRLxXKuoWLrsM1daHZv3Fw2ZJw4hlH28CQ uRB5Gn6691zNnwBvtcatdgZUCBYmeNFOaNOgxfzoZnQqTASOA1d1Z0pS17ibHd3mAmUfCJdo8VE tiB/8wsAGHr/eZfalEtLJir3uusoCIu0cCDIH7gftu+P9gSqA5Z0o1wF3/FR7d7Kd/yzUaHOLt3 Xbn04UFF+oKLy3w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang commit e38b117d7f3b4a5d810f6d0069ad0f643e503796 upstream. mptcp_pm_remove_addrs_and_subflows() is only used in pm_netlink.c, it's no longer used in pm_userspace.c any more since the commit 8b1c94da1e48 ("mptcp: only send RM_ADDR in nl_cmd_remove"). So this patch changes it to a static function. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: David S. Miller Stable-dep-of: 87b5896f3f78 ("mptcp: pm: fix RM_ADDR ID for the initial subflow") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/protocol.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index aff41beb4dab..fa4668c2d6b3 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1701,8 +1701,8 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) } } -void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, - struct list_head *rm_list) +static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, + struct list_head *rm_list) { struct mptcp_rm_list alist = { .nr = 0 }, slist = { .nr = 0 }; struct mptcp_pm_addr_entry *entry; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8996cd6b6820..ecbea95970f6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -948,8 +948,6 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, bool echo); int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); -void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, - struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info); From patchwork Tue Sep 3 10:16:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13788454 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 0BB4F1A0BC7; Tue, 3 Sep 2024 10:17:03 +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=1725358624; cv=none; b=SysCTAMRDlKSjLeryIn4JXRDxoaDfsiIHIdCW7yi4twaZUezKqdUedCYIZDCZ1nQ4/MF2jR3oKylpV70wxN5ey5J3jH0r/P1s15F4s61lqG3JMugUj8v/VfdALLHOEhEjgNYbMUytCFD8CJFgOslrRn/gKn973FdRXlWiUWtiVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725358624; c=relaxed/simple; bh=TQiqazGLhtHKKUgi3NC65E/YTtGJeb3NUVBYQtIyOH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wym3lUjl/j0FjtydG3Zq+jPaF/doT7cIexUpx1lH1dALpxkjahaKuOXu4F271qdzG+uh/dW1i3YpPn8/OAQkVOsDLJvAMSX8yUdbqCeMDCIx18aoTuWEsqYCcexU8rUULtG9D4aMcViiXainIIzFcTScHtusicbHbCMFgJCFPoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T+yR/a/d; 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="T+yR/a/d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EBB9C4CEC8; Tue, 3 Sep 2024 10:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725358623; bh=TQiqazGLhtHKKUgi3NC65E/YTtGJeb3NUVBYQtIyOH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T+yR/a/dND88b44EHBN8Dt35TgEBHMZ0FXViHnCBc6EZEulUmu8yTMclsJvqUd13X 3eOJJv08MdVtHvP9LeZD+DglrUQCG1PTIuG26NsmOV5/t5LV7OUiAGSTzUnotscEmX Sl3aPoBNwY3BDaOX7mqZJsWdf5+X2e1xijcBXZLqNCUrc0N95ZbuBdwgId/vWbzo2Y kIlAk6gp/T0/aBFGxDWIUq/8rKT8AwTcscOhdXTIyF7NQru97874pjzD5F4S1XOMDr RHCeXPpgG/eRUoWHbkEyOOQUpKJu7QRSO8PhZ3Dgr+9a2V17H8ut/0wb4K9vOiSI5z l1CuBI3REw0uA== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni Subject: [PATCH 6.6.y 2/2] mptcp: pm: fix RM_ADDR ID for the initial subflow Date: Tue, 3 Sep 2024 12:16:57 +0200 Message-ID: <20240903101654.3376356-6-matttbe@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <2024083044-banked-tapered-91df@gregkh> References: <2024083044-banked-tapered-91df@gregkh> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5228; i=matttbe@kernel.org; h=from:subject; bh=TQiqazGLhtHKKUgi3NC65E/YTtGJeb3NUVBYQtIyOH4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBm1uIW5RlkwCIBaahV90++gp1nT2pzCG1XazOPS e6QGdrHmr+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZtbiFgAKCRD2t4JPQmmg c/VgD/0bg0IhETuJzKNSd6qZUoJyH7zdFu0xU2ChLDiYPu726RSUNEbtgk5cpZQXX6Hs7pE0QLM 4nxxMu1qg1qqXbZg3OXGKkTltE2M0EbobYIRY4ol/AygYtTcC55qAfKWkqMpgrXgokucM/wSuV8 fLXRJw6HGhlCYreNQHjV3R8ke6Twv+ZEA9CtaP7+PeuBHFlIDlD9atYixgyRvcpYl04SiafrP2r Ss6n0+y7Ey/LG10LytpEHndc2mavZ2RvcTdQb3Gwt4Q6pcr42kjUsivPFxTyBM3pAvjevURBMUP I7lDVNN5Hyt1Y+A0+owP3lz5UxCMVdxp/ICYOyCq6uqRdlNoRRC53G//znGs19Q1juwFwWzVfKt 7AlzQbN8CbbPLf8sORini33qNYg5YQRc2kEFUifq9/3sEu5Leb+drTZQlrKDXfqi528Lxj6flsV lnI0Pr/PxgOJq6y5pwXzSH0GclTdnav+9AxQK6+/caNGsRwXhSKA4yBU6rxPAQmx4g1hVT2Wyx+ M6KrHjqw/tujtyv0Zy26GvE6p53rCL+jN6zjJBVfODu42wPqO/ggYZ1JOh+kbHDfxeNSAcUrB4I Kv+a04TBT2XIHXHCgL5w/oZ+yBrJ3A2YCg3b+W3T8bXwDH1GuhkFvr+AIUWCTH0FBG3EKjghoX4 ACq/WOpCoiYQJHQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 commit 87b5896f3f7848130095656739b05881904e2697 upstream. 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) Signed-off-by: Paolo Abeni 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 fa4668c2d6b3..d5902e7f47a7 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -826,11 +826,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) @@ -867,7 +862,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, continue; 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", @@ -1506,6 +1501,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) @@ -1513,7 +1514,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) { @@ -1540,14 +1541,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; @@ -1565,6 +1564,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); @@ -1673,6 +1673,7 @@ static int mptcp_nl_cmd_del_addr(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 }; @@ -1701,6 +1702,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) { @@ -1710,11 +1712,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); @@ -2002,7 +2004,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);