From patchwork Fri Jan 17 09:34:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13943064 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 6893B1F9409 for ; Fri, 17 Jan 2025 09:34:36 +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=1737106476; cv=none; b=bl9am70zxjWEVmDfd2vPh9SOMkQXTD3UsSDLW+r0BKlsl/+xr3iLffKyTcZjNMzkhaobVFu+BZv89k0yDPuLyO384N/4BBINWJTRIk6fDTMJC77ejl4GmBJetFnHUH+QtagIgUwHdEdyMmAOjY5TzfERCUo7pbsWIaeixeOcjH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737106476; c=relaxed/simple; bh=FgctcrCBsuMWkQbr/BczzCPD0YcgP+TPlkYUAi597mI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HKJJn0kXuPV4nbAeS/ZCE5EtoXQIVUgDFxRcynM1tK98aBz4Chmgf5cATjDFtaKd+2uwLqpsg/xGpgkUz6CK7D/bbqXyakw9NOH4+mZSVQV9s0W0vt4yXKzgRsR/rE211i374fZBy3wR9eAoflILF/VghzTjwY8QBoi0sR2+p2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J/uiSaWO; 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="J/uiSaWO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46649C4CEDF; Fri, 17 Jan 2025 09:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737106476; bh=FgctcrCBsuMWkQbr/BczzCPD0YcgP+TPlkYUAi597mI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=J/uiSaWOSLsUQ1WCoUudzYE+yTpctSqxGH0Qfiv3CkaHk0WAV5Fl3lgRMwY5y/yyf puD4StqV5GomYJIhPwrv40BG+gSovOP8jQQoSvTa6nQVWvoFmuKvW8AnsNMwuqk8w1 hNhksjR+Y3g0bul92FZAehv0zBAdtVJAv2/CiyzKh+FmGXpRgs2fSd5VIfebpEN9cm jysBBbUDMk1+9fY4yt2D8TylEqohHYc40Poh1fBpoY54RxQ7drLUoyFGr3iEVcwfRE 5a7cNGUjRdlh26+oHliP7msYWoAsB8cK21EkB7khm1RBfUZ5LB2IKVgCEehKcukVE8 xZGRrSblOL1uw== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 10:34:13 +0100 Subject: [PATCH mptcp-net v2 1/3] mptcp: pm: only set fullmesh for subflow endp Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-mptcp-issue-540-v2-1-a194740fb380@kernel.org> References: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> In-Reply-To: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> To: mptcp@lists.linux.dev Cc: "Matthieu Baerts (NGI0)" , syzbot+cd16e79c1e45f3fe0377@syzkaller.appspotmail.com X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5605; i=matttbe@kernel.org; h=from:subject:message-id; bh=FgctcrCBsuMWkQbr/BczzCPD0YcgP+TPlkYUAi597mI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniiQo26hJ4F70cKAV5A1boDxtexkh7mynzwvhx YOv+AMl1DOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4okKAAKCRD2t4JPQmmg c5scEACIDz51+a8EYVSnD/WlJZ//YJC29eVtXLDAS5myY4Ylr1T11kGCtDzovw71/vECJvQJopW qEIb80qA23/ak6DxaiK31jrX+qQnTD9jh4oApbcJd/tPxe3KwmjcoLCRl26f4sYuOKDjI5r2esK l09L5Y86gDRFKnmGA5gJdHBwmuD6vh4kLW5h2VPXquZEWwv/mvH221+oFOtrIAFYeTlTcyB0L1K ULeNk3D0peo4/w2sYntMP9Y2YnRNVv5TA9fQzq/U4ejijZSxtce+dlRs9i3GHPDkTmb309wTGe1 6KmuvNPqUExDX80DC9rrBLI8cZJKOBYtDhvGZ443+6i4IMUpWIstWXiM+oUjhe9SKhutgq3DGXm sY3Ihd/I5MJUdu2S7MJ8GeRwfpc9f4trGAcEBwpMio3mQWU1kwUd4qrJ4P5eid9FsvBZpOTqa0+ GYjLTOBSHrE99nc2rxlK2HDfscYc2jAOw0h0w+H7kdnzoPnToZofDmydbJxEHP2IISS0TiMCesz NIEudcBfL7otiJxiN87Yu2whEMTmseIhQEVYcK+VtHP4t7XSrGB4RqcYZjvUzjoU2HWrqtC6ZB+ zFD3NVnX35RXhGZ/kNVcG7gFRk3CG/QCHsd2SHaeQXPOniRf9IfE+jyGvuBC6gM23SfHdY3slRU Hyh/h66QL6fWreQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With the in-kernel path-manager, it is possible to change the 'fullmesh' flag. The code in mptcp_pm_nl_fullmesh() expects to change it only on 'subflow' endpoints, to recreate more or less subflows using the linked address. Unfortunately, the set_flags() hook was a bit more permissive, and allowed 'implicit' endpoints to get the 'fullmesh' flag while it is not allowed before. That's what syzbot found, triggering the following warning: WARNING: CPU: 0 PID: 6499 at net/mptcp/pm_netlink.c:1496 __mark_subflow_endp_available net/mptcp/pm_netlink.c:1496 [inline] WARNING: CPU: 0 PID: 6499 at net/mptcp/pm_netlink.c:1496 mptcp_pm_nl_fullmesh net/mptcp/pm_netlink.c:1980 [inline] WARNING: CPU: 0 PID: 6499 at net/mptcp/pm_netlink.c:1496 mptcp_nl_set_flags net/mptcp/pm_netlink.c:2003 [inline] WARNING: CPU: 0 PID: 6499 at net/mptcp/pm_netlink.c:1496 mptcp_pm_nl_set_flags+0x974/0xdc0 net/mptcp/pm_netlink.c:2064 Modules linked in: CPU: 0 UID: 0 PID: 6499 Comm: syz.1.413 Not tainted 6.13.0-rc5-syzkaller-00172-gd1bf27c4e176 #0 Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 RIP: 0010:__mark_subflow_endp_available net/mptcp/pm_netlink.c:1496 [inline] RIP: 0010:mptcp_pm_nl_fullmesh net/mptcp/pm_netlink.c:1980 [inline] RIP: 0010:mptcp_nl_set_flags net/mptcp/pm_netlink.c:2003 [inline] RIP: 0010:mptcp_pm_nl_set_flags+0x974/0xdc0 net/mptcp/pm_netlink.c:2064 Code: 01 00 00 49 89 c5 e8 fb 45 e8 f5 e9 b8 fc ff ff e8 f1 45 e8 f5 4c 89 f7 be 03 00 00 00 e8 44 1d 0b f9 eb a0 e8 dd 45 e8 f5 90 <0f> 0b 90 e9 17 ff ff ff 89 d9 80 e1 07 38 c1 0f 8c c9 fc ff ff 48 RSP: 0018:ffffc9000d307240 EFLAGS: 00010293 RAX: ffffffff8bb72e03 RBX: 0000000000000000 RCX: ffff88807da88000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc9000d307430 R08: ffffffff8bb72cf0 R09: 1ffff1100b842a5e R10: dffffc0000000000 R11: ffffed100b842a5f R12: ffff88801e2e5ac0 R13: ffff88805c214800 R14: ffff88805c2152e8 R15: 1ffff1100b842a5d FS: 00005555619f6500(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020002840 CR3: 00000000247e6000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: genl_family_rcv_msg_doit net/netlink/genetlink.c:1115 [inline] genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline] genl_rcv_msg+0xb14/0xec0 net/netlink/genetlink.c:1210 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2542 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219 netlink_unicast_kernel net/netlink/af_netlink.c:1321 [inline] netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1347 netlink_sendmsg+0x8e4/0xcb0 net/netlink/af_netlink.c:1891 sock_sendmsg_nosec net/socket.c:711 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:726 ____sys_sendmsg+0x52a/0x7e0 net/socket.c:2583 ___sys_sendmsg net/socket.c:2637 [inline] __sys_sendmsg+0x269/0x350 net/socket.c:2669 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f5fe8785d29 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fff571f5558 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f5fe8975fa0 RCX: 00007f5fe8785d29 RDX: 0000000000000000 RSI: 0000000020000480 RDI: 0000000000000007 RBP: 00007f5fe8801b08 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f5fe8975fa0 R14: 00007f5fe8975fa0 R15: 00000000000011f4 Here, syzbot managed to set the 'fullmesh' flag on an 'implicit' and used -- according to 'id_avail_bitmap' -- endpoint, causing the PM to try decrement the local_addr_used counter which is only incremented for the 'subflow' endpoint. Note that 'no type' endpoints -- not 'subflow', 'signal', 'implicit' -- are fine, because their ID will not be marked as used in the 'id_avail' bitmap, and setting 'fullmesh' can help forcing the creation of subflow when receiving an ADD_ADDR. Fixes: 73c762c1f07d ("mptcp: set fullmesh flag in pm_netlink") Reported-by: syzbot+cd16e79c1e45f3fe0377@syzkaller.appspotmail.com Closes: https://lore.kernel.org/6786ac51.050a0220.216c54.00a6.GAE@google.com Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/540 Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- Notes: - v2: check the two flags in one instruction. (Paolo) --- net/mptcp/pm_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index fef01692eaed404e272359df691264f797240d10..99705a9c2238c6be96e320e8cd1d12bfa0e0e7f0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1986,7 +1986,8 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, return -EINVAL; } if ((local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && - (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { + (entry->flags & (MPTCP_PM_ADDR_FLAG_SIGNAL | + MPTCP_PM_ADDR_FLAG_IMPLICIT))) { spin_unlock_bh(&pernet->lock); NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid addr flags"); return -EINVAL; From patchwork Fri Jan 17 09:34:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13943065 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 691701F9409 for ; Fri, 17 Jan 2025 09:34:37 +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=1737106477; cv=none; b=QIaFsmvBhGjpMsgV3m3wGIg82wfCUMCqsHj335uv5RQPPiFukzcu1JLWzu1Gxs8zbFeCmhiVg8vrZFM2WOW0UMdjG1i+R/u98Tie6L59Ji0ymZ4Nsd/IbwRrFoQJERFG6KhGbTGU3/InSDVknz9nGOmBkZAB1NPf3lYZvc9iiho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737106477; c=relaxed/simple; bh=BcMcrorEXUu7i7uxqZTK+Vz4e7CI+plstckMmnXnx+g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tX9x8eFZkQUZPzeg5Z+9QvDzXkf28FL+rPwO306wRiYIWPDZ4Ea6ClF5o7CKrgMvR6CHwImRU7v39GtjZYAnpKyNP9IK98ek9Uh2NYUviuH/uPDWVaeL367ToK1MIuDg0DAk6OFc7yrnAajQkJk0feNeC5LkqUqCUEoIpEWs5Es= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UDaQae90; 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="UDaQae90" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 765B6C4CEE2; Fri, 17 Jan 2025 09:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737106477; bh=BcMcrorEXUu7i7uxqZTK+Vz4e7CI+plstckMmnXnx+g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UDaQae90LoviMhCcf+Njdy5fySj2jDPuNzkLSaPSCecoTxcb9vQuvw0eDmnQNgr4G FQ4nME262E4IZhXllS8iCl1PaNeg2e6Ev6cMLsGIedGzXJ1waZcBn4pF8egZ/BLNdh Mhxg5XbHG8Nm0iWvJsvEohCp2eK83Pv1KLhpXXCDOraXuheLObPy7X6Eq5VgFTXxzt XI/HNN7xMeiNJ0f6lXL0vG+mMUSO2kRh1AElcvkRxSM+Pm6L47D5Klg+DA49nF4NIa F5TByDCwZxn3nb76iUH4jBW5DYOU3fLxofV8eNgZisiRll2SveBm9rF07RnVpumMDc LwB5U3VytDhOA== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 10:34:14 +0100 Subject: [PATCH mptcp-net v2 2/3] mptcp: pm: remove unused ret value to set flags Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-mptcp-issue-540-v2-2-a194740fb380@kernel.org> References: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> In-Reply-To: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> To: mptcp@lists.linux.dev Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1571; i=matttbe@kernel.org; h=from:subject:message-id; bh=BcMcrorEXUu7i7uxqZTK+Vz4e7CI+plstckMmnXnx+g=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniiQocEWkhCBF5kS4yc/EWrS5bp7aDsO24nnXS 6IDWWRb/5eJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4okKAAKCRD2t4JPQmmg cwLREACs0zGcSaIK/rlJHwrwX8AZWvygfDs9Ct5P63dyZIW4HVkcgUtX0BfoOuB5ufClCLFHKwI GT2OBC4Ewsl7+A7ezcWy7ZhLbc1Y7Zzt5QCH7HZVWA0hYulRP7Q0cuZyxN1xfC2lRwmepZE9s+Z /ya0YAGbo/ygtxyZPrZG+ZxZ3ApsHvbGInlT2Cl0UCgzI+hZIqlCqZ9KEpwJvDkLhO1FTOgb4ij rI+ido2JbTEDXJtGfqv4UWhnvu0FdibC+VQDhIN+ouglZ5jSjUM9FNd5Aj4M0mab2aKKGmhKn+o qIYaiSr8ItyYDDO5rZYIMxOCsvwh8Ikoa88pPDQmW7LTujhQJ040+6bVvnZ4Qu0yyFnyeuBkLMg ge4i3iCNdDOektnUeR4R1fsSCefEyw/9nwN+0m5LY6Cyb6ToQ7tLfLxZZge4QwRWIShKbAAVyvk u4zxDQxB/qvyzp6j6kqi6CSkgepu2l6O189xMpmN+kY8byoeWQkG22T3tgXAHFKxjaFZ3JRpbLp 3yY6kYSlIBhqUbL/AkjeaRzJvpq6gxlvS2FcwUGjPdjZo6xjRSdy0/2GL992IrTalx7ksPNQVO2 O/kaGad8Y9zG1Z5jSMJTCAXfvqNi8nkcL9ekriWtjahjkPGe48fNgZl6LvYddsxacj1/VedGTu7 kEJKQDCzh2rhWXw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The returned value is not used, it can then be dropped. Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- net/mptcp/pm_netlink.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 99705a9c2238c6be96e320e8cd1d12bfa0e0e7f0..ff1e5695dc1db5e32d5f45bef7cf22e43aea0ef1 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1922,13 +1922,11 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, spin_unlock_bh(&msk->pm.lock); } -static int mptcp_nl_set_flags(struct net *net, - struct mptcp_addr_info *addr, - u8 bkup, u8 changed) +static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr, + u8 bkup, u8 changed) { long s_slot = 0, s_num = 0; struct mptcp_sock *msk; - int ret = -EINVAL; while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) { struct sock *sk = (struct sock *)msk; @@ -1938,7 +1936,7 @@ static int mptcp_nl_set_flags(struct net *net, lock_sock(sk); if (changed & MPTCP_PM_ADDR_FLAG_BACKUP) - ret = mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup); + mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup); if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH) mptcp_pm_nl_fullmesh(msk, addr); release_sock(sk); @@ -1948,7 +1946,7 @@ static int mptcp_nl_set_flags(struct net *net, cond_resched(); } - return ret; + return; } int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, From patchwork Fri Jan 17 09:34:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13943066 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 2AAD325A659 for ; Fri, 17 Jan 2025 09:34:38 +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=1737106478; cv=none; b=A5S68jxst18VBSvs0rrGRSd6O2R5X17qiFHAwFl16pOZBNlwWiDF6w9gGfo3+/zmnOJ8f54drKpD8W4CjLdrnm7gS6LF8OkuPps5nG7ueGyey1L1fKZrU8LZs4BHoJSiK1HLk9byHwdbp3WJcIGYlrsfAHCTRcobYM5JDLa9R0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737106478; c=relaxed/simple; bh=Z9VH9EKYJiONuf7Hf/esBY50wItS6sWRscwSaTlPiWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VFpda7qTcnFEchCniy3wWrXalZgXMvSjBUf9+2z8axqlr0uIWHqDxZ4onUSztlpnP7fvaMGyLz8mEtsPa+rrLJu5w7xShVcGNhHx+Vx6sVxJG+avslJdmIj4sqGnkqsqtSA21QxfuQJzHGAZ39v3aXVK4lJHlmJftQsMT7FhCL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O4cJJdOP; 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="O4cJJdOP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 758A3C4CEDD; Fri, 17 Jan 2025 09:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737106478; bh=Z9VH9EKYJiONuf7Hf/esBY50wItS6sWRscwSaTlPiWU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=O4cJJdOPvKax9J/2q2LTJuwHhDWifw3m1Z+nRNxTSlCZX7DZw64RkpcqTweIkMsuT VPVaFJkAzBVdz3VUD+06F1Sr/n604XyTL8xw8ZFZv6Lal2F+G5n9IUzF/2wwxrjAqw qtnv2tTowyixM/MDa2omfy3NMNiOsH/wn/k/CzEDhtVUKBZfCDXRwGOECUxYlGfDCa 7pSupHFxPj2u7DiNQWAw7mThN1CqP4UW7BQNraP+QFCEk/meZg1PpgIqIIufQqz2+s IuXY+Qq8L9yFCXm8+qa2pyva0/XM8eKbVGZDrA2ivR3MLGoDAT4CQAcZkQCL3xWxtz vbr29/WQXM/fg== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 10:34:15 +0100 Subject: [PATCH mptcp-net v2 3/3] mptcp: pm: change to fullmesh only for 'subflow' Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-mptcp-issue-540-v2-3-a194740fb380@kernel.org> References: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> In-Reply-To: <20250117-mptcp-issue-540-v2-0-a194740fb380@kernel.org> To: mptcp@lists.linux.dev Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2507; i=matttbe@kernel.org; h=from:subject:message-id; bh=Z9VH9EKYJiONuf7Hf/esBY50wItS6sWRscwSaTlPiWU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniiQofX9c+ku0mIdpDkRTTu5uKueHddSv61RPB peRXxM9wMCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4okKAAKCRD2t4JPQmmg cxQ3EAChvLiDOhc2hvEXSlirOtVgzd1+SQPS/Gg0JkiwYasaUYZ0tfas93YF0zuOcZSs2kZbyog b908szB3TXp1Y82SRC5WREvU6QDo3AjGlJwi3xUpQFOybyvdAEf4FCVtcy5q/w5naHB141YuWX4 OMbvugRWPy4CtRIRaXt/xRDV1S9L8IWP/KTmkLacSVvsO02ZQx4WOZdTI5UInKpvOtayGRL3OYZ IFNe0LTQ3gQ9P1reV4WUC8zdoiIrpYvj0SMV/ZpuMbJUWWvLsM1KfMF+BRamKhLfuGzSUr4ZtFN oV3PBfQ2SebLdPt/69McKYkeZ9eU5okXaZ/UWLzYi1212lGi3YDuqfds0CP3I8/5qEUq0ET0Diu aeG/mPE4Z9i6+ZLVSPVk9LExXBGulikMUCSLQlKQsPyRrw8mcuaDHOcZyAICUwUAz7ECDEeYzbc WNhZlJiLbnga/ZjvnagkgyFjt/WNa7979ckv7SON9vBAsqBbVkaAMC7IEWFb7EBiTSEAoJVy+6F 2LrsVrqgiEgIcD04SVL+bkvO1RjrbqDYzliEv04nswTNzxaq3wrNjwN3ftBOlz/Zlry0qwarKmm tdw2W7Jz9QnY7KWy4gt+muxG2BZ0rJGpO3ywaKzcjADwxeTN585fowDcLoNZpVR5wdc+O/g1FWl 6GYphfdkMqdmHzA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If an entrypoint has no type -- so not 'subflow', 'signal', 'implicit' -- there are then no subflows to re-create from this local endpoint. In this case, there is then no need to iterate over all connections to do nothing. So stop early when this case is present. Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ff1e5695dc1db5e32d5f45bef7cf22e43aea0ef1..b1fe2a74fcfe97896de8f9eaee9a1afa5378fabb 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1923,11 +1923,16 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, } static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr, - u8 bkup, u8 changed) + u8 flags, u8 changed) { + u8 is_subflow = !!(flags & MPTCP_PM_ADDR_FLAG_SUBFLOW); + u8 bkup = !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP); long s_slot = 0, s_num = 0; struct mptcp_sock *msk; + if (changed == MPTCP_PM_ADDR_FLAG_FULLMESH && !is_subflow) + return; + while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) { struct sock *sk = (struct sock *)msk; @@ -1937,7 +1942,7 @@ static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr, lock_sock(sk); if (changed & MPTCP_PM_ADDR_FLAG_BACKUP) mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup); - if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH) + if (is_subflow && (changed & MPTCP_PM_ADDR_FLAG_FULLMESH)) mptcp_pm_nl_fullmesh(msk, addr); release_sock(sk); @@ -1959,7 +1964,6 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; u8 lookup_by_id = 0; - u8 bkup = 0; pernet = pm_nl_get_pernet(net); @@ -1972,9 +1976,6 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, } } - if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP) - bkup = 1; - spin_lock_bh(&pernet->lock); entry = lookup_by_id ? __lookup_addr_by_id(pernet, local->addr.id) : __lookup_addr(pernet, &local->addr); @@ -1996,7 +1997,7 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, *local = *entry; spin_unlock_bh(&pernet->lock); - mptcp_nl_set_flags(net, &local->addr, bkup, changed); + mptcp_nl_set_flags(net, &local->addr, entry->flags, changed); return 0; }