From patchwork Mon Aug 19 19:45:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768897 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 B8BC71DD3A5; Mon, 19 Aug 2024 19:45:29 +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=1724096729; cv=none; b=nJWdKsK+EoXDUvtRwoIZcRZ7XF4Nd5IMWV6qNVh7llK2eMHBReHRcdsBiUrAFcNdFt0IxrPHsl4JGRk7UbAWiU5pzJTX3UiXR7tShlYH28dxDIwe9yZ8Tw+t7PY83yvgaHEU7tgAAMNkMKURptD/7VqurwCee52cgMdU9c2qUxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096729; c=relaxed/simple; bh=V0XCDtlKCCwxfOzle3JmIKNgZUrz+8RJB7fWPgB6tHg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QaevPx7BkWz+lhT+enh8pRYbCS548VpbvaOJEMuuB/vXDUvKZOXvzINuK+VPCkvoJ1OfZ8mI4v1ZetHEG/Zvunh/9uyZisLBkQSzbzd9bFgSNRUum2t4vf11V3CKiL6LIb1OJDaEQ6ZEOzb019Irx/FCnzaMxn9OPRlHRPEQoA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PdZfJZrH; 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="PdZfJZrH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1AAAC4AF0E; Mon, 19 Aug 2024 19:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096729; bh=V0XCDtlKCCwxfOzle3JmIKNgZUrz+8RJB7fWPgB6tHg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PdZfJZrHw1o1P/n4e1RZgri8ihu0PHaOAhdfaBU3nr75ilLHA5XwNimTk9pwvosCe y+8FMPwyIzXFltKmYDAa3i5Dt72kl1ZdyNcfiq3nRXoDGL1qZPJnmdr1WGC+fAjjbL G6siIx3crMjnPkSwh6I4Vhqs741h/UtVRkN2qWnU5Ngy0S8yFyZ7KxO9BmtpWM0rrO X6P71QbpLN2CJ3GzHzF0cqDFO4r75yl/lDxUJ/4YrFMQQMbTTl0wqh2X7i3aKxY6cG PbiZqjX6P/B1xZhUBT5spfM8BlXijWLhRaJ8MPVUEuHS5IE3+HfDvxKN0P0z0/LJW0 hDEMXR38GuZaQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:19 +0200 Subject: [PATCH net 01/14] mptcp: pm: re-using ID of unused removed ADD_ADDR Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-1-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1120; i=matttbe@kernel.org; h=from:subject:message-id; bh=V0XCDtlKCCwxfOzle3JmIKNgZUrz+8RJB7fWPgB6tHg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DSU6TDvIdePtPMOoc2sdDuk8wQ79rfFTVGI YUukJwBZLmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg c/irD/4zKqr7S7Cvi+YcAnh4fnT0MawawQBJd+xByazwa8FSRu4z9UHlCwTUZok9XK86Tu8ml8g Ppk9vEvUCZESa4lP1d1gEpKMCH53WrI+iDkjtS47U+4OXox2I16U6gTcKczSEsuH2AyXyU3R9vX 2i932yV+ZRIVOIIRFNk+KVOFDnQobqwstuvDyjbH3xNCZ8w7Dhqikp409yKLK2liZgSQbpBEFiW S7TLKi6/jTslC6gSywpfS7MRj8sLFaZUUdXRBJ65CoCiT9WKO24c1z+qpbNaDRojYpjk0rjDEYe jfoNzcZUEJkGM6uCjD0pig2H1sGkf0RYDmt/SmV/yFfp68rFV/x8E5fBl5JyDiWKxMd4upFZmm7 oRi8NOjc4qwekqMLsNuJEGIg63x6MZQESSAvzRJo73z+DvWJG/tLyRjC51ukukyQh48yEm6UKT+ b80hQuS9S6Fiaw1R26tdz2w0UDDPl+4cu/cinZOctfMcQbDYqv9cu0Z+MLO0R1LsSuAKHdM0sca LinvJo2+Fza6tj9WWKJMdnESQ5LfyGHSZnzG0+ZnpgJ6t0kzRzhl/Gfx/oVveIL0qxehobtpTwO ZE0p9Kj2Fal8PMpyvWKOLFjEytBKcDFAhARGmkxUw/brnovhoHjbZ53oBmVpkSQI0kQN+8Ua//n iePtWkn751S98oA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflow is attached to the 'signal' endpoint that is being removed, the addr ID will not be marked as available again. Mark the linked ID as available when removing the address entry from the list to cover this case. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4cae2aa7be5c..26f0329e16bb 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1431,7 +1431,10 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, ret = remove_anno_list_by_saddr(msk, addr); if (ret || force) { spin_lock_bh(&msk->pm.lock); - msk->pm.add_addr_signaled -= ret; + if (ret) { + __set_bit(addr->id, msk->pm.id_avail_bitmap); + msk->pm.add_addr_signaled--; + } mptcp_pm_remove_addr(msk, &list); spin_unlock_bh(&msk->pm.lock); } From patchwork Mon Aug 19 19:45:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768898 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 E7FF01DF672; Mon, 19 Aug 2024 19:45:32 +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=1724096733; cv=none; b=lluiYb0R7bzDpBXU+uN8EKU4CDEx2Gk627xamp3WbE2bBH82kpvMo2mIkDiNCEFPksLQHLUS4khjjWcuRG0cikTvLOx5BEMaHap8j1KKtx5O9X7I5mDTJ31QG8nI26mLh57enZ9sBdCgtP5LVgv7pJFQWQNDwaa59v9Bgo9W3AM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096733; c=relaxed/simple; bh=NtVlQLPFijop5CpDR1dcSpINA0/PkFREiPlPhJDJkCc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tEaqUCChbJId7woI9k82VlThFKurTXJNIEx6g0pO92nY8MWnH5vbkrIR6w2Dn2mZL0pCGf5lY36maLABv52QNZ3dUggtauRAIcMdMTYsi6o0jkYKj1jWKd8RTuS5hFqhTuH6O21A3unPZ8uCKyD6s+xb+lzzGF/skPLE7IKdEOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rfPdD7Ab; 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="rfPdD7Ab" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0C80C32782; Mon, 19 Aug 2024 19:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096732; bh=NtVlQLPFijop5CpDR1dcSpINA0/PkFREiPlPhJDJkCc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rfPdD7AbOdTIOk6LxlwjJC1n4e/jfQcR/q3nslx1FYRq3cJrm3hBv2nGPkXCTLK7M IRKC3m6TOG+SjmRLWvkwa8CJ3SRTGBnMT1e1M+AIcnFOmlUHu8EcUOteXN7Tz1J7oF CDcbMZUsqa8k0Auy0qux9kNUsEjYGTQZOdweAuOrve83I/99SWnHp/Ik/LK0mSTEvq V0QTNUgDzCQgHYcsyC0NqssSpRa+dAUxesRE4d6hDKoksV/0OOihq7jN5SjfZeCzbu dzYK2Lbeid/SBBjochFtTKyVwgQdmxufwTbiHjBea7gV/fSpR4nt3HXAoUeu/A8Sft aTiB/mW3lPLaA== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:20 +0200 Subject: [PATCH net 02/14] selftests: mptcp: join: check re-using ID of unused ADD_ADDR Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-2-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=2670; i=matttbe@kernel.org; h=from:subject:message-id; bh=NtVlQLPFijop5CpDR1dcSpINA0/PkFREiPlPhJDJkCc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DSCbkW+VOhlV9gbjNgUsWpTcPkSZ3rP65LD FRWTteQlAyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg cyBmD/9rcB5iwtdVpspO+LWc6zuyg0lQ9cMOAreIOUGFgqTKAE8YrHd5wQj9mwDrNyguN2NeeiZ fx2D6JF2AfIa1mpeHjCTM0U7J/TPzKfYH3w/yOX00D4vUYRYSSD6MTJr7V1whgCUfLMhepp7YHk dpitgNGlQB2YYMT7lE9FWqBvGU7LkbfWBM26iapSk+majttQys7DOosZLr6vIhClISO81Qasb2S tGUByP37JV/dHIcyzOFsm2cJW3rSG8OE1njgBl5tGcrSE/rMWjBNxX02R4BqlhbynG6CBOHBZrX wO1cMvCUrWrUzvn9U77LUSd/B1liHf4DHTrrW57ZsBJ4no15e0WOEUcNDZM6qovg3MFbAOYgjPg iQah4qQ0w/brrv1sqVpQRQwnxR+c0iMUcupjWEgankxhXVcwHchMJwBDBG8H4okK91HkRw5s9wo 7q7N3iC8ykuU/dRJQ+CFcEnwXkkCj5Q/1MBbwrMvKsNLzrn6H4TI3iedBbxxtCuFXfwSZYcsnBr OBtTC9e0HsjB/jmzuVT+3/yAz8GsNcj1zDd3DsRnBo9K9+KgKV3nEuFOGktAs4AlT22ySszhEHS 9ahg0gfqQEEIFc+jLvIen/RU1sKntCcpzbjVlhOlX5F3XYxOq0S33X4GgC90mPKXGDF6dWdLo30 QTy8o6VpNY513pQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This test extends "delete re-add signal" to validate the previous commit. An extra address is announced by the server, but this address cannot be used by the client. The result is that no subflow will be established to this address. Later, the server will delete this extra endpoint, and set a new one, with a valid address, but re-using the same ID. Before the previous commit, the server would not have been able to announce this new address. While at it, extra checks have been added to validate the expected numbers of MPJ, ADD_ADDR and RM_ADDR. 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: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 9ea6d698e9d3..25077ccf31d2 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3601,9 +3601,11 @@ endpoint_tests() # remove and re-add if reset "delete re-add signal" && mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then - pm_nl_set_limits $ns1 1 1 - pm_nl_set_limits $ns2 1 1 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal + # broadcast IP: no packet for this address will be received on ns1 + pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal test_linkfail=4 speed=20 \ run_tests $ns1 $ns2 10.0.1.1 & local tests_pid=$! @@ -3615,15 +3617,21 @@ endpoint_tests() chk_mptcp_info subflows 1 subflows 1 pm_nl_del_endpoint $ns1 1 10.0.2.1 + pm_nl_del_endpoint $ns1 2 224.0.0.1 sleep 0.5 chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal + pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal wait_mpj $ns2 - chk_subflow_nr "after re-add" 2 - chk_mptcp_info subflows 1 subflows 1 + chk_subflow_nr "after re-add" 3 + chk_mptcp_info subflows 2 subflows 2 mptcp_lib_kill_wait $tests_pid + + chk_join_nr 3 3 3 + chk_add_nr 4 4 + chk_rm_nr 2 1 invert fi } From patchwork Mon Aug 19 19:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768899 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 3FED91DF699; Mon, 19 Aug 2024 19:45:35 +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=1724096736; cv=none; b=P0+CDQO1T73LqOgdL6cfSnB0tMAqsn35IIiDzfMM5wlXTidl1yGzm+VOsDWi7urmW/qxLoPeKB5OqZjuGDArydVrbkzXo6dNj+d0ZVuaHmJqXRxJ033r90AqZ9QPNVtoZJ1Sp735R31MWxMPlVVrE0AGel/qqPI/o6zxJP7w2Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096736; c=relaxed/simple; bh=e6zkinGzyHZuqufn3PvT5I44EByDELDaTnVXsfjtp50=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IGETt2O19VtkttU6Xs33K6qcSuVkyD1omIWKOVgxlCPqINObmyqGzQIsXQcK9q9LZWHHENiRHklCTGwldrk4mWi1iJwM5iayeOF3K/J6/KhWse9Xu2Xr/15zOaTcfIkbsibYKT/qV7Ams1kx+bb0WkoWI3Zw60DTXJ2MW0HDtho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XRL1PwuQ; 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="XRL1PwuQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DED96C4AF0F; Mon, 19 Aug 2024 19:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096735; bh=e6zkinGzyHZuqufn3PvT5I44EByDELDaTnVXsfjtp50=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XRL1PwuQWpABS9nJVMXetS91thZG8KLYviygk4BpkvTd755ruwXBmSYPTEijPT86/ qi5ClvqWNK2cYSe4xQRF3n72aXO4VZ9hvsQxLUQhDmGodF2vbF/Ttdiy+pgAgS3LBW 2E4831pcze7r2oU0jiyj8/TQ+cOGhjTfkO8kLL2x0Ppp7TK0s8fe+3OQshPXlMwPDL ynqN+QgVp/gZy5+Tp3PAFbNB5PVbRIZevjs2Jtg2p9f7rvXNpKiRdcBbbJDFkHxHt0 8Nvwb3uAcckZXvA0rlXMKncQ6mh8NZ4gVKObH2N9LOxTyNVQ8sM4clilYZsPd+bFlY j2z/FjoQUcKkA== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:21 +0200 Subject: [PATCH net 03/14] mptcp: pm: re-using ID of unused removed subflows Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-3-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1597; i=matttbe@kernel.org; h=from:subject:message-id; bh=e6zkinGzyHZuqufn3PvT5I44EByDELDaTnVXsfjtp50=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DS3O6nMV3haSBgRiDbVkjH5T4nwrxXX/G8I H7swPv/0OKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg c9QVD/9Y+89LmOmjArCRkXagsmPAvAIQD/u7kGfMS3oB0FsFbh9VKiuijgpeZIKWUbQZV1M/H11 zN67MjgTgKGp70S6bC2QQwVgefON749w8hsKnAsApcaS7UwekcNRBPXZLrASDM1vIJpGyzfH8yt zmTajTgEpmzLiO5I1ymahXbQ1wJjYVul67/VbN1Ez+6SOXssEMeHY+aDbAH0q1nqlS4ZNV7S+Nl 56wNu9T4ZFFnHn2R9I3m3u7ByJhPQ3C7uYHCL45v4WalNakKC5tkuHPlYo2EUmzOYDX+ASeXwSw assbEOAMJt2MYGPP1Lj1fJftL9M1ZrUjHrS2py8Xnq19RjYLohBU5+LfLP19QZMFpLoQhj+XHMv HA3XpSTB2tFeyLhjUVFwZQsolYrTgRwOX5ogZoyB7cxmFsRpnb5udGe1bNh6o/TLWeZFnW7YdIn jjMgVjCaBgxifUQappPvrgGEs69E944/0eHIlnUR029ZBni30g6ZuWgk73LUA4MdZyCPiAtvdF7 40YroNQuRbvuGYiB0nGGRsVBn8Y612iuCsObG2PqCDeGT6vuKubCgPNAdjRkrEFimuvavvtmyaB xE5qT11qB7UBurgtHeX3o5JSc7lb56iuhlGkWLgiyW9qoqAivPWYgiMsvaznG7Sq7rIAg3fH6kc osXKAXmz4bElLbw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflow is attached to the 'subflow' endpoint that is being removed, the addr ID will not be marked as available again. Mark the linked ID as available when removing the 'subflow' endpoint if no subflow is attached to it. While at it, the local_addr_used counter is decremented if the ID was marked as being used to reflect the reality, but also to allow adding new endpoints after that. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 26f0329e16bb..8b232a210a06 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1469,8 +1469,17 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, remove_subflow = lookup_subflow_by_saddr(&msk->conn_list, addr); mptcp_pm_remove_anno_addr(msk, addr, remove_subflow && !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); - if (remove_subflow) + + if (remove_subflow) { mptcp_pm_remove_subflow(msk, &list); + } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { + /* If the subflow has been used, but now closed */ + spin_lock_bh(&msk->pm.lock); + if (!__test_and_set_bit(entry->addr.id, msk->pm.id_avail_bitmap)) + msk->pm.local_addr_used--; + spin_unlock_bh(&msk->pm.lock); + } + release_sock(sk); next: From patchwork Mon Aug 19 19:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768900 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 E11641E211B; Mon, 19 Aug 2024 19:45: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=1724096739; cv=none; b=qY/wMukFzj3nRS29Lfn/T4t05/xah28Afh9j2FrWgjiYcYU4usVOJJ7pPWiDyAmBYGXJ8ZNBytmJx18aSeYDBawbNSX3zwuVxnzoVlTA8PNQhG8HOXzpnW3VC6ICJ2KEL7H/NDUNXCq8HGMJrzVs+svM3D8f7F1H0712F80HUQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096739; c=relaxed/simple; bh=KyL1tUwzalesCFQEM6xvcAjmyyEPD5yGT+YavTU6wv4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jTe4jzFycey3bKrrjFFv6oTbzirIi1Iv0kLE2gNqctJ9/pUwVW62G0/vXtHw6TEAJ1Uu6d5aOjLGkdSAtuKRvrqGzVAhzFpd9ywOf7aQLWXJRYdx6Gu55Vhy4yafj7mFqGdtdu/NlvHZQySl6se2PvIjlbwZnRbIcOM2KAKe7qU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dt64JPBo; 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="dt64JPBo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 282DCC32782; Mon, 19 Aug 2024 19:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096738; bh=KyL1tUwzalesCFQEM6xvcAjmyyEPD5yGT+YavTU6wv4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dt64JPBowDSrJzTtJC606z+1MxranD32jWE+cfBp0kfCjz/lXb5qDOe80J8kXqTCw N5fnDy1Jhm43Kf2zrPWWjbvi1JvssFBgw1HrkpWESFrArOE2qFFlDkt/fAr7yBTb4u pKqjlUsU6lltAVeGf/I4ATWpqTf6giaGRowUrBBtCCTdyARCsH+cq5d7ePAcTZmPSS QTXgjCauxPR/0nMX69OcGZy4WiTkaCBk0+U5oD5nTUP/eHdS67Jy3lmIbknOoa7UFO cFPLsoWV7Oganl7yAEunCn+/uBytF7ZLjjWR9ix9656vk5R6ZUY1F5mE1AJ7ATrkOQ JyBfdx/ljHrEA== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:22 +0200 Subject: [PATCH net 04/14] selftests: mptcp: join: check re-using ID of closed subflow Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-4-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=3051; i=matttbe@kernel.org; h=from:subject:message-id; bh=KyL1tUwzalesCFQEM6xvcAjmyyEPD5yGT+YavTU6wv4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DSw3YsLw4l+9VZXlEaeIGDqXqFnijOr7WUY 4E4NoHMvfyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg c7+MD/oCRfzXefVY9gyVcQDTFoixW/fNHOENIGdacb6XLbe/zzxUbJyHsqruG1UVPMdhhoaKuDk BxD/d5gtTw/QNOGGAEfkFJRZGc5K2/l+48N2GnitP+ygKyrHROJx6mOMYL+6Xr4f5UssxpYp4XB H5I6rsqvpaTP+5K6ENm235fziumgE0ehLSOI1S2bbvqRDdldE3VahA6J/D05Nkpb5mtdMfG/BWf /v9ewQJQ36IlvsGK7feURoGC/pIK+S2VMVd/WrY9U2dbp1O2GDM8AhL69wHP0mCviaq9mCqTv5N 9Z3okQZBlj9oGh7lZbdaeZhbKH3T+IqeuXxATmZORJwiEQ0fdUaMYL2b3GeOcL7njv8K9FGjIfK wPsz/aiEhwdo2a4xxAsVVb9V3AGwgoL4GPQ/SWbsYgkWrzDeKwWMfVW3+ZjGEr9LyhHDKhG4EsL QtNq9VLa2beXalLN974fRX+GI3on2CFVp3UENcfRMHBPlEASFFhYPJJmaC4vY8/BwVFAzHBtA7r YTLE3roEupItItt4JTt/3y2h4hDOTV8AQOOXeGOfkbyGhjaeU8O5PbzqEVwIoO0UQqOoZ7lk6FQ zmDp4kVJMQK99C+zgbR2YnJuEWkWW2+Y2kJ8ssawmD6yR/8SQjAsWAApACDmXtxVk8Crk7Mq5wK zl/FPmh63717/Hg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This test extends "delete and re-add" to validate the previous commit. A new 'subflow' endpoint is added, but the subflow request will be rejected. The result is that no subflow will be established from this address. Later, the endpoint is removed and re-added after having cleared the firewall rule. Before the previous commit, the client would not have been able to create this new subflow. While at it, extra checks have been added to validate the expected numbers of MPJ and RM_ADDR. 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: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 25077ccf31d2..fbb0174145ad 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -436,9 +436,10 @@ reset_with_tcp_filter() local ns="${!1}" local src="${2}" local target="${3}" + local chain="${4:-INPUT}" if ! ip netns exec "${ns}" ${iptables} \ - -A INPUT \ + -A "${chain}" \ -s "${src}" \ -p tcp \ -j "${target}"; then @@ -3571,10 +3572,10 @@ endpoint_tests() mptcp_lib_kill_wait $tests_pid fi - if reset "delete and re-add" && + if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT && mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then - pm_nl_set_limits $ns1 1 1 - pm_nl_set_limits $ns2 1 1 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 0 2 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow test_linkfail=4 speed=20 \ run_tests $ns1 $ns2 10.0.1.1 & @@ -3591,11 +3592,27 @@ endpoint_tests() chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 - pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow + pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow wait_mpj $ns2 chk_subflow_nr "after re-add" 2 chk_mptcp_info subflows 1 subflows 1 + + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_attempt_fail $ns2 + chk_subflow_nr "after new reject" 2 + chk_mptcp_info subflows 1 subflows 1 + + ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT + pm_nl_del_endpoint $ns2 3 10.0.3.2 + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_mpj $ns2 + chk_subflow_nr "after no reject" 3 + chk_mptcp_info subflows 2 subflows 2 + mptcp_lib_kill_wait $tests_pid + + chk_join_nr 3 3 3 + chk_rm_nr 1 1 fi # remove and re-add From patchwork Mon Aug 19 19:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768901 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 45A271DD38B; Mon, 19 Aug 2024 19:45:41 +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=1724096742; cv=none; b=B8Dh3N6YhVRm82mTvG08y2KhPMpbwqcCoXQ9ReJ//ZLgRsKaO5hoIj6IcEK+7855luhEicL4CLvxXtzbwtmeHTTpknz+8FexHgb995HQE3V83GGnY5OrUAgAJ3aGpNcyhA23LWmIyEqpab/81+5gK9qotVPEAXXwyywf+p8InV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096742; c=relaxed/simple; bh=ntTt2Nf5fS/2mcfHtb4bPPKUjO530QR3Xzw6s0Sn6JI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ELw1Il3R7vo6WrLgSsE/GGmYm99l2qyCzOmRz+f/Z5Gj0wuwJMN4IZCSqfMSNDRxp6fr5qPdBnDTKXjK9GcyadARZYUIIH83DjhJMfXdbXjT4dBkq1uC1PKGwnzFXRhqbFLryFf3SMFYeI9pDXpSimLc2CdIdu1DGYYnbNGFmKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fujYw9oY; 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="fujYw9oY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3691AC32782; Mon, 19 Aug 2024 19:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096741; bh=ntTt2Nf5fS/2mcfHtb4bPPKUjO530QR3Xzw6s0Sn6JI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fujYw9oYtwKQaXF2thHrVzOzBTpbECxisUS5guS2EvWvV+Qp56YS/yrQ/h6c2FNlE faEMuxJTKnniuPonAp/R2DZPS8QvcOMroVc+Nm64gFsGfp9smsfJdJ9gU0LR07iOnc PeBlnGMAqWOgeE/G20v4L03HkmWkNQSUJ1k3y8yl8auPSBqO9FONG4L8/tHCUaEh2X NCI3LFo/A3GlJ9N+y/yKqK1hPnBO0pYBJq65r3mO/6hwlG/LAzuw0lStu8Jqgfn+QA u5mMyoSkB08wWAJUwr3eS67G12jYgosaggV+EJPRtsA2Rhjb702Q+wW9efOPZ28XqB CPTaiiz0hv6Cg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:23 +0200 Subject: [PATCH net 05/14] mptcp: pm: re-using ID of unused flushed subflows Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-5-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1447; i=matttbe@kernel.org; h=from:subject:message-id; bh=ntTt2Nf5fS/2mcfHtb4bPPKUjO530QR3Xzw6s0Sn6JI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DScf67eUXQfJ6D+r8doyT+NgdgXyiQO8HrB vcVhs6PfM+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg c8XBEACn2aI1GQ0qKUKPXo4XvDgPuQ04vanm3OwwN7E3VRCQfQcQQ5jQkzMc3Gjyi6+chzBeQsH vyH+D20vvqXqGmzz+sH9MOJswVIvQ2ExEiaZ7pM0mfvDrr3ILdojpjKg4uamle9BpCoTKqHDTRt fiC8s5AzYdrFCeADxAUGBWRM6cuRH7946ZnfpXJIvH6X502r7INjCwmJCE3aZJHmzlePaFNvxu6 /bG2/vS+jqb7WK+v9W0xFiQhNa/Kbe0xDKMWOhIROz3vYyqmBQ4dRVwsiKGEIn35KNABUy5zb3c 1eD9y0UMXPY6OwhBthzP8Z0RV4EzqzIKMBUQANniONuz9A1yJIT1IgTjrU0WPst3svHfrm004OE Yop/8ovGXWldoR97rbM7RAMOUy7CYx/0cGnyVsPcsdEd0orfWQviIDy3SkkVPqWDeneOkavDHWO 4LJbQbspJUkwSwDpnzHYKhZPlj6+BXuQzrXcCiUMU5rEOJW6ubvKRyTd2llLdnpljmEUVMZCikc bTH6cEisDzfJ9PYPV8mK8ghuxcuXC9qg049R2K98hjUY+sEzJ4DkTrOS5HX9+Hxymj9tXF6B+Vg QSfR3JpP3+djyeD/4U8Mdr02hV2aJwYL4qF59puDNF93ORZggWP1nVwIWFQna94GY37sGB3adLC 5ix/zaQlOJlzPow== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflows are attached to the 'subflow' endpoints that are being flushed, the corresponding addr IDs will not be marked as available again. Mark all ID as being available when flushing all the 'subflow' endpoints, and reset local_addr_used counter to cover these cases. Note that mptcp_pm_remove_addrs_and_subflows() helper is only called for flushing operations, not to remove a specific set of addresses and subflows. Fixes: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 8b232a210a06..2c26696b820e 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1623,8 +1623,15 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, mptcp_pm_remove_addr(msk, &alist); spin_unlock_bh(&msk->pm.lock); } + if (slist.nr) mptcp_pm_remove_subflow(msk, &slist); + + /* Reset counters: maybe some subflows have been removed before */ + spin_lock_bh(&msk->pm.lock); + bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + msk->pm.local_addr_used = 0; + spin_unlock_bh(&msk->pm.lock); } static void mptcp_nl_remove_addrs_list(struct net *net, From patchwork Mon Aug 19 19:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768902 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 09AD31DD393; Mon, 19 Aug 2024 19:45:45 +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=1724096745; cv=none; b=JCL5yQ4pFyjCEH8cBWwlMM9vgZV+1DKYiXJy+eRpJ0at2VGMtpHdlRqD0OwbzdNUGs501KekoyrY12+LwnOPeApr8CjFo4xgKAYPAgmhJPmJYZGHiPJ2SS3pY1IWTGRDB1+R4fboExecMAb7RGvzGUddTgpr1I5IbVzovYP1ROQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096745; c=relaxed/simple; bh=el3krj0gIbWdRFoKFHJr5isBMDFRQzCj/EyzGroLrZY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=duJDlYd7257WT9tAuQYxxDvH4AeFFIpFwwt6Iy6Bd1epZ2jPKEB2edLlhoFmAfMX6gcz3qwrw9gDHXOj85X8/+k2XqsUDkOATnbkf1TXWSjduRzMEH/f2r17nYWgn7+a/wliezs0FQ7sPYvtyFRfICrPmx7K3suk/37lJ9ivtTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mZ8Uq4EY; 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="mZ8Uq4EY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43226C4AF13; Mon, 19 Aug 2024 19:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096744; bh=el3krj0gIbWdRFoKFHJr5isBMDFRQzCj/EyzGroLrZY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mZ8Uq4EYocvXI63p+tYZxjxx5hRGWc8NMB4Tr0F7d2siW+V+OJ4DFP1GbD1bMLgTq XbWesBol+9AAKRl7FJ08/dXi3ezZHksrNerJyMep1qZSSB5b1kPT89Wv9bsMsro1Jr Z/4m2hoUBVZnWtiL4M8nx+zGriYqxf9J3ihWZkqNs1tGznn9SB2YSd998cf9bz+Puh umpNItZwjyyFLMraektUlDLHfZGc3AwCcNzBTB4HM0ajqwJyl2iKpBGqShcDjqGIGZ hGESVYQdkTPQDbkKiRMJOBCiA+XoCCD7AjZCFZo9VBPkZmD3U+cnegJS+ks3Pp54sS lrBMdD78HJXHA== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:24 +0200 Subject: [PATCH net 06/14] selftests: mptcp: join: test for flush/re-add endpoints Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-6-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=2253; i=matttbe@kernel.org; h=from:subject:message-id; bh=el3krj0gIbWdRFoKFHJr5isBMDFRQzCj/EyzGroLrZY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DScjkZfQJaQTRVHr1aF5SLxUPZ9KRCi6Qc4 lsrfGRVXyWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0gAKCRD2t4JPQmmg c2M5D/9ZWZV2bJ/sc8iXcSDFG9UgrJMtMOqHrt3HPuSYkcRelDRlBMwgAhx5OAO2LOEQPdvWLwv ak+GdNBvdhpmS0blXW8xflRXP2yyjSQNh7FoceVtlh+RwDqbqBlmq7Krp7hTrNOrTGOPqpSX6CU uQyKeM4nbb+YpaOFPMow6Hmup0NkUsyop3usTGWW6i+rpNznxVlL49ReJRZIwGIeZQiHwl4a15x +W23roLFxcy8h29U2f5ZmHLx+c6LVgpu3DMlYumqcTbwYwXcpYupJ8hJ8oxrMRWQBz32LY2rZOD dCcb5Gf0srj5kTe56I3J8nhklNsQiVDIUkE+yDBAfEij4Fh7/ZhfbcRMhRdJuHHkvwbh3tiyNl1 0z5onPftIJkhhRfKHKySne9B83notBVhysnTS1nUd+1aHTy2fXvSHhfIwokX4sUiMAdAreiaHQw e3r+z/oI8dQqKeiImKsle+ll8YeDWq0scuyMQtykdTTobHpn01gJ8q87CgGr35+oev0R+GLqAyc lEM/R8q9YY2hLuAIOvuIO0p41P3M/mENlP5xzVAF67+Hg77HzK1rP9ZBf9EuI99HL9MWaCF8ahw ubG61dUchdd7WAuwd+Gvb06MKmA4W/f/ZfgAwAC5LHBgoj5D3DqDIs5UCgs1ehlD4bYjE0Rlb5m 1SSkwqr+Zx634Fw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After having flushed endpoints that didn't cause the creation of new subflows, it is important to check endpoints can be re-created, re-using previously used IDs. Before the previous commit, the client would not have been able to re-create the subflow that was previously rejected. 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: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index fbb0174145ad..f609c02c6123 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3651,6 +3651,36 @@ endpoint_tests() chk_rm_nr 2 1 invert fi + # flush and re-add + if reset_with_tcp_filter "flush re-add" ns2 10.0.3.2 REJECT OUTPUT && + mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 1 2 + # broadcast IP: no packet for this address will be received on ns1 + pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + test_linkfail=4 speed=20 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + + wait_attempt_fail $ns2 + chk_subflow_nr "before flush" 1 + chk_mptcp_info subflows 0 subflows 0 + + pm_nl_flush_endpoint $ns2 + pm_nl_flush_endpoint $ns1 + wait_rm_addr $ns2 0 + ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_mpj $ns2 + pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal + wait_mpj $ns2 + mptcp_lib_kill_wait $tests_pid + + chk_join_nr 2 2 2 + chk_add_nr 2 2 + chk_rm_nr 1 0 invert + fi } # [$1: error message] From patchwork Mon Aug 19 19:45: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: 13768903 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 100F51E4EF4; Mon, 19 Aug 2024 19:45:48 +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=1724096748; cv=none; b=Z53xjJjvpCWVL37sW0IXX9bRSasfPKqvYZbjdvLES+eNa70Kk5tgfJnRDzq4tupbukPcgwa0ASN1x3SxjNtFw9pc4BbGs/QLySFqqZs4mne64fLb+FCco5tLT0sZTXwsLxmOw9wpM8mwTbeZzcNpQe9bZzOfPzAqXpqStTXaAcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096748; c=relaxed/simple; bh=BTC1VqrgypC0zR0a/DPftpsfqKtSqKmahpvHDAKQMXg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KyQ9zV7KCIqWxTPRqPF5GI6nEmQQnrGF3n785ClXHpMW2vXi8fFyCC317V/1yymvEAsYNW0f2702Lb0bvIwcpHdh+FdDG6fmYtg0lAQvZf70pyBUeJ5xEwUSUmZg4jwKj57JkNt/kHDOKNhtiBX6iXSzeOWGrO5EOA80e4RgkfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ka5ojFE4; 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="ka5ojFE4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FCBCC4AF0E; Mon, 19 Aug 2024 19:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096747; bh=BTC1VqrgypC0zR0a/DPftpsfqKtSqKmahpvHDAKQMXg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ka5ojFE474ErJ8kwIBbixpX8geY+tOEnYTHKQpE5vtuzWpabbs07VH98SJkLD1zcM +3Y2GHAmx1tTPJWH3F2jVN5gDwsr93S1Ph5ClEUrpBcQr04365hvXB8APyiDw5hcz1 QvRnINMeBaTNq17/nRBhbNCx3s/7OGnaOeSu98MjLthNSv8doRXJwySx8OXLVOk/7E p1f84gOd3sT5eJo7fw4RpV+7ZOd+3a0IuS5ZYJcXO9Gj2OgOgq8t1E5VnI8bgan8Ln pJo40xQ0mRq+4AkLaq53mHrfFDlXUiUQhuMjffYP8KoksgtaCoqOW3XFpLt3lpxosX 4876k1lwPhJ8Q== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:25 +0200 Subject: [PATCH net 07/14] mptcp: pm: remove mptcp_pm_remove_subflow() Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-7-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=4749; i=matttbe@kernel.org; h=from:subject:message-id; bh=BTC1VqrgypC0zR0a/DPftpsfqKtSqKmahpvHDAKQMXg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTcaXMICC6/6mJo75ZmAFgQEYtPhgQL8oxd sRt5BZq67OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg c8OhD/wNmNTAqUfXbPxULsX9+aAdPC7QnqNsXRZBZc0mzpww/ik5tRr1fKvRJ/FD2iNeN81kRbA GCYleKQcNjv9faivL9gnJtMdRRSlSc15I7wiapBakzUXwrgoNHi+G3ecBSyH13on0/CznrMJ2fl Zgn45vY274IH5948XPxQ8pPrRXbYUgMkvpPivh9Mi161I17djdD64tagedzyDhMeDra3HLj+hfG SHYsvfliMI3x6Ah2nsmPRSZ2gGHYoruWDSTlmVuj8erMFfQJXbRA4BjugZYz4KUS5l+nf7rGH8W oYGlANkAOkIr8HOFkmUkJYW+wRrzQQ8n7wR0TDxhQO0zf8ri+s7OzFxddU4K2otgH53Fut3Rgx0 8v3nl2TWo2mMUEhjmkMCvWpE+BJd5ftuqs1/GxNKdBYCnTnNnIx5DdP6ohAG+eubtcpX/qVKdI0 9WRC8oIZFQUxSh3qHqVLS9+tC6KUQrm8AQ7KqHomq2Fb3U1nqWztIyY590fq5dBXkYkQDlGaz+V q5TdNvFvX3+XfBAE426KIcehpoHh7JRJBA12nN7Ywf8Sewcay+KWYWVL2j3SMrA+xpoTZ4xeic8 G9eb0XKGvHai9+jVvvB762hB+yt/buUt97kSouHPlauWY8XepuemWSwNQ5dp6/UCajP3mQGouHk /I6tw8UD64R4DXw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This helper is confusing. It is in pm.c, but it is specific to the in-kernel PM and it cannot be used by the userspace one. Also, it simply calls one in-kernel specific function with the PM lock, while the similar mptcp_pm_remove_addr() helper requires the PM lock. What's left is the pr_debug(), which is not that useful, because a similar one is present in the only function called by this helper: mptcp_pm_nl_rm_subflow_received() After these modifications, this helper can be marked as 'static', and the lock can be taken only once in mptcp_pm_flush_addrs_and_subflows(). Note that it is not a bug fix, but it will help backporting the following commits. Fixes: 0ee4261a3681 ("mptcp: implement mptcp_pm_remove_subflow") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 10 ---------- net/mptcp/pm_netlink.c | 16 +++++++--------- net/mptcp/protocol.h | 3 --- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 23bb89c94e90..925123e99889 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -60,16 +60,6 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ return 0; } -int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list) -{ - pr_debug("msk=%p, rm_list_nr=%d", msk, rm_list->nr); - - spin_lock_bh(&msk->pm.lock); - mptcp_pm_nl_rm_subflow_received(msk, rm_list); - spin_unlock_bh(&msk->pm.lock); - return 0; -} - /* path manager event handlers */ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 2c26696b820e..44fc1c5959ac 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -857,8 +857,8 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) mptcp_pm_nl_rm_addr_or_subflow(msk, &msk->pm.rm_list_rx, MPTCP_MIB_RMADDR); } -void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, - const struct mptcp_rm_list *rm_list) +static void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, + const struct mptcp_rm_list *rm_list) { mptcp_pm_nl_rm_addr_or_subflow(msk, rm_list, MPTCP_MIB_RMSUBFLOW); } @@ -1471,7 +1471,9 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); if (remove_subflow) { - mptcp_pm_remove_subflow(msk, &list); + spin_lock_bh(&msk->pm.lock); + mptcp_pm_nl_rm_subflow_received(msk, &list); + spin_unlock_bh(&msk->pm.lock); } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { /* If the subflow has been used, but now closed */ spin_lock_bh(&msk->pm.lock); @@ -1617,18 +1619,14 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, alist.ids[alist.nr++] = entry->addr.id; } + spin_lock_bh(&msk->pm.lock); if (alist.nr) { - spin_lock_bh(&msk->pm.lock); msk->pm.add_addr_signaled -= alist.nr; mptcp_pm_remove_addr(msk, &alist); - spin_unlock_bh(&msk->pm.lock); } - if (slist.nr) - mptcp_pm_remove_subflow(msk, &slist); - + mptcp_pm_nl_rm_subflow_received(msk, &slist); /* Reset counters: maybe some subflows have been removed before */ - spin_lock_bh(&msk->pm.lock); bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); msk->pm.local_addr_used = 0; spin_unlock_bh(&msk->pm.lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 60c6b073d65f..a1c1b0ff1ce1 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1026,7 +1026,6 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool echo); int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); -int mptcp_pm_remove_subflow(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_free_local_addr_list(struct mptcp_sock *msk); @@ -1133,8 +1132,6 @@ static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflo void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); -void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, - const struct mptcp_rm_list *rm_list); unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk); From patchwork Mon Aug 19 19:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768904 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 2A1261E4F19; Mon, 19 Aug 2024 19:45:51 +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=1724096751; cv=none; b=BxsNFTXodo3r2G8hUsQJDcM3d8XE/WYc7u8fQqTE2rnqF/9cVfYO7kNkeaB/epm1a4q9M6G9AkbJSe1fqvXHA+nPGOIDHiNKwZscIh0hlX/dAsXhr4iyiJXvl9Wwa71BSi5paa+k6d7OMeNC/Aw53MiQ8vOAVOGnGFhKHmN38UY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096751; c=relaxed/simple; bh=G/T4Zoev04V5Byavsl//HLV2kTVTfPniskd8/ZHW86Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qjjb5JbZZtFwk8qI0hCOaOQVBThZPxGgSGlVvSCsKl+NujPiS58ZTiWb2oHJpQt4ik3ieioww3Q5VzaXHB5vpcI4mtKE5BYKuki4s1VXNUfSlVJhXCFBqPgwnAK4AQ7jgz2g6PMyGAc4zGd4nAzPTlNAmFndb0LiH5Euk3/wMos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q0uqG0m0; 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="Q0uqG0m0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62B67C4AF12; Mon, 19 Aug 2024 19:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096751; bh=G/T4Zoev04V5Byavsl//HLV2kTVTfPniskd8/ZHW86Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Q0uqG0m0IUpNhyG929qvup+lc9FVQEs0VSCyCrtEIiXaP7n3Z3Z0lUnfgmjEMk+G5 88OuAprl0PtLPEwIc5WMB2Kuhb4d0/xPNLGEqUOq0dcaDNv2qM5zm33IbMMO0PuzVL h2220jWC2x+ZEVhDI+inXQ2ap+Rqw9DxlYibO67o/mgLiEPWwdSUxd2JL+9AqGDGzV VeppmhbkRznZUnOcuQuBgYknVGfp2VxoskPiOoXRnfbNfkz/ltgWsnvn1vNlZT9N6T 8NLsq9iMcNA7emchFSLEaNqdiQeEUhzStlt3u75qA4BPMKfGCe0l5zLbylFU5pMvTC tH1P9oMTZANKg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:26 +0200 Subject: [PATCH net 08/14] mptcp: pm: only mark 'subflow' endp as available Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-8-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=4100; i=matttbe@kernel.org; h=from:subject:message-id; bh=G/T4Zoev04V5Byavsl//HLV2kTVTfPniskd8/ZHW86Q=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTkO3PlNozNZFdOi1GAiidS4XawGoebuqLt j9wB2mCnqiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg c8F/D/oDlBGFJ2DnRGImot1TksWV42Jc8J25ZO1xBnsr0sK/sQ4F7QpwPIs1yEKplmlAchoeor5 D/67BAWq6mFINfaHee1V6AxSzgcYOXK7HmgNCk4SQs9YQF2foJfCpCobAOreZg/B8vmhB5+9oen JZSGdFfMJJpvPzu655m5t6Ws0JucOhGHXxYp5HcI3FcIkI/iA0u6k5A+cv7GFbxlkg16ytC3tMJ 2fbJeIk5s/FM/bbHYIlgU3H+ym6xgZxQwjK8JrTSBdYml0U+npSRaqQ4NWk/OuRcfzng8yAjD68 KUyGYURdmIgZ+d0zAx9nNGtUQ8JjhCLxNR6Wc0yyE5CPDtiw3Cu+DZizJS6rNQiRjpTrDbRk+TR 7+x4XZv9B8usjzDvsNAeQGYw1LNMZl0kqZknO44k6kA759popa+YSZezchG7ajbabfc6YuaCXZK xF7UE1ef2q4Iqlrgk3W4am5MTt+7h00JI1zZIva+wVJLgR9g/iMVBtQZjCexhtshHXOXYqPl7kD MEudqCfJ2X0IDMhKzfWf78EwUeHgG8Tj2WF2Nm0qyh/JaBEj0wSlHeQMO5v/fW49vY9uEAn6Ctm qKvcoAA3/e0gQrquSzvmjA0mSco5nu2VKf9sQb03lEKEbdfuL3B2t0c97SSr9lCXTfoxOyMJnBX ogm6aSGiV1smlOA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Adding the following warning ... WARN_ON_ONCE(msk->pm.local_addr_used == 0) ... before decrementing the local_addr_used counter helped to find a bug when running the "remove single address" subtest from the mptcp_join.sh selftests. Removing a 'signal' endpoint will trigger the removal of all subflows linked to this endpoint via mptcp_pm_nl_rm_addr_or_subflow() with rm_type == MPTCP_MIB_RMSUBFLOW. This will decrement the local_addr_used counter, which is wrong in this case because this counter is linked to 'subflow' endpoints, and here it is a 'signal' endpoint that is being removed. Now, the counter is decremented, only if the ID is being used outside of mptcp_pm_nl_rm_addr_or_subflow(), only for 'subflow' endpoints, and if the ID is not 0 -- local_addr_used is not taking into account these ones. This marking of the ID as being available, and the decrement is done no matter if a subflow using this ID is currently available, because the subflow could have been closed before. Fixes: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 44fc1c5959ac..4cf7cc851f80 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -833,10 +833,10 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMSUBFLOW) __MPTCP_INC_STATS(sock_net(sk), rm_type); } - if (rm_type == MPTCP_MIB_RMSUBFLOW) - __set_bit(rm_id ? rm_id : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap); - else if (rm_type == MPTCP_MIB_RMADDR) + + if (rm_type == MPTCP_MIB_RMADDR) __MPTCP_INC_STATS(sock_net(sk), rm_type); + if (!removed) continue; @@ -846,8 +846,6 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMADDR) { msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); - } else if (rm_type == MPTCP_MIB_RMSUBFLOW) { - msk->pm.local_addr_used--; } } } @@ -1441,6 +1439,14 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, return ret; } +static void __mark_subflow_endp_available(struct mptcp_sock *msk, u8 id) +{ + /* If it was marked as used, and not ID 0, decrement local_addr_used */ + if (!__test_and_set_bit(id ? : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap) && + id && !WARN_ON_ONCE(msk->pm.local_addr_used == 0)) + msk->pm.local_addr_used--; +} + static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, const struct mptcp_pm_addr_entry *entry) { @@ -1474,11 +1480,11 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list); spin_unlock_bh(&msk->pm.lock); - } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { - /* If the subflow has been used, but now closed */ + } + + if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { spin_lock_bh(&msk->pm.lock); - if (!__test_and_set_bit(entry->addr.id, msk->pm.id_avail_bitmap)) - msk->pm.local_addr_used--; + __mark_subflow_endp_available(msk, list.ids[0]); spin_unlock_bh(&msk->pm.lock); } @@ -1516,6 +1522,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, spin_lock_bh(&msk->pm.lock); mptcp_pm_remove_addr(msk, &list); mptcp_pm_nl_rm_subflow_received(msk, &list); + __mark_subflow_endp_available(msk, 0); spin_unlock_bh(&msk->pm.lock); release_sock(sk); @@ -1917,6 +1924,7 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list); + __mark_subflow_endp_available(msk, list.ids[0]); mptcp_pm_create_subflow_or_signal_addr(msk); spin_unlock_bh(&msk->pm.lock); } From patchwork Mon Aug 19 19:45:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768905 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 57EC81E6749; Mon, 19 Aug 2024 19:45:55 +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=1724096755; cv=none; b=fzTc1mvjxedabqaZFAmaExy7ss01evdMj7/yiDioxR9YKH5vXt1cAxxOCqMTBt1+pKXfimDgosH5wy8aIKgxkePV/kRWcdf/G+sfTPoZ1H8k0KaSax9c+RNP4ppV+KGF+47hJ7PnbpHgxqAd8puTKbIb2hL3DmqVZPQVPR3MMio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096755; c=relaxed/simple; bh=qns9EsRn0eYFNDNl9ZViOIXU6X/zqUvUuU8EAStohW0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jl1W9YlIE+n7Q/v7gbAg/nlTDaQybzKzev0W7ghhpiQnadwOfTosVCUsG0nxwuZClkWXPXAKwKGnbki8820+EvWDa+eM8RCo04RQIZweTqBmNhYEDkg4CwJg6v5hpEM8EUhcFfl9NT5f1qKtPZyvtL9Pjnj2Eb7GCCFpyFlPXwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R5Lpib6e; 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="R5Lpib6e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D206FC4AF0E; Mon, 19 Aug 2024 19:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096754; bh=qns9EsRn0eYFNDNl9ZViOIXU6X/zqUvUuU8EAStohW0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R5Lpib6exheZvA/Szqxx+7YzFdm9H+vPYBMysQWvj0MNISyLG/55E/ZzOg9ZZTaML fnvGGEH3a8b1D24XotVfvJkw/59KenvV+nTNvKxZMZsx4OdUNCE7U2WoOFGYqg7xeM ShEomPMYUbrfAfZHOQAuOyu0rznaaajaRGgb/EsKoi2bGftanfA3RBNHeQjFhGI761 gtZKQk4qakPptB3WeXZLiVPkLjtdL5lqQVAU5LU1AwUR3rN4UqZ6aNqCxmZhZ+z9PT mQYLvgSA+09Aknqa/VkXVBvGi4YHp3Iw9Q03ZSjLcKVWOabQO01UQzdF+mNFWbtUoH wkrJ2ETzd6Emg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:27 +0200 Subject: [PATCH net 09/14] mptcp: pm: only decrement add_addr_accepted for MPJ req Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-9-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=2040; i=matttbe@kernel.org; h=from:subject:message-id; bh=qns9EsRn0eYFNDNl9ZViOIXU6X/zqUvUuU8EAStohW0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTQJwOL+kc5QuppdYEwBVbEF/O6w5cNCyOR GfAFuoo/deJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg cwZpEAC8q27zWOJ9e6lzPmZZV75sH7q3anAxuVGQIudHI87P0FFTYgSvqaj3l/dzzmRNpL+/dsy 4ZW8TtM2zjO4Lf8CXvE1ZNttrzwzj4ORBbV387vAOJYny8IdgbaouG4AoNezVq4m74lX38hL8Ap R0R99etVmptlGRTlDEWRW/L6W5MJAeC6VhCm/QPWeXsCuO28kV/LZAk3RoX9F4u4LHKyYt8WfHf stG9v6b8RX0D5ssrZzeJdDcveCT8k0d8sUg0Q8pUE46qKfHKE8fSuW+Yeh2lvxXbUtic2VGLk8A 9O+k1PvHT3uuh5kKBkcSFkveYZubQc8U60Pd4lqTlIG7dH9cebxdtmWEBhoZx4kmP5oWZaviqeI Ke4HN3X4BIBTemIBNAuCtCnb5vOl5mOKXdhYfamJ3LpR2B26uD/+7PJYBUzgjkMCNOjB52wUY1i dt1dDo9D8gpekWtNNfvEaro5ryUJxAlduF2bUa80lc5ESEL6YgYJDDoFQlo10CwvOFLTsmQj/Ov xzonERGvZeWjO/jFZp+Wzpf/ls1HMc+UqMFwRfN6uMBzrDj1hgSqxxlq6jLgsPzhodH871BLHak ftTWZUF3iUEZYJmVSqcJ4e1yp9u8BUQAlPzF5RHw4mop8SEvwHxlpE/pe81wn++7tQPv1RfijJi FuXHp/hWk1vuUxg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Adding the following warning ... WARN_ON_ONCE(msk->pm.add_addr_accepted == 0) ... before decrementing the add_addr_accepted counter helped to find a bug when running the "remove single subflow" subtest from the mptcp_join.sh selftest. Removing a 'subflow' endpoint will first trigger a RM_ADDR, then the subflow closure. Before this patch, and upon the reception of the RM_ADDR, the other peer will then try to decrement this add_addr_accepted. That's not correct because the attached subflows have not been created upon the reception of an ADD_ADDR. A way to solve that is to decrement the counter only if the attached subflow was an MP_JOIN to a remote id that was not 0, and initiated by the host receiving the RM_ADDR. Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4cf7cc851f80..882781571c7b 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -829,7 +829,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); - removed = true; + removed |= subflow->request_join; if (rm_type == MPTCP_MIB_RMSUBFLOW) __MPTCP_INC_STATS(sock_net(sk), rm_type); } @@ -843,7 +843,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (!mptcp_pm_is_kernel(msk)) continue; - if (rm_type == MPTCP_MIB_RMADDR) { + if (rm_type == MPTCP_MIB_RMADDR && rm_id && + !WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) { + /* Note: if the subflow has been closed before, this + * add_addr_accepted counter will not be decremented. + */ msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); } From patchwork Mon Aug 19 19:45:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768906 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 0C4801E7A38; Mon, 19 Aug 2024 19:45:58 +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=1724096758; cv=none; b=mL+wPOMytjZEGLjeEmQl4H22TRbpybeTrx73TOmYBwaXE2KbhJ7gxMrkHKHHIvOYe0cScdRd1982nEphIAicJYtYcnyjcH80VBXVcqltWizUrGM1hEWklljljNizi2jbxoCYxQnwoLGeVvWhKIauBmzrn1iACS9NXjxDRWri7F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096758; c=relaxed/simple; bh=yEteMQbd0AFftgasQN6K+OTvQe0Z4B72FbeaZORBvFs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qcB7n5Qmn0+CifMr7Y/yzPgndx38ViDKHrvGJT3FFzx0fLqyAglBDXRY9KNddemi3boQhSSsldzrpM27ZObCUIjfi8HfWplDyvSZoP05I1lES1FU+VXv6PsfRWIlBsNef3BERs6ylz9QmEXMaOQ7WJI6sMCkPw1N9BNJ8lKSV6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J0ciMDys; 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="J0ciMDys" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F646C32782; Mon, 19 Aug 2024 19:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096757; bh=yEteMQbd0AFftgasQN6K+OTvQe0Z4B72FbeaZORBvFs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=J0ciMDysvbQR+a9+M0I3wM6Ispdo+Q0v63FrVK8oMaq4/TdXD9kNVgLaATlpdeaBZ Z6aA/T4MTS+jPTPEECmNQqfuZtNh25IXWBWKOvS12vypoO80wJkuFfa7sggS8jOJEe /MdYpPVpHNOU7qviOUk6mpyogZZnJNL9Ic1uKPs4wH94sUjJ/I1YFHb95jX473FHFX 5BT0rj5HCItzGbipQKmXicg9/qFbsk9+NDqGrmAVnMoxNYKj1sJk0M2wXB4n7ghD83 1BX9kuqWelXyl3+bTAmSWFSf9Y5oUp5u52MYCKfWbe73S149qSJX2EX/zcs+F1wjYY tz7WEKt1nVpAg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:28 +0200 Subject: [PATCH net 10/14] mptcp: pm: check add_addr_accept_max before accepting new ADD_ADDR Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-10-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1005; i=matttbe@kernel.org; h=from:subject:message-id; bh=yEteMQbd0AFftgasQN6K+OTvQe0Z4B72FbeaZORBvFs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DT3vD+a7kz9eBUW+PvukII7bPCcvqXbqucv aiQofBA7UOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg c8D2D/0RJTdJj4k3esNFhAJ5q1nUr1TXXiUfTkUHg7oeCS7ThtU9UYH6plGDRR2xUjm8TY75P6A OdlTeov0s/8/ZUgzpSNBJlk57OOQZHdlSbX1Ct8X/UrRi4krkAX+0EVdmkRpkUx2JKfJs35waaO 97vQCkFxE7cN6QKWp3whhtw7JI8xxhcomUf05E66XhD8JsurexqAHNPF72Q+dQKbc6y9H86yw3m LME9LUlDQyW1xFjGm9dvyJ/rC7Hb5Qlzqxv/EU3nqxWMq401US3qxPyAldHOE7oNXuKLfjcnMyu JESokLsM56arDGiS+mDr3GweCqbXy5nnmCQwLpsXtRbkFCB7fivgQYcywu9hJy1EYRjgu5n/+0i 5ABrvr2/epMUIg1Rk0MmDepeDcFScitphdfYJ4y1MLPE6wQf4uimTj3SDz353AZM6F1XEI/QCJd nUmK4BwaK+Bz/YHdgH3rRt1tq9+a5JnkvmeOEqBVYKKOBZmlySEWh6fdnOQkKcxaoaDjYy/ssGw D7ssZOPI39kxyjly1WeZ8GBdrFe9Q867JmEszn6LesaQBEQkK9ofAKZdLf6x80+iPHp8qLKnESJ mqaOwA4O7a3zSa/ytZfgy3OPPdRS/EbSBsK1hC25ZXNGK/3mkYZsT5NCThtKxY4RZM5U9CpCTMI IXkEAPTeMSGXrlA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The limits might have changed in between, it is best to check them before accepting new ADD_ADDR. Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 882781571c7b..28a9a3726146 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -848,8 +848,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, /* Note: if the subflow has been closed before, this * add_addr_accepted counter will not be decremented. */ - msk->pm.add_addr_accepted--; - WRITE_ONCE(msk->pm.accept_addr, true); + if (--msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk)) + WRITE_ONCE(msk->pm.accept_addr, true); } } } From patchwork Mon Aug 19 19:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768907 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 7A3A01E7A38; Mon, 19 Aug 2024 19:46: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=1724096761; cv=none; b=C+qlhIt3HeGlx25aa05HatDsuEg682Qmy6bi5CeYssmOsYCMT0XgtpvDNQU4c7a8U6ZjiqAqqCZ9eN1M1RU/x+zOmpnBUlE+ivPOccuyPFSi+UDrbmImCSvxKyedXcTANbW9zjbYsY+AiSZ8PmA94WGDTIrZ+rMq9fyo2kCWQtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096761; c=relaxed/simple; bh=cGNoHeKCL947W/uprD2LBcdAoCIR32Kpd7CBuyKk0Gs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iW1y6dG50581m702fWM9P2i/J60K/nsjk1DAk9UOuFZTkAAYxuAZXXhIoo1XaI4TURgfVtlcWqcg+ygfrAfJerNKjAHRKwlf0LGY1YpQ5A0JrPrxAJV/j33PdbvvtRvV1WnAZKJ7/dIrL/XbDDEgBecYL9PZHQKDxtdx2osHYQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nk/u0Q7T; 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="Nk/u0Q7T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EF67C4AF0F; Mon, 19 Aug 2024 19:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096761; bh=cGNoHeKCL947W/uprD2LBcdAoCIR32Kpd7CBuyKk0Gs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Nk/u0Q7TccGtR5CCzjRorD/knBnspGFwuNq8O5QjIHWwJi0Ashae7LDwWTEgvWJJP cN60l3IYfw5HVHPsqb1sLw75m3/GrUIcCdHtZerYQIizZU7QO8mVGIF3KesjwUN20X ccxgr4Ry85nYp4dDrm+Gfrnnl5jAu9l7P0EHXZ1jonfvwAvbXip7jKwf2oMH8xDvYH i9StbX3PeQbwi9mDAZKAarVrcZDfjACoPYHD5TGDi3Y4jCLuzkLHnFkxPRZ1Z9kI60 ZNkkrCr1UuFG6YCmqtfuZ6gJxgdw04fs5Vt4UnA8SIexZUnYNKka1hyAxQu6vFPDvq 8dQYI4nfuNSBQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:29 +0200 Subject: [PATCH net 11/14] mptcp: pm: only in-kernel cannot have entries with ID 0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-11-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1617; i=matttbe@kernel.org; h=from:subject:message-id; bh=cGNoHeKCL947W/uprD2LBcdAoCIR32Kpd7CBuyKk0Gs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTUkcdqxZnODu3Vv0DrmcnJaoahmvFbSqwN wK4PvfRrt2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg c1JeD/9skMtucjpTfEljtH44u9stOu8n73vTjg0yrYWdlW4r0vo50/2ZyiY5m66pF83qUZtkPHx /mGH2eKbECwAPInlRkpoBAFsyToL0Tr8VcA4hhZF18HlIUuLMxKbMnQIWfs/VClOhhg0xCNfVx7 9sgjOn/eGhk+Z/oIrN1YAI+ghKnv0lmz23mWvcG+7WKTvXk5TnGUdf5NN+ahZ3PBTIyhR59Yz2K WT/lcWVh2VvkNUAMLxK2Iu0F58S6uuzEc4boBC9MQxRkv21p/T98+f+6eYvahPx2DcznrY54oCP 9uC/EHJdLy2Troqy/UQSl3N70xjBUpk7BGg5+MTWpLtNKiaDXTwAxxv5lBR7LXa3504raiPDgUf rpHO3JjsvujOpmmEw4/7mpy9JDnLr9qdKgrHNArFkBkjKvQWj3i8qY8yTWhwflwrpd65UMtTQBG GtDV/rVFB+x/G37vYCLyAhe/nZDG3SReMYtrYHPCOKSlXAIo/zK3huQfZ+UuaWNCQB3s/h+5MiO IcTm+hv5OQFJG5rvdUi72zccM+dXmv21A8nob0O+v52RJk5zzsJpg2ziGYq62vZqBYYWY7tgfDr BKYJIjwGr+TfUiTyIArJPO2siUPaGGoqQCvs2EJ2QY5V1SeL40HZb508ac9cK/J55LND6NbCm8e uTofLnTYt8axPNg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The ID 0 is specific per MPTCP connections. The per netns entries cannot have this special ID 0 then. But that's different for the userspace PM where the entries are per connection, they can then use this special ID 0. Fixes: f40be0db0b76 ("mptcp: unify pm get_flags_and_ifindex_by_id") Cc: stable@vger.kernel.org Acked-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 3 --- net/mptcp/pm_netlink.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 925123e99889..3e6e0f5510bb 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,9 +434,6 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id *flags = 0; *ifindex = 0; - if (!id) - return 0; - if (mptcp_pm_is_userspace(msk)) return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 28a9a3726146..d0a80f537fc3 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1395,6 +1395,10 @@ int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int struct sock *sk = (struct sock *)msk; struct net *net = sock_net(sk); + /* No entries with ID 0 */ + if (id == 0) + return 0; + rcu_read_lock(); entry = __lookup_addr_by_id(pm_nl_get_pernet(net), id); if (entry) { From patchwork Mon Aug 19 19:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768908 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 78A591EB4AE; Mon, 19 Aug 2024 19:46: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=1724096764; cv=none; b=FL+fALye2jBCT15nb2kLPIX/Bza5coavWplNmvQeobFzQftfHFcAaOUMNiYuJUgIZItA/atzuApyMwrHn8zhruZXZYLGYSjPnA9QygtjoNi2GDOWLDIDO99tB1mo+2CJuX5NiH/ffSHU3AXrO4639IODSVg8vv5Nno4lnL4vlkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096764; c=relaxed/simple; bh=l4iKnwGhhsDMn8htcpUOxdszoLQDZFdyQCl5kbQWUFE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jxGBNFS9XsqIsKVKKgnoBfLTjR7C6tpOqwJ1xZV+GZMv/q2EzyDX53tWuN+rlr3fux9+lAdyw95+foDIgAJDdnUuBAglHLcb04LAgZLU3wvYErKWDz2yQZ8jxOVIIJ6TyiB6EBWKtOaXYUI40Hb5wZG0P90mSqDw4wgJn052lXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lgPcAxw3; 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="lgPcAxw3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 739FEC4AF11; Mon, 19 Aug 2024 19:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096764; bh=l4iKnwGhhsDMn8htcpUOxdszoLQDZFdyQCl5kbQWUFE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lgPcAxw3qoCSAzYT24ZvnovIOK7wNktRjNcYEr6O+mDcOln7NF1hKHrSQDtIp+dwl 3cJ9m0aZJMf91718UrILuF1ghKyFcMlavOQ7cWCVv0r0QSGaZnTjaw3CZUGHlZAAFL q+G7oex+h7fvFVJDx6VC8a1W11IB2keuyUJEoZ8B2ACiXvcsrJkf0CZ0uwgVLWAR/e 6VfJXeidO8TYvGCubFH5wFhD6hl+rzYNjnIZYmyLLeWV0EUZP5MuX5exPfOqL/zDia M9Xx4ElPO03DlYu74LkZuB/gbiG9LQr9AJSvHGGo8ngjyXHTdqRnqP8vg+FIBd9Pk0 Nw6U3fvEe3osg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:30 +0200 Subject: [PATCH net 12/14] mptcp: pm: fullmesh: select the right ID later Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-12-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=2018; i=matttbe@kernel.org; h=from:subject:message-id; bh=l4iKnwGhhsDMn8htcpUOxdszoLQDZFdyQCl5kbQWUFE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTY162plzd1LsvGwrZ1VIf7yOI1Ub0FAQko GMRiHAOlraJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg cwivD/9imuKIhyv87CMIvPd+ZTZu8rB3zJaltXFudDU2tkC2/QfIMGzSOsJdzGUQvCn1C+uFeWv YSbKujUdFSYZ4Detq6YhvYtbnES3i2EFIjiATjsiADNhKO72RhSdCkb6OnqDhv+R+X5jJckxyog YhbIcKb8MxYuypnb05wnUuT/X5sm0lUdSadkRxIWJLQS/Ezw90fIquUd9E/MNNWLi5d6+fiJooN V3nTD79OKs/my1351dTZJ8T19HUlDa5CicuX1De36r+uKshc+cxSGba/cMOyq3CqFJlI6lfeC2H 1d4C0vx19NmQVakU3mWwMADCrhmOW9zO6Cus9SD2izriGS3Xol5SKmgIdZlrmKVZkseErzw+zKt MMQmaKc5Jj4iYnB3gKCtbFM810ybC4omX1kLo5xq1ixLs4inQPHLCHwWVe61tzj6JP8+qTaligd tUKmXUEi5v6yOzoNfC2gyWPF7ZrGoYs/Lyx89hW/Y7nC/jud4R/F/ytcNx3fLW2O2c6XvcLN6ds zVXsnVJvIPcbvxox7budfV5ZnacC9UB2RiYVq0VScUteDJ8GWf1mi58BZ0UnytHpVs4i3vucjkJ OONZlagAZx615TyotjUtF7JWgDt2NwQaD1PDxL8Pyl7Um33D2NPF4U0NWnJlz08w49tuOWcNgMB BKQUQQBo67Ibjuw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When reacting upon the reception of an ADD_ADDR, the in-kernel PM first looks for fullmesh endpoints. If there are some, it will pick them, using their entry ID. It should set the ID 0 when using the endpoint corresponding to the initial subflow, it is a special case imposed by the MPTCP specs. Note that msk->mpc_endpoint_id might not be set when receiving the first ADD_ADDR from the server. So better to compare the addresses. Fixes: 1a0d6136c5f0 ("mptcp: local addresses fullmesh") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d0a80f537fc3..a2e37ab1c40f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -636,6 +636,7 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, { struct sock *sk = (struct sock *)msk; struct mptcp_pm_addr_entry *entry; + struct mptcp_addr_info mpc_addr; struct pm_nl_pernet *pernet; unsigned int subflows_max; int i = 0; @@ -643,6 +644,8 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, pernet = pm_nl_get_pernet_from_msk(msk); subflows_max = mptcp_pm_get_subflows_max(msk); + mptcp_local_address((struct sock_common *)msk, &mpc_addr); + rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { if (!(entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH)) @@ -653,7 +656,13 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, if (msk->pm.subflows < subflows_max) { msk->pm.subflows++; - addrs[i++] = entry->addr; + addrs[i] = entry->addr; + + /* Special case for ID0: set the correct ID */ + if (mptcp_addresses_equal(&entry->addr, &mpc_addr, entry->addr.port)) + addrs[i].id = 0; + + i++; } } rcu_read_unlock(); From patchwork Mon Aug 19 19:45:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768909 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 A3BF620010F; Mon, 19 Aug 2024 19:46:07 +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=1724096767; cv=none; b=COjzbfeHLQ6l0sv8EZAS+whjb+0uw6QoNMT445KpDssG2416G9wGCaAyThSTdsvJRGTTEioO+DFaCHinKVISdBooS2vpDUtCQDQMT2NOimeIJUsVEaJJf47yJhbLAy2AXGWH/vxHtOzTwjZbzbRKtoi0CU25KKoa2DopwD1YHsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096767; c=relaxed/simple; bh=Jx+YWM0xAm1SJYDNQ2FKQR/nOU1ci/rJbdfBM/eYfVY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NEc6NBnGB8WM6DEqSEelpFrI5FPTP29oydSmBV8bTbYIicYPtZ/K2E4cpM6hGj63HBhnTx6Iyo9pB5t/Oo+oaRjQ8OyPFKbvLkjOgggPyztDMiLfz3dQyURc+31RuKnOt1eJEZj0vDmCTiZedH9nj3iYu0CFJYhn2dpREsmSSIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sxOZdpbP; 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="sxOZdpbP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8161CC32782; Mon, 19 Aug 2024 19:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096767; bh=Jx+YWM0xAm1SJYDNQ2FKQR/nOU1ci/rJbdfBM/eYfVY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sxOZdpbPTfOho14Lob8dME9KnFExsvsRzuI3FonckSwAoW/LwRl8T86cXWwSREbFu mNcGuYEx39u7BY/fprpbLvX8S+RcEDNCB0Nr8zYdpluScTQV7Kkbf9VESzyWmXITsy kblwizI63AKguRvsKpZTHtdP/PIiC1msrcm8x5i6FRW+udU0c31tWXaSfiwbA+LBvu OSiAyZxP67nWOB3o4rESJB2zHSVD4GMusWdEVEtv39GOk/iIH61nuvLurOpwXNfuKJ hNOdCGgcnutdjJyb5BP97z9dQD3OCVYvcV+P5YfsBbB39x9ZFmX/Aff8r6gCUQmzeJ 9skxpzWf+yWlg== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:31 +0200 Subject: [PATCH net 13/14] selftests: mptcp: join: validate fullmesh endp on 1st sf Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-13-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=1261; i=matttbe@kernel.org; h=from:subject:message-id; bh=Jx+YWM0xAm1SJYDNQ2FKQR/nOU1ci/rJbdfBM/eYfVY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmw6DTJVOVB9sJ8kjZ0OocKVD7U8C9JFMxKOk3o wg+S3L7BZaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZsOg0wAKCRD2t4JPQmmg cympEAC5jUlrqyf5A8ym+tGS+wfj7itFGEUzkqyrl4306G0MTE1YzDRS1+QrrvXnnwLFcLgZrnI pr3NXoiyy4N13R+GqC5Bzg5y/IAXiEvWl1VZlQ0I9/uKBY7hshS0BtLmHb8jjQmxQwGyj02qd+s Xd3a76lJOXSd/KNXQ1XBKvDN07rLgRp+RgkbP6PERymW60fJsi/cr34G8MF/VgvLDz/QjErMqqx avRc7LTY/TatnkelF9yQDUn0wy3197DLQkFe/XafscbONHYW4A+0dcF5IiXo7i19oNunxyCbsx3 M+Rih/jtI83KEI385MAT16cq30TzlI3RW0VU3ZBEvSy2esk3xYA2uwolOd/R5fffZeI0lNQQZgB L0boCnpEZr5fj2qkNvfzABPaYo15OMM5i7IAw8a42PUvHRQJNjX0ncWQjZfWP6A8C1NyZGUz/Y5 O6Oc9y3OQ1Vd2LPY7xkxqx6duQGqY4ziXt0q8A9hL7HO7DWv9sswVirY5Rzv+LTJ1HCUWxPuoQn 4w9FiVK0uBu51L0qW3rcVn1vD29Qm8UkgoSabSPUh1gJjQVC8Mu6iillu3TRMkE6UY5c6J2ApEl fo0mRBwk0ehbiGhawNpxhm/5a+ptJkv+Q5vu3zRYFVTiLabmvKY+0w2lmdsTeu5BjzmJQeJjTzc vaw0VRvvcQf/aKQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This case was not covered, and the wrong ID was set before the previous commit. The rest is not modified, it is just that it will increase the code coverage. The right address ID can be verified by looking at the packet traces. We could automate that using Netfilter with some cBPF code for example, but that's always a bit cryptic. Packetdrill seems better fitted for that. Fixes: 4f49d63352da ("selftests: mptcp: add fullmesh testcases") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index f609c02c6123..89e553e0e0c2 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3059,6 +3059,7 @@ fullmesh_tests() pm_nl_set_limits $ns1 1 3 pm_nl_set_limits $ns2 1 3 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,fullmesh fullmesh=1 speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 3 3 3 From patchwork Mon Aug 19 19:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13768910 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 559A020124E; Mon, 19 Aug 2024 19:46:10 +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=1724096770; cv=none; b=Kkdb+C30XorSwYU8zPG3o0he53eg2bfC6IpbsKFuXr6ef5GOuv8Y+ALE4l7flqfnAgSkT/jHoQwlT3YaR8XtUM6zklOINnJqAe0yznrA9Xrc27KqJqnInuJaQGpoV9/SF5QWm0DhbKpuurOYcWoDGXGpBWsbt/TdL1PCp24pFH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096770; c=relaxed/simple; bh=S/G3H+zWXhU4Ysa/76xvg601REXC5HLy4Uhd8tkcCIY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g78GsheATKD7Q7cIgk2XMX//ggrqaxnzLxUj0pfPZh8BLCeURvKB0/OdYfvlBErcfzodPvTwR3O2z2059Ld3gtNmv70TW8E0uMmRXXCHOuO97Q+RfFmwLAr6DYAIhTKTeYVlkBNYmzYv3WizrdI65AEyKzAOfhuu4CosME8zbcQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Te+T++sB; 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="Te+T++sB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 910A9C4AF13; Mon, 19 Aug 2024 19:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724096770; bh=S/G3H+zWXhU4Ysa/76xvg601REXC5HLy4Uhd8tkcCIY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Te+T++sBuBbkjdkdu+lo0RsreBVV1B0VE4LauCftSKVImsnXk+qHZ/ZW3W++kT1BE Jt09DP8+JS0okm1S1+FXCjfLAJ07wMJUlcSdKDfhZTKG0ZgdgLAw1Kjy6E0R9LInp5 j+RtlSUeaEvtimHfup4u6+xo8SQd5ehVhbwrEpER4y0g+pEd8yAllBDfisiwBSyDMr e+tFTIva7mH4v+dN+2z79sLrnHcSwGOyev82dwJ68T/3pjcU9VWRJdmSQC6Mejx4uf /PQzUKDsfSMpVRm5szAhrOa723shz2nuPHYzMVqjFutahtunt8m1gUrWu3hC8sWl6C wUCloFAs2VaJQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 19 Aug 2024 21:45:32 +0200 Subject: [PATCH net 14/14] mptcp: pm: avoid possible UaF when selecting endp Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-net-mptcp-pm-reusing-id-v1-14-38035d40de5b@kernel.org> References: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> In-Reply-To: <20240819-net-mptcp-pm-reusing-id-v1-0-38035d40de5b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan 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=5507; i=matttbe@kernel.org; h=from:subject:message-id; bh=S/G3H+zWXhU4Ysa/76xvg601REXC5HLy4Uhd8tkcCIY=; b=kA0DAAgB9reCT0JpoHMByyZiAGbDoNOjBCnpnGhGTWSMeyQztma46JXJb2M0L5L5ZU+o5onq/ okCMwQAAQgAHRYhBOjLhfdodwV6bif3eva3gk9CaaBzBQJmw6DTAAoJEPa3gk9CaaBzMbUP/A3d MfwJcEXPb1VeckKa35cNxanJVUG6ocURH8bqw1oDbR76hX7BYgcu2Chbd+FGwOGgeegCkOIlyXi 5J/a1cHkrYyFOTXy1AnhP8SqtHOzF+/NG1Wn1Rb+M0g4EIxry5ly2dEBN4WwcFHwt6/bNZ6IP/p q+4N7jY0VCNsgNLyCM+kv9E+bqGKN4GHz1h0pcYyGBcGd5+JFStu0EyZc/s/sy3tn/8Zpp2cZnh 8X4i52eV1lAEvmz4Cly6tkK27hipVDU7L5vcfxnsXi1Nk9tHtGS6XoEiqYiwHQJTx/nn1Zw7Vud 5q/+Q3IAb3D3J3lEB6ky/n0IVSPKDrR55mZs4Y+UVUUGAK1SNNtj+HTM0tLz6U7a0cYaQize84k Zaks5McUTgBoap1lqIPMBREC5y59Uu+43g7iGRQ6Q5+GXdGjOLJQQeMGiJ9BswTxMkxe+5cNE0+ 6eHJOpDVSpE3FdzMTUWbP/kXP+aOJtFZBD8GcjlL0WdY/Y8+NTt21SzPABKZEp9WH8qehFVcY3o tZbDo25HLD3udEFQlhAoC66KK5j6HRiSCLi74axmZQQP1lnyAQWvHTltQTGoQuEuvBM7UHri1mG WnNWPiYPDJhkc5wgSobo0QG1Z0W4gpRQ561pDKcHd9UY7nv+m9Plx5GUHYLGF+aBLWITzyngeL/ yhwAp X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 select_local_address() and select_signal_address() both select an endpoint entry from the list inside an RCU protected section, but return a reference to it, to be read later on. If the entry is dereferenced after the RCU unlock, reading info could cause a Use-after-Free. A simple solution is to copy the required info while inside the RCU protected section to avoid any risk of UaF later. The address ID might need to be modified later to handle the ID0 case later, so a copy seems OK to deal with. Reported-by: Paolo Abeni Closes: https://lore.kernel.org/45cd30d3-7710-491c-ae4d-a1368c00beb1@redhat.com Fixes: 01cacb00b35c ("mptcp: add netlink-based PM") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a2e37ab1c40f..3e4ad801786f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -143,11 +143,13 @@ static bool lookup_subflow_by_daddr(const struct list_head *list, return false; } -static struct mptcp_pm_addr_entry * +static bool select_local_address(const struct pm_nl_pernet *pernet, - const struct mptcp_sock *msk) + const struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *new_entry) { - struct mptcp_pm_addr_entry *entry, *ret = NULL; + struct mptcp_pm_addr_entry *entry; + bool found = false; msk_owned_by_me(msk); @@ -159,17 +161,21 @@ select_local_address(const struct pm_nl_pernet *pernet, if (!test_bit(entry->addr.id, msk->pm.id_avail_bitmap)) continue; - ret = entry; + *new_entry = *entry; + found = true; break; } rcu_read_unlock(); - return ret; + + return found; } -static struct mptcp_pm_addr_entry * -select_signal_address(struct pm_nl_pernet *pernet, const struct mptcp_sock *msk) +static bool +select_signal_address(struct pm_nl_pernet *pernet, const struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *new_entry) { - struct mptcp_pm_addr_entry *entry, *ret = NULL; + struct mptcp_pm_addr_entry *entry; + bool found = false; rcu_read_lock(); /* do not keep any additional per socket state, just signal @@ -184,11 +190,13 @@ select_signal_address(struct pm_nl_pernet *pernet, const struct mptcp_sock *msk) if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) continue; - ret = entry; + *new_entry = *entry; + found = true; break; } rcu_read_unlock(); - return ret; + + return found; } unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk) @@ -512,9 +520,10 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info) static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { - struct mptcp_pm_addr_entry *local, *signal_and_subflow = NULL; struct sock *sk = (struct sock *)msk; + struct mptcp_pm_addr_entry local; unsigned int add_addr_signal_max; + bool signal_and_subflow = false; unsigned int local_addr_max; struct pm_nl_pernet *pernet; unsigned int subflows_max; @@ -565,23 +574,22 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) if (msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_SIGNAL)) return; - local = select_signal_address(pernet, msk); - if (!local) + if (!select_signal_address(pernet, msk, &local)) goto subflow; /* If the alloc fails, we are on memory pressure, not worth * continuing, and trying to create subflows. */ - if (!mptcp_pm_alloc_anno_list(msk, &local->addr)) + if (!mptcp_pm_alloc_anno_list(msk, &local.addr)) return; - __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); + __clear_bit(local.addr.id, msk->pm.id_avail_bitmap); msk->pm.add_addr_signaled++; - mptcp_pm_announce_addr(msk, &local->addr, false); + mptcp_pm_announce_addr(msk, &local.addr, false); mptcp_pm_nl_addr_send_ack(msk); - if (local->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) - signal_and_subflow = local; + if (local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) + signal_and_subflow = true; } subflow: @@ -592,26 +600,22 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) bool fullmesh; int i, nr; - if (signal_and_subflow) { - local = signal_and_subflow; - signal_and_subflow = NULL; - } else { - local = select_local_address(pernet, msk); - if (!local) - break; - } + if (signal_and_subflow) + signal_and_subflow = false; + else if (!select_local_address(pernet, msk, &local)) + break; - fullmesh = !!(local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH); + fullmesh = !!(local.flags & MPTCP_PM_ADDR_FLAG_FULLMESH); msk->pm.local_addr_used++; - __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); - nr = fill_remote_addresses_vec(msk, &local->addr, fullmesh, addrs); + __clear_bit(local.addr.id, msk->pm.id_avail_bitmap); + nr = fill_remote_addresses_vec(msk, &local.addr, fullmesh, addrs); if (nr == 0) continue; spin_unlock_bh(&msk->pm.lock); for (i = 0; i < nr; i++) - __mptcp_subflow_connect(sk, &local->addr, &addrs[i]); + __mptcp_subflow_connect(sk, &local.addr, &addrs[i]); spin_lock_bh(&msk->pm.lock); } mptcp_pm_nl_check_work_pending(msk);