From nobody Mon Mar 2 06:38:02 2026 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 CEACD32FA1B for ; Fri, 20 Feb 2026 11:26: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=1771586763; cv=none; b=JONQH5jBv03MHntgqwldXCEtsuZAJRIbrM4Z0s8HvwbMjlCC1iIoQAKeHSSlaWR4QIQXAhNDBiXsXCerTYGKpvBDQNP9bETVunmGSbyGp9BS4RHca2bGJfkkgXqfzsn9uTTuDiOG7REuHtxaeK2M61Ptc2gaHiwH0vm7p/s8ZyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771586763; c=relaxed/simple; bh=1s2cb4OZKRQpmugLeWzPD2pp5/O6/J+IgRSyDn4fk54=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fJlfQcEAIhWcFrKPHcc0KHFeJjcVkCFA6HFReHzokx8w92hVjEHTcAFJqI3cS/iPtzWOKFg4qtm8G77avH9hHEmSk/zuYhtgo1IG9eBauE6y9Nc85ngv9ENpuLfubyP7ArvQ6SnIRFu8ooYI0WSTIr5pVLAwluFRy0YGVeulkTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F+wM7s3P; 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="F+wM7s3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40DE5C19425; Fri, 20 Feb 2026 11:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771586763; bh=1s2cb4OZKRQpmugLeWzPD2pp5/O6/J+IgRSyDn4fk54=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=F+wM7s3PbTMKGawIWZ7yJqbnj/4gs7XyFZ9MY0Ll41XYuZI263vKgzb8L3gT8zitN KgnWuG9uXgwUpHNmLmogpM8dd+QeCnitQye1xZ2UnooMObiVZB7xlbCyDMrb2n7myk zBB8QvGW8YbN+lbeo28TDBaSbdUzNnGTyHJzg5WpiA8t40fnM8Jruk58A5y21JzT0q HYG2Og7tZdHdPQTzsfOzvot1+xKZwGFXx4dUFqAEto+MCPnL9KYxBPMkoPRZzyaW62 cCGHxfP1y+ibUxPX7IpLHmAh8fUL4J9QXdaC/vA8foGew85Qec1Xdb5IxdqIifk1ky 5dy71uBQvHdlg== From: "Matthieu Baerts (NGI0)" Date: Fri, 20 Feb 2026 12:25:51 +0100 Subject: [PATCH mptcp-net v2 1/2] mptcp: pm: avoid sending RM_ADDR over same subflow Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260220-mptcp-issue-612-v2-1-089684a6edcb@kernel.org> References: <20260220-mptcp-issue-612-v2-0-089684a6edcb@kernel.org> In-Reply-To: <20260220-mptcp-issue-612-v2-0-089684a6edcb@kernel.org> To: MPTCP Upstream Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3761; i=matttbe@kernel.org; h=from:subject:message-id; bh=1s2cb4OZKRQpmugLeWzPD2pp5/O6/J+IgRSyDn4fk54=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDJnuJy4qn14Fb8046S8/1Z5kVpGgRpRTG/ulj0tdvc5k 7Xgp/S2jlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIk0fGFk2HCzKPCH/qvUqCVh L+reiUqy+X1OjTphM9M3fMpp78uLIhkZDnjUJ8ZWzZSfsrylLSb4rfq3ZX33znkyrClrLZfZbKH HAQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 RM_ADDR are sent over an active subflow, the first one in the subflows list. There is then a high chance the initial subflow is picked. With the in-kernel PM, when an endpoint is removed, a RM_ADDR is sent, then linked subflows are closed. This is done for each active MPTCP connection. MPTCP endpoints are likely removed because the attached network is no longer available or usable. In this case, it is better to avoid sending this RM_ADDR over the subflow that is going to be removed, but prefer sending it over another active and non stale subflow, if any. This modification avoids situations where the other end is not notified when a subflow is no longer usable: typically when the endpoint linked to the initial subflow is removed, especially on the server side. Fixes: 8dd5efb1f91b ("mptcp: send ack for rm_addr") Reported-by: Frank Lorenz Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/612 Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- Note: in my initial version, I only used one alternative for both "stale" and "same id" subflows. I guess it is better to send over the same subflow than a stale one, hence the priority, but there are then a few more lines of code (but still readable, I think). To be discussed. v2: - reduce one indentation level and s/rlist/rm_list/g --- net/mptcp/pm.c | 55 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 8206b0fd2377..daef91e597ae 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -212,9 +212,24 @@ void mptcp_pm_send_ack(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); } =20 -void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) +static bool subflow_in_rm_list(const struct mptcp_subflow_context *subflow, + const struct mptcp_rm_list *rm_list) { - struct mptcp_subflow_context *subflow, *alt =3D NULL; + u8 i, id =3D subflow_get_local_id(subflow); + + for (i =3D 0; i < rm_list->nr; i++) { + if (rm_list->ids[i] =3D=3D id) + return true; + } + + return false; +} + +static void +mptcp_pm_addr_send_ack_avoid_list(struct mptcp_sock *msk, + const struct mptcp_rm_list *rm_list) +{ + struct mptcp_subflow_context *subflow, *stale =3D NULL, *same_id =3D NULL; =20 msk_owned_by_me(msk); lockdep_assert_held(&msk->pm.lock); @@ -224,19 +239,35 @@ void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) return; =20 mptcp_for_each_subflow(msk, subflow) { - if (__mptcp_subflow_active(subflow)) { - if (!subflow->stale) { - mptcp_pm_send_ack(msk, subflow, false, false); - return; - } + if (!__mptcp_subflow_active(subflow)) + continue; =20 - if (!alt) - alt =3D subflow; + if (unlikely(subflow->stale)) { + if (!stale) + stale =3D subflow; + } else if (unlikely(rm_list && + subflow_in_rm_list(subflow, rm_list))) { + if (!same_id) + same_id =3D subflow; + } else { + goto send_ack; } } =20 - if (alt) - mptcp_pm_send_ack(msk, alt, false, false); + if (same_id) + subflow =3D same_id; + else if (stale) + subflow =3D stale; + else + return; + +send_ack: + mptcp_pm_send_ack(msk, subflow, false, false); +} + +void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) +{ + mptcp_pm_addr_send_ack_avoid_list(msk, NULL); } =20 int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk, @@ -470,7 +501,7 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const = struct mptcp_rm_list *rm_ msk->pm.rm_list_tx =3D *rm_list; rm_addr |=3D BIT(MPTCP_RM_ADDR_SIGNAL); WRITE_ONCE(msk->pm.addr_signal, rm_addr); - mptcp_pm_addr_send_ack(msk); + mptcp_pm_addr_send_ack_avoid_list(msk, rm_list); return 0; } =20 --=20 2.51.0 From nobody Mon Mar 2 06:38:02 2026 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 BA68530AAB3 for ; Fri, 20 Feb 2026 11:26:04 +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=1771586764; cv=none; b=TMif4wrM2PvB29su8Ne4/L4/wvcEwL3vcPXVzWlU90g6pXokuCgBCL1djM+6HQv1O0a4/CBErvow7Bqq4pn/HdWsVHQ0ntS0v+JqUDEs/vS+a/FPKLAQ7v9vGqFJ+opTiQf7tJcfCrewMwQxv+6YOOOiIF3zQ0QoRSWkba3G570= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771586764; c=relaxed/simple; bh=kYQdB8KQRFXXa9v895Q5Ur8/giutAWzYe3SK4Bs4KdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u9gNkNBLdYVe+2jpZNJAwb933P8N7/Bz1SzCrGviN8pS387P9r4dzWZob7ZV/0LfhCOBTmtPo1xqFvOJuqph6JVzKkKQCGpHELPf7bJNwsubdgCF9/AIgT423UnZkLWqJ2jEX6+0t2qij8FS78w5ZLEoI/31AlJvLOef4o4lTck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hQUB/QBY; 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="hQUB/QBY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 244BEC116D0; Fri, 20 Feb 2026 11:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771586764; bh=kYQdB8KQRFXXa9v895Q5Ur8/giutAWzYe3SK4Bs4KdA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hQUB/QBY0jqXrHL3eH/mueb3eShJ2WlQKIcbhtfNRP1GmYZOIKMog4gvX64Y+wD0u evEjORXeM5qXpkAIFhviy3n5+f67PFqtjXhGhQ/fHH781nTeKo1GojUm7yyWS0N2i1 gEhEnF9luX4ene7/9hHHJ0cwMhscXP9BJTAdcHSpcUDDwQg8eX0Ybhgwf4SJORCgsQ FPW2VuWov+STw2HIDYFFKgAMQzlOAznt5iLw5Zmnz9h2B/Ip9skvYX/OGjNf6PKCoG cchT5as5QPmWeLlIBogBMqraBkRQTFzBPFf1y/ET7pZBbbBjH+SxIGqabC7pDb10Wn EZMQeocuniJjw== From: "Matthieu Baerts (NGI0)" Date: Fri, 20 Feb 2026 12:25:52 +0100 Subject: [PATCH mptcp-net v2 2/2] selftests: mptcp: join: check RM_ADDR not sent over same subflow Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260220-mptcp-issue-612-v2-2-089684a6edcb@kernel.org> References: <20260220-mptcp-issue-612-v2-0-089684a6edcb@kernel.org> In-Reply-To: <20260220-mptcp-issue-612-v2-0-089684a6edcb@kernel.org> To: MPTCP Upstream Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3877; i=matttbe@kernel.org; h=from:subject:message-id; bh=kYQdB8KQRFXXa9v895Q5Ur8/giutAWzYe3SK4Bs4KdA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDJnuJzUfXhu3V+x3e9WTl/E7hAYyXpGJacl0z0/f9H5m FU/JhbKdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExk3x6Gv3IX25nmzPw+ccc9 rzc7959b6tep4npo9e9Zz4JMbd5Xh8Uz/E8/0DLz93qBYzKCLH8mc77/y3DCbra5x52Ztwwe7f+ XepcNAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This validates the previous commit: RM_ADDR were sent over the first found active subflow which could be the same as the one being removed. It is more likely to loose this notification. For this check, RM_ADDR are explicitly dropped when trying to send them over the initial subflow, when removing the endpoint attached to it. If it is dropped, the test will complain because some RM_ADDR have not been received. Note that only the RM_ADDR are dropped, to allow the linked subflow to be quickly and cleanly closed. To only drop those RM_ADDR, a cBPF byte code is used. If the IPTables commands fail, that's OK, the tests will continue to pass, but not validate this part. This can be ignored: another subtest fully depends on such command, and will be marked as skipped. The 'Fixes' tag here below is the same as the one from the previous commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID. Fixes: 8dd5efb1f91b ("mptcp: send ack for rm_addr") Signed-off-by: Matthieu Baerts (NGI0) --- v2: revert to original commit message, not sure how I ended up with that --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 36 +++++++++++++++++++++= ++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index dc1f200aaa81..058ad5a13d24 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -104,6 +104,24 @@ CBPF_MPTCP_SUBOPTION_ADD_ADDR=3D"14, 6 0 0 65535, 6 0 0 0" =20 +# IPv4: TCP hdr of 48B, a first suboption of 12B (DACK8), the RM_ADDR subo= ption +# generated using "nfbpf_compile '(ip[32] & 0xf0) =3D=3D 0xc0 && ip[53] = =3D=3D 0x0c && +# (ip[66] & 0xf0) =3D=3D 0x40'" +CBPF_MPTCP_SUBOPTION_RM_ADDR=3D"13, + 48 0 0 0, + 84 0 0 240, + 21 0 9 64, + 48 0 0 32, + 84 0 0 240, + 21 0 6 192, + 48 0 0 53, + 21 0 4 12, + 48 0 0 66, + 84 0 0 240, + 21 0 1 64, + 6 0 0 65535, + 6 0 0 0" + init_partial() { capout=3D$(mktemp) @@ -4217,6 +4235,14 @@ endpoint_tests() chk_subflow_nr "after no reject" 3 chk_mptcp_info subflows 2 subflows 2 =20 + # To make sure RM_ADDR are sent over a different subflow, but + # allow the rest to quickly and cleanly close the subflow + local ipt=3D1 + ip netns exec "${ns2}" ${iptables} -I OUTPUT -s "10.0.1.2" \ + -p tcp -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \ + -j DROP || ipt=3D0 local i for i in $(seq 3); do pm_nl_del_endpoint $ns2 1 10.0.1.2 @@ -4229,6 +4255,7 @@ endpoint_tests() chk_subflow_nr "after re-add id 0 ($i)" 3 chk_mptcp_info subflows 3 subflows 3 done + [ ${ipt} =3D 1 ] && ip netns exec "${ns2}" ${iptables} -D OUTPUT 1 =20 mptcp_lib_kill_group_wait $tests_pid =20 @@ -4288,11 +4315,20 @@ endpoint_tests() chk_mptcp_info subflows 2 subflows 2 chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 =20 + # To make sure RM_ADDR are sent over a different subflow, but + # allow the rest to quickly and cleanly close the subflow + local ipt=3D1 + ip netns exec "${ns1}" ${iptables} -I OUTPUT -s "10.0.1.1" \ + -p tcp -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \ + -j DROP || ipt=3D0 pm_nl_del_endpoint $ns1 42 10.0.1.1 sleep 0.5 chk_subflow_nr "after delete ID 0" 2 chk_mptcp_info subflows 2 subflows 2 chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 + [ ${ipt} =3D 1 ] && ip netns exec "${ns1}" ${iptables} -D OUTPUT 1 =20 pm_nl_add_endpoint $ns1 10.0.1.1 id 99 flags signal wait_mpj 4 --=20 2.51.0