From patchwork Fri Feb 23 16:14:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775387 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 B1FF18526D; Fri, 23 Feb 2024 16:14:43 +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=1708704883; cv=none; b=SoWQ12fW1JvW/KWYLtfN1xXVTFFJ8QUXs3gLUEQHfbsjrQXgj/AUhavcIOj0dOlR+Gz7A9vAehvBjHT+56P1EIeycKAbkyJ4gPiu/VDdx6nio7FXy0ALJ5A/057wqxfoHmSEv9yZyZiCw/VnalTyg9luNhGg/Qb3zRLbx954h+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704883; c=relaxed/simple; bh=qISUZKplFPWYmLkdmI1gLlKsQvehUGqkZjUJuQ2PWWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qmuZECMDvROUniagG/prmT6jdeqlFsGDVgWLLo6XLGsBhtCTJKQsr7T0GlyvzSGnVlgZUQeAjcLzA1i4CNVaDdCJ+6LD5uxm8eMJzrFuW4pgFjBBS1DiQoG8NlrujJ65g45md+5GXPtsaFXm6YpNLtBpDZYLnPeKdFOf9WE4vl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lpKeJBT6; 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="lpKeJBT6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18BC4C43390; Fri, 23 Feb 2024 16:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704882; bh=qISUZKplFPWYmLkdmI1gLlKsQvehUGqkZjUJuQ2PWWc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lpKeJBT6k+vV5p9rMNOt9vObKqfXrazOQ431ipCowoLrfa7CVukqhilijvPWQG2xi jsg829/alLeqOm+3DN512ZTZKc5Krw8z3M6oZi2FooZrsYI96xOcqMaVwP9bAz3q0E XK/7MD5maKStTI6NYdA3QNuYWubUzrq8M0ghuLs7ah10bncZ2jSPEjdvwjVj5kAV5S PjMOEDj3ZfJXvcEnGEqV7da4mCF/wCQfICi1jgqNZcCDhclANSZ69HIqUzRWWnShTt AUHm2elH5ys0JycPnWbjxBQSIciq9qGtT/wpP1JjwH7noLfsCZUe0/btayU+H2Dgae EYMS2xyrJ74CQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:11 +0100 Subject: [PATCH net 01/10] mptcp: map v4 address to v6 when destroying subflow Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-1-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1870; i=matttbe@kernel.org; h=from:subject:message-id; bh=R+BQBUEWiM2ym//t1ZB6xXS8N8caCdeWbnoDwiPCfe4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqwKTdW3PskIYPe7YlyeUTOtATAmZlVGcwi 6E30zx0XAmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c+uED/9eaB4gK4ZdGVN/ncv+ZTHQGFKZc8N5XfdpyCBQ7NySR9oJDseOFt0HeXKHsP209jWimRf awMCdYlcq/LHrQEWj7VtM7FoTxN5ddBcncCUoocl8y2xdnlx4I8wnw4Qyj7dcEZAZaov4CIZPwh ufGDCMQ2Oxelnq6Q/04157J4I+pNLLw7Pcs29qG5LLvRgy9HoE/eMS1EiFT4tMxOYkIeaValWwx L05c4WmSzqvbv5djX0YS3oSjCzSyV2bKvE0AglN74c+2SwOWh8TDvpkRmdOfEhTcjYvTjA87UR1 hmfHBVdNxNq9gEXzO+lSPu2H6ZWSzHSOGyhzJOZVkRvzyt2nTXOrA2VLY5bSIj8fp3euwLHieV2 1QEumN/7GjmjfxoT3L7rCCAWK9TTD10H+e1Tc8fo+ilAU2igODZ2oJ+P2ypi5sX+Du/JqgcJLeC rA6LeKFMDDS1vKm540vUESZ5R17q+3+TPDG5FufdSiBcMVhgBctFpTaM+iLhNpyOjfqQuZlrCOy dy21Hsc/8kRzgUlbANDYv181i+GAMR+8a5SuP5dFrcFi4OoSCeXA2rRiPBmyxIqcW1G6WtRxYmb 0Zk5skwre+t3qr0Bb3wD/okVf06rybE1Vxc0JmnA9WBUWlstnUZLMGzZBmaZhOCZ+dkhQzNOFdP KMvH74pTCriQOjg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Address family of server side mismatches with that of client side, like in "userspace pm add & remove address" test: userspace_pm_add_addr $ns1 10.0.2.1 10 userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED That's because on the server side, the family is set to AF_INET6 and the v4 address is mapped in a v6 one. This patch fixes this issue. In mptcp_pm_nl_subflow_destroy_doit(), before checking local address family with remote address family, map an IPv4 address to an IPv6 address if the pair is a v4-mapped address. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/387 Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index d396a5973429..bc97cc30f013 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -495,6 +495,16 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info goto destroy_err; } +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + if (addr_l.family == AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) { + ipv6_addr_set_v4mapped(addr_l.addr.s_addr, &addr_l.addr6); + addr_l.family = AF_INET6; + } + if (addr_r.family == AF_INET && ipv6_addr_v4mapped(&addr_l.addr6)) { + ipv6_addr_set_v4mapped(addr_r.addr.s_addr, &addr_r.addr6); + addr_r.family = AF_INET6; + } +#endif if (addr_l.family != addr_r.family) { GENL_SET_ERR_MSG(info, "address families do not match"); err = -EINVAL; From patchwork Fri Feb 23 16:14:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775641 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 0E26485C53; Fri, 23 Feb 2024 16:14:46 +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=1708704887; cv=none; b=k0m7SrUUxNOw3DLY+9Hgk14Ceprr8baw646e8BSZo3uU/b6O7lCFb6Z7iBB7MJW6GsMecVO40G3lsbqJzsJl10sLlLazetqjfkVk8SWANOCD2QewiGoRIQYf90ERuLs11RMyHHNvYjqHg0Gp1f60q6ZcO6t9hDGhWqKd2cDm/jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704887; c=relaxed/simple; bh=ue5sQop1UX80N3Oly9X4CFXlH4jZY6ypbaPw8tp4MNk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dEgRYozT0Q88YIW4SNdC2a5Vp712qf0Q10AgpCvexCOLYyJOcnw4I/0rVRnkEgyWe2yCif2L0Ua8OIhirbr7CqgcLd2z5QBRxq00sSSxZRSyi/K52gEapBam4L+QJ9LCn1q28/GxRRATHZ3739+/TuVDcpInUiz/W7UsgD9vnEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OYQjiqLi; 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="OYQjiqLi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14F7DC43142; Fri, 23 Feb 2024 16:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704886; bh=ue5sQop1UX80N3Oly9X4CFXlH4jZY6ypbaPw8tp4MNk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OYQjiqLiSpvM+OSw5U4180OTYu2K26nqI1OOcVnhZcPjuFTcHW7fx3ZOq4tq/hhj9 JrEniQ9mW3MVh1IRfbHDC+Zrt2RMEcKcD9vTA5GkgZKXa7NN5nBmvfWWf8NThmmQer XNUpZPo/DZvOayJeETWkt8Q+jm+xz3Xo7OGtGZHBHXtYoeAppzTcrbJj+lxXJ9DV/d 3ipgHXmL8F+qO6jw5+PpyuTpXpf5slB2MmqdVteX3YdrhVdqpIKk9EUj7GdGLK3KVh o+PKYG991i5JWw3BCdYZVOWpyjyGEVjoQYLaPB7tcviZFXlxWthnEXupyxQAuUoven 4ieaDepF9/w7w== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:12 +0100 Subject: [PATCH net 02/10] selftests: mptcp: rm subflow with v4/v4mapped addr Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-2-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3748; i=matttbe@kernel.org; h=from:subject:message-id; bh=ZFk6g5PlJHfh11TlBjZmbnSS1q5EvGF/kQ+zZYNGb5Y=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRq//6S05QxDI1G5XsvbBsehgLjYNABsmmvO oWybwGvJYyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c5KQD/92c/GlnMe7YDrf77OPpMvOybwPkaZgMchRNsMt5DqXM0C3dSRihG+iEXnRg3N/kq36R5E 6XlsivfJHTS8hptn5iw5S2tzvONtgUAtle+kl/HcdWp7VS0AJbM92PRhvuxOBHRtsny+DjkvE0J R9+qIQapN0y/oiImFrmumcUJhZLJThoU0lHvLit6/5/mkJcZDJRleC1qJoreiNFqwqNQqfjMir1 pMNeFDrU4jGhIo+t5pH3k0H/n4DmkIZf3tGT/ZFKOMEqjz7YKmyxVW2KrEygvx9RT81ErPTpjOv bITRmuwaQvM8Sd/A0BbQgrAnrzFYdLy76GWF9Hw1IIr6F/UVDVek77TaXHnpuDAAthMgwKj/k4X RehOQb/DotcD5xHr31JJ8ko63iQFPIh+ZwjhjkvpfZ/B0WtoSKWEnZdwv+vhTWvgocC7YoU5SvA 2wXA2QVAGJ41cBdZtI2rLIzZVMfkUt01iAo2ZnEK+T5y8efxKVmaYPr63ooIIzLI8eFkn8ZYhT1 IVUPmDXtK+ZKvX8Kr/wBTR4ZPPvQCZ3LRdCRVX4MaEA22FiL+3L3fIeu5UfoshD6QEgg3GV90Ad GfTVQ60aZ+IeF2uYedQukbC6wyqsX1pW5re2E3Gv9qOF9yxrXJsD8SRMLt5pJdtjWGEBZMOqaJl 7X5etMjhYRy/8Gg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Now both a v4 address and a v4-mapped address are supported when destroying a userspace pm subflow, this patch adds a second subflow to "userspace pm add & remove address" test, and two subflows could be removed two different ways, one with the v4mapped and one with v4. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/387 Fixes: 48d73f609dcc ("selftests: mptcp: update userspace pm addr tests") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 28 ++++++++++++++----------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index c07386e21e0a..e68b1bc2c2e4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3333,16 +3333,17 @@ userspace_pm_rm_sf() { local evts=$evts_ns1 local t=${3:-1} - local ip=4 + local ip local tk da dp sp local cnt [ "$1" == "$ns2" ] && evts=$evts_ns2 - if mptcp_lib_is_v6 $2; then ip=6; fi + [ -n "$(mptcp_lib_evts_get_info "saddr4" "$evts" $t)" ] && ip=4 + [ -n "$(mptcp_lib_evts_get_info "saddr6" "$evts" $t)" ] && ip=6 tk=$(mptcp_lib_evts_get_info token "$evts") - da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t) - dp=$(mptcp_lib_evts_get_info dport "$evts" $t) - sp=$(mptcp_lib_evts_get_info sport "$evts" $t) + da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t $2) + dp=$(mptcp_lib_evts_get_info dport "$evts" $t $2) + sp=$(mptcp_lib_evts_get_info sport "$evts" $t $2) cnt=$(rm_sf_count ${1}) ip netns exec $1 ./pm_nl_ctl dsf lip $2 lport $sp \ @@ -3429,20 +3430,23 @@ userspace_tests() if reset_with_events "userspace pm add & remove address" && continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then set_userspace_pm $ns1 - pm_nl_set_limits $ns2 1 1 + pm_nl_set_limits $ns2 2 2 speed=5 \ run_tests $ns1 $ns2 10.0.1.1 & local tests_pid=$! wait_mpj $ns1 userspace_pm_add_addr $ns1 10.0.2.1 10 - chk_join_nr 1 1 1 - chk_add_nr 1 1 - chk_mptcp_info subflows 1 subflows 1 - chk_subflows_total 2 2 - chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 + userspace_pm_add_addr $ns1 10.0.3.1 20 + chk_join_nr 2 2 2 + chk_add_nr 2 2 + chk_mptcp_info subflows 2 subflows 2 + chk_subflows_total 3 3 + chk_mptcp_info add_addr_signal 2 add_addr_accepted 2 userspace_pm_rm_addr $ns1 10 userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED - chk_rm_nr 1 1 invert + userspace_pm_rm_addr $ns1 20 + userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED + chk_rm_nr 2 2 invert chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 kill_events_pids diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 3a2abae5993e..3777d66fc56d 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -213,9 +213,9 @@ mptcp_lib_get_info_value() { grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q' } -# $1: info name ; $2: evts_ns ; $3: event type +# $1: info name ; $2: evts_ns ; [$3: event type; [$4: addr]] mptcp_lib_evts_get_info() { - mptcp_lib_get_info_value "${1}" "^type:${3:-1}," < "${2}" + grep "${4:-}" "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1}," } # $1: PID From patchwork Fri Feb 23 16:14:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775386 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 EED7D84FAA; Fri, 23 Feb 2024 16:14:50 +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=1708704891; cv=none; b=O38IKOTu8HI5sDoahz9AXu8LSGv5RDGBBekVWn5qIAfPgekZ3PYRlurASFBwv0+hWN6LKVA/XvMOgjo2I347ebQiuJlhVax7zb7Cl8c+1Fo2TDKOQrowYZJUaPXUNu5484zz+oEFdG/uayBx76S5BVPsjn1/uVbbtZGwX9OfcIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704891; c=relaxed/simple; bh=yqVpPDEMqq8zK76y9/RmkaivQjX+jkMnWSVK2jv/tQg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eYC5kxbHKrFnRho1b+dbXLOh9X30QRJDJ7GmIzHMMaFywTqsKO+JOy19RIgxSP6VJZaXhpOrZvqsXgZWL9xbSe9PRlXI3aBykzdV+nBCfDSKsLlH91EBCJKoGExEGFr5vn25Qb+MrmnEz1HwUIAEWO42/TC9YBCRQaKBiYIs5H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rJL2laFc; 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="rJL2laFc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 121D6C43390; Fri, 23 Feb 2024 16:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704890; bh=yqVpPDEMqq8zK76y9/RmkaivQjX+jkMnWSVK2jv/tQg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rJL2laFcQJvQzSBN68I++1KDdpnbpoFHC5tniRy7U/iyPwSTUfKyuDjkPLbaWwq9g uoFzvarctpfa5tXnqekNcM3DBaLIlctwRjN/DIMLtDb+C9zHUTCu8RslzYc+hSNreg wd/gkpLmdTd17H8Ctr/24cr3dD97jEjKqCsD622zxeeWdz500mGPFSR5iEM8KR2CIW l6l0RYDuXCbXlV7oUEljfkFdwqRYMC16TEEDtziNw9VWR4jsVm0W7Wy8aP1Abp6o/z b0tXtARfUvWsqbpR8RCemUfmrOPjxZ2GNO1iDoFIMMZ6WJhS+X6gkXMygS3wCGWLiY kqbTsVNMXxNFg== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:13 +0100 Subject: [PATCH net 03/10] mptcp: avoid printing warning once on client side Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-3-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1379; i=matttbe@kernel.org; h=from:subject:message-id; bh=yqVpPDEMqq8zK76y9/RmkaivQjX+jkMnWSVK2jv/tQg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqWg0B1Jjp3HzUvASfzwT2t8eB6Fif+NvbI dLqtrIJcsSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c3cZEADmMRbSTC/9CnNeg7emKx2DvjHpspiVlqu2nUM5x6yWnhKyia7OM1BvZMY94o31oWDzYcL cd4AeEF/sE3Yz+x0mGM3gEtH/NCuNjXXv6I6el/29kmdx+7CAGscV3k0L75wd3evuzQhVieXNq7 /EC54fanr/EO154BPDq2FJ8TzR+CaJJMMVIe473/vggq8R/EifQFi/lXBl//HHa5sY0HFZNCkM0 vwJ+jJxxe2MGtGWXqQqIGuePYBuhbmU+7nR0GgYOUE9G/V4AFi/nx9MOddb7ek9zdEOjgVOXRgC pQyMdPZWlOXKEw1kyLnUligfJLPIL0PEyPObI4jWaC0j5efzqy4+NZS+WnULWJyB2QD70Vf0hvI TPWqLzhIbrHEqetHNF6k2CGQjD65B7msGkPrK54OX4o7ME8+gfSUALJMimbPTilZ+5zdOuoPIfH Kaaak6/VGqIrO0hmAQ1jBTr3YfhIaxxDYwBa/7oo2PwX+sfFSEsHYlzY6rim2JMD/XEUK707fMk S+VKFCi7C+5QeTlQjFNfw/FnmL78vvwQUzCWTeCZRIS56qZ8vve2LbKrNd6yhpkCFQ6uxnAt37C u2qSDb5BhPV3LbVj19mlq/wFiU056rcf0lBmW94UvoOpclSYgTu83Dqm0dyTSzj6LSvOqOWP97u Iwyc5cVo8Syjjag== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After the 'Fixes' commit mentioned below, the client side might print the following warning once when a subflow is fully established at the reception of any valid additional ack: MPTCP: bogus mpc option on established client sk That's a normal situation, and no warning should be printed for that. We can then skip the check when the label is used. Fixes: e4a0fa47e816 ("mptcp: corner case locking for rx path fields initialization") Cc: stable@vger.kernel.org Suggested-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index e3e96a49f922..63fc0758c22d 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -981,10 +981,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, if (mp_opt->deny_join_id0) WRITE_ONCE(msk->pm.remote_deny_join_id0, true); -set_fully_established: if (unlikely(!READ_ONCE(msk->pm.server_side))) pr_warn_once("bogus mpc option on established client sk"); +set_fully_established: mptcp_data_lock((struct sock *)msk); __mptcp_subflow_fully_established(msk, subflow, mp_opt); mptcp_data_unlock((struct sock *)msk); From patchwork Fri Feb 23 16:14:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775640 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 4F22984FBB; Fri, 23 Feb 2024 16:14:54 +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=1708704895; cv=none; b=SeDDY1ahLKFQ0ymCEBLVlSS6VTWGeMovLPP1spiG3CqjzAsHpL1Xf+HSIx+vJdM0FG93adYDrA1Zt3tX5+EhAwWi1V1Kyk8kVA1hdXEBR7GgfE0ZJfuMbUZvFmkXLMsldI2ZMjHOPcFf1iaYfrDjHDR1fNH6i6wcMboeiIV24j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704895; c=relaxed/simple; bh=oMPcTg/HR4My2+n2kEfVTapwJZ1FPd+w13TvTlMGAjU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eZVyIt0zf5OfbzR5Qc8aBZF4m4nXSMv9MZWDrBBg3a1bDKNZ/Xh+BhiHANUpD6kusNtrfjRb3l1KyXIMDCawfAu64k1zS5OdAt89m6Rm4Vi/5CG3tvlj2ivCoi+0EQRgUz+umIyPLoLMQRsbgCN5+b8jIZ972KdmgFEj7xHsp/Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k+BmOVmG; 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="k+BmOVmG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9455C433A6; Fri, 23 Feb 2024 16:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704894; bh=oMPcTg/HR4My2+n2kEfVTapwJZ1FPd+w13TvTlMGAjU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k+BmOVmGu1WVPgWV4tYATEy6Do8BYxMpQTMFseaweyFcBFympiJdfwoRAewYGG3cP SY6EPq7p2y/MOVlxvpFG9jDXs3D0cfFUBVK/HDCHQkC1wVBv7nIPYVlERiEPrVQQfI K49wNZfJ1CKShcWbTdtD/84xXoLo3WHAqrGSrBqFOy8AMhPS4xisKyzXwnWGcyKI9A 3viuMXfqbT3fAnf/t4wOA4x/z/UWd5vxDvZcx+afLvzq0YNiFe19fowsc89Zxcmyow b+r6XGQoScDX5GgaorUKEGoOldDxch3BvMfp7rJJ33M993JWCroLg6HeXgrlJmN5HY 7syt9QjVvaG+A== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:14 +0100 Subject: [PATCH net 04/10] mptcp: push at DSS boundaries Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-4-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1234; i=matttbe@kernel.org; h=from:subject:message-id; bh=LIWA9w8Hu+BN9Y93ANJ69iVx7kuDZyfmJaoFzfkKwwg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqohB1/YeTq+OuqgfAFqE+ePW4jlRE5MgU5 dBhI0B65D+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c8+gD/0TZOAF6HLWBlDgOkRrcVEyvyirDvqagkCH4NhEHL3pxfQ3Yss/bShQ8PAtfjS4x58pd8G An5gZ/9oMnL3b76r/pphg4y1m+h7yJct0Akv9tNRXzlvHmXhkZdqpcrUrjInpznaDKcpoyrtRtc fG4yHBe9Pux/Q4h9BvvnoVhxGJCDExtd/tgoA0NbxDxFx2ACwifYshqjVVVkLCyNrc2d3p+YjUZ NVcs7O4i8S2OMfddssO1IsOSQUJBIj4KbVOqgFWBofDZtsfdxkMM51LPRDltbj5DK3FCdCXOLG9 oyeM0BEz576RQXnZ6v2cNFhmYRjYxnqZgkiXu+wEIMoX42OJDkbA8TFvDhBQONutMgLAJyXCfq0 vvYc7LVRI/oU2Gy2eQi388Wy6h4oDif+NOMhbqX+Qb2PkfIMH0hM3rq9CV6kUjpsGt8/zG4EDBf JkQ121N9cBZRJBWGrhB6rO0JRAdei25kj0uHYK/HthmaBZkEvBpAP3GJ+VNtRrLFTOj6Vfn/jLU U2vyzeGvCDMVnRTuCYF0bkjAkS61cTtGq68biANBrHODMZh1Gcnz/eUbgvPKizuWXWERBHHH37K NMASOEQ82uSbYJTRVgjhV5D3atJIvnVpuRBlanPJ+Ptx/DiaIp6ox+wiIjGDMOcp+BH0J0aQh0S c2hEkViXtfrVC8Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni when inserting not contiguous data in the subflow write queue, the protocol creates a new skb and prevent the TCP stack from merging it later with already queued skbs by setting the EOR marker. Still no push flag is explicitly set at the end of previous GSO packet, making the aggregation on the receiver side sub-optimal - and packetdrill self-tests less predictable. Explicitly mark the end of not contiguous DSS with the push flag. Fixes: 6d0060f600ad ("mptcp: Write MPTCP DSS headers to outgoing data packets") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 948606a537da..442fa7d9b57a 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1260,6 +1260,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, mpext = mptcp_get_ext(skb); if (!mptcp_skb_can_collapse_to(data_seq, skb, mpext)) { TCP_SKB_CB(skb)->eor = 1; + tcp_mark_push(tcp_sk(ssk), skb); goto alloc_skb; } From patchwork Fri Feb 23 16:14:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775385 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 6173012D217; Fri, 23 Feb 2024 16:14: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=1708704898; cv=none; b=feLp0ItEVShUBUMm9Ug88vnjse8sRGZDt5UQOMpIymfQ8J+HoWs5/l3HQIah8F/BBpJsyU5Fw8FnG+CKcQASHyeRB/AhtTIIresGqwmAL/kFLOgqM+4ivC2E7l4I/Yeu0dIWh/K2nTep2C/9cPOIVvp6OPoyfaMB/mYHXoF+2x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704898; c=relaxed/simple; bh=CPDy4dZRwTDEbx1YV7BtHTXQsWFT3BnDEbIFrcORF/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nwBbSZsKAlHN9J6ntBZFCQHLir7FL4b5J3twpPDmJakSATE6wq2fIEexO7s+/ShUsyE95v9xCz5jyEfq+p+WpIHTBVsnfqgmtMtemOTiizlkHekrg79CSKePb/NDhE2XZ923aAr4TniPH/EDXFnxK2RaLgtacRm32v7hVytDuEE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BUPjmnLG; 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="BUPjmnLG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6DCAC433C7; Fri, 23 Feb 2024 16:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704898; bh=CPDy4dZRwTDEbx1YV7BtHTXQsWFT3BnDEbIFrcORF/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BUPjmnLG4EEmoVkbZHiYUh7NwbhZCFW8cRCOI8JkXk7KNYhfGf0eWhjI2Q4DpQ/Sw XMY0eyyGd1RfmIbrbIzd3NFYp+WKtM+NIlG2C01Us8QZNDOqRNh5fAO4f7F3AlQ8yV ySICiAGPLUSnxezVUpRAaav2d5y23+HnubAlYdyZgaPmllyKKe8BFOdBhPX3hjDzA8 6/tiZMTWf0PP+aEn/P9qKzM3MUasfUy/MX5szPYDtXqsg668tWv4DL8pXQ3mpqYFBp xhxAq2vd6I44gOrualYJsG8nrhbRabcc8/tqkdQQMo881/k9Sa75UhGNvwPAuA0PdV h7fkDmjtsxDuQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:15 +0100 Subject: [PATCH net 05/10] mptcp: fix snd_wnd initialization for passive socket Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-5-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1025; i=matttbe@kernel.org; h=from:subject:message-id; bh=zIc0DvPqwvck70+qa3G7AqDo3nn6CKmR3M+FTdYp/kk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqFg1UztakYnL93CqFyVtJ6zltzN2Dr5BA2 ORlY27pbKCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg cxXGD/0dD0CgsDVdaPHL6m2LuFAFjfFkSA8ug4hqwJ4GqD7EiIpES0CraAvncxkciSjNhcpuesm ySM4ZvVEM3bzupke4g/8zbrWuxUPaDA1BVPEPt7tqfK94s7D+LWmVVyY3zJVr3M/Iimycecqma9 lQ2zmQ1n2glNN6wufx2rnNoXMlCgvo5kTlv8p0Wt9wLMNKwk0Po1Ff61mJxglpAbBNuZ2F2RvO5 Hk6DqPEsGpk5eZQW03ZnwQYxP+RvwtooQQ2X+htxX1vfHWrIaNxuwBjVQFIWtOmGODQyLMncDaH aaD2YeYzxzXT3Q7X4UzQWcsuBFAvujsfb+f8evylOhoBmJ0y1mHF5j0jmkC8y8l7fTDTI7V6p9r JhZ6nLhyArvLuAd9xpFaMPvUPB3x4QPkDCnqjPpRhMWHzqyWIVfEsv6csb4kWs3K0e3qSOrVLa3 PV22ytZblYDccuv5aXNECi3Vcce4NNKpZnDmvQzXY9RCJJyG7tlZ+FeRUbWqJXbX7Vwzp82Rq0L 4Gdkrfzsk2ytzNj3kSXD9kB/XxvDyfaTn25bya0oTCvodbUYNXwTTQiFu++LsV9UghyjkSVuMTe 7NUTSVi7BVhVs4UGC324V/8sZ5j+706CxoXYkQ9A7mVVg4I3Hw73qjLl5a374Wy8eYCQAUflTDP z3l4epqYIK9HmNw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni Such value should be inherited from the first subflow, but passive sockets always used 'rsk_rcv_wnd'. Fixes: 6f8a612a33e4 ("mptcp: keep track of advertised windows right edge") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 442fa7d9b57a..2c8f931c6d5b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3211,7 +3211,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, msk->write_seq = subflow_req->idsn + 1; msk->snd_nxt = msk->write_seq; msk->snd_una = msk->write_seq; - msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; + msk->wnd_end = msk->snd_nxt + tcp_sk(ssk)->snd_wnd; msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq; mptcp_init_sched(msk, mptcp_sk(sk)->sched); From patchwork Fri Feb 23 16:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775639 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 607F21339BA; Fri, 23 Feb 2024 16:15:02 +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=1708704902; cv=none; b=UgQ4+Ii04giTtoRxApBBPd/71AbfvWxssQkr+lu2R+yB6fEyxjXRLVcqVvRBfAQVC0WOxe9kp3qbu6+IXSMdfFgI99bz+r7rX6Ow/FDnBhgLcb4tNDYKA6fGq8G1TjWPkQBy6jO+87ZpPGPaOwRZ8akKH9rV55CIfL9WpTUscF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704902; c=relaxed/simple; bh=PMAgnDXhRdjsNXlI4ncyw/rBYaRC4RspgOy+6WHSdWQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f36yjnYO+ZWsNFYFGUmIGyRo1SWlL0w3q4enB67LR7F7N2Gir6oT/Wow61dHpjwP5tRkGM0k5IIRCMbCnOlT33RqtRmLeeT9q17j32wpckUnUWYarx3kyhXWkine/86odSf0NVB6CGP04W7tdoK+ZiDAHgPdrJyVJHK79x/F1k0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OvgOV89T; 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="OvgOV89T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74A50C433A6; Fri, 23 Feb 2024 16:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704901; bh=PMAgnDXhRdjsNXlI4ncyw/rBYaRC4RspgOy+6WHSdWQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OvgOV89TM45dHS4EJWpLaYraLn/38cckE4E+eT3MCuPy8SwYHyui++rb7pCzY5+S/ Oxh81DF7cNkEgKb7o3xNv0/s6ZCMZU59P+zYgF9RNAOPW0Ie4DjX4GtHHeWc7KXZVy vhyTFkExltayTKpfA7EJez/XktuIvuVy7e2Iet6XG2KyxfFmT1KpB0VP4QnI7rVgNS 76pM+zysvpM3+dgoDKokjUJxzhTDpGnmoQUq1IbVzXhZc2+RKd2CenDnlKfuC993gQ 89/Qk8C90Q9aLpTE5L/N99QWj1T3vwSf48UM/M8Ip2FtwIEwD7kneSCgBQFLjnmvdN uEp9laIZmgANw== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:16 +0100 Subject: [PATCH net 06/10] mptcp: fix potential wake-up event loss Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-6-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2127; i=matttbe@kernel.org; h=from:subject:message-id; bh=g/43TBB3hrKxL6qqQvc2rdv93ajqIAHOvqscdy4uC4w=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqCbiEqi91LPDSjON7evvjjl9b9JVJOG87I M1OsGNpSQWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c+w9D/93xfwHlSJBSVqSLBT0GCGAdy/yW9dEoRKB5dYOpjitE+UaPM6ahF4MDr+d0oifWMkOvsO d3gKJvtohzSE6ngKrEUVgXuDVaDhT4wSEq5mVAjdF5Y7Z27gHVB3CCkWwc8qm2OmeVV7nE7i37S Rz7rS6ISlpyFwu3mqEFtbN7+i8x/OPU5SuPHftYOsb6tjnIaLSXSNgNmKxDFd7iw0SMrORhwzMM 1k/lixDMZfCPJfwacw1HAhMJfPhaVzWy+aJ8YYSOd4Q1TE4fegKjLpNttYITlUiJ0IEE1sd+xN8 PwTSXDHXkTTPcBY5Bxukzby3/gka8zoawTTsh19TRXF0yUftyi7S+aGftlTgDWRZQvV4chTZ3+P EJ4hIyGQbDvjkHjPoBMOWjZpfAXmGnLJ3BXanibfIUMTTHE0BU1MnGWPERd1ONBLNrqasU0dVcB 6AVr2TocXsR8mBRz9V5YR/Tn6R+MWSaggno9lCEFHQsP33zBi9FUCpzRxH6Nk/zQmDZwn/2bEh7 8NRmVDIqjX16L5Ls+k0InABhdNaGM5UeqI765EXlffFKWP+nVPFC7cV/yDG0JgjpDz+vY/cCnl5 h4P4sMJYRnh1Hgtl09CCB3Fcna1xoGldbRjF96naFtPHpDsTj6uLw3ONv/XRZUsVKqgDyL2SYvB 46QX9oR4Z29LSnw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni After the blamed commit below, the send buffer auto-tuning can happen after that the mptcp_propagate_sndbuf() completes - via the delegated action infrastructure. We must check for write space even after such change or we risk missing the wake-up event. Fixes: 8005184fd1ca ("mptcp: refactor sndbuf auto-tuning") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 631a7f445f34..07f6242afc1a 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -790,6 +790,16 @@ static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk) READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt); } +static inline void mptcp_write_space(struct sock *sk) +{ + if (sk_stream_is_writeable(sk)) { + /* pairs with memory barrier in mptcp_poll */ + smp_mb(); + if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags)) + sk_stream_write_space(sk); + } +} + static inline void __mptcp_sync_sndbuf(struct sock *sk) { struct mptcp_subflow_context *subflow; @@ -808,6 +818,7 @@ static inline void __mptcp_sync_sndbuf(struct sock *sk) /* the msk max wmem limit is * tcp wmem[2] */ WRITE_ONCE(sk->sk_sndbuf, new_sndbuf); + mptcp_write_space(sk); } /* The called held both the msk socket and the subflow socket locks, @@ -838,16 +849,6 @@ static inline void mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk) local_bh_enable(); } -static inline void mptcp_write_space(struct sock *sk) -{ - if (sk_stream_is_writeable(sk)) { - /* pairs with memory barrier in mptcp_poll */ - smp_mb(); - if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags)) - sk_stream_write_space(sk); - } -} - void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags); #define MPTCP_TOKEN_MAX_RETRIES 4 From patchwork Fri Feb 23 16:14:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775384 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 7A26B1272CD; Fri, 23 Feb 2024 16:15:06 +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=1708704906; cv=none; b=HvNsAlywj4bpsPRhLNtKseQrYlFXYEaBCAPqx+upHWlwiee798Do+pW9xRsZXJrhvUyzh1Vl1Sd3b4M9JfJhYJ2EVfQHHLy1gWcy8ApZLFlEZWsDQjb7eyVpRjcnbR1h3dM5yOwPcXv8gXkfPmujV4CLmJj7RyzqkrTKnxH1Je4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704906; c=relaxed/simple; bh=b+ZN3PITa9kkg8zOC0cUDaJjwPVoLTyK2mnUW7RNJsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oFMPqaA0KWkz7nIeMfwXmlVsZ7qeBBIaO3v5rZbU4MsgHTHUwzCA20QyBlK9Ya2ZjUxNYt9CE1DCpce4f83FAK0pbj3KxwPcgT4DNetxFjpUTTNypUwy3Eq7XV1XHzUILFmMHwPxtI/YRLJSXAVU6nHRX8nDU7meyKF9b3Ug/v8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L+m0Q/oS; 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="L+m0Q/oS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4496EC433F1; Fri, 23 Feb 2024 16:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704905; bh=b+ZN3PITa9kkg8zOC0cUDaJjwPVoLTyK2mnUW7RNJsA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L+m0Q/oSLKJOkrbYpLsIewuZcckjXTCmKJM8dpHaK64RLuouMelF3H36YDOAxoCi0 m9fMAFIrBGDZ6DqONllUBxRVknx/DMzLMjLcta7//XTXjgdOfqgZH0IGSLzFJWFSUs EgfTFmPVJ8Z7yfzsvvds1pEvR3eu0WdPDnbpBANksyl531f+svBfZ9wLMgdTWz+WrH PJHsozMbxAJ2bD86baEezNgLiy40ll+btaWcn6I9qc+JgIdqR4PgXqjHsot9cdIbgq wvrjzwJ32m6sY0DyFU6Ia4gICSqDzzDkIf+qzBhnIzq5ZKYWBDpKMdE8uWvPIuLlnD A8CAClnzb1FPA== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:17 +0100 Subject: [PATCH net 07/10] selftests: mptcp: join: add ss mptcp support check Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-7-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1126; i=matttbe@kernel.org; h=from:subject:message-id; bh=KLB3MMq4NcEI7Evk8y2hay/amTn6SC9Wks/c0APaicY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqp99SXmBP+BCtfm0cIfwhmR9owsF54p2/3 jHTQHHFQBGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c6GiD/9ODQHMUmkHjQr/jjXIX7p5secWLqfKIUtaHgmsfuT30Z11zHFyfIEDJTzT6l1/ptn3CEn LRKZUnkDVYl4KaW9en5CKsvHDfgbyO5vIr62J4FaIHuCnWLVGeH4hH4rQj0A4k0TxVtGmAUqW0n 2h3eW+addcNa3jREiKgxAXPguF16zr8hlrED92Oi7/oYwsjJYU9Zj5YRNXOWhchgp91qOjcpJ+I wfAuYKSQi47h0a30vDVWmzLjqhUR3mOtGVkLHBiMYl74mCeygJfDlSiEsW/CTVFr1Zkv12nRoSb 1thkPABxV/1tFOngs85lQXZjzcnrH6y7YhF8PPMY6QkW99pGuBUwTfMN6qgYh9lyBCaappGcpTf pA9102wHwZfIOh50Pxw6pzN31ZsbY/sOtEs+2oYNXixpx/8MlNpl7xIU/OCxPKhS0i6M+gFi80+ xwrHjMIubaWaKF0U/2HtyWjHOgup91/faSk+UaC6f2cNx0ZDoiaSsw9MnGrAlF+89kFV3EyQT4u 7U9gnk4EegqZfnrtScP40gwPHtW4kNh+Ix4hq8PqYpKXg8jC/AUX3o6TnDZ29p6XSWsK+SfdIqH wKxOuyF1rDWDNAzFpRaO4yYlPPghdrZ05DzDhBptFm7UPX4Ay2HYxUPwWqsS7wzHB4HDgCMgKgn odeHoGcCPbjPRuQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Commands 'ss -M' are used in script mptcp_join.sh to display only MPTCP sockets. So it must be checked if ss tool supports MPTCP in this script. Fixes: e274f7154008 ("selftests: mptcp: add subflow limits test-cases") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index e68b1bc2c2e4..e4581b0dfb96 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -161,6 +161,11 @@ check_tools() exit $ksft_skip fi + if ! ss -h | grep -q MPTCP; then + echo "SKIP: ss tool does not support MPTCP" + exit $ksft_skip + fi + # Use the legacy version if available to support old kernel versions if iptables-legacy -V &> /dev/null; then iptables="iptables-legacy" From patchwork Fri Feb 23 16:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775638 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 50A2F1272D9; Fri, 23 Feb 2024 16:15: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=1708704911; cv=none; b=N185gf6tO37BDqca9ofe4HvDYKZd9DjEyn1foON4agBS7wSuR9SJ0dPCTobsXSydQPVyWbzlQcstY0VEWNE5q2pv5x4JBBG7bqv+/ueiDr1BzFmOzwafHMhUV43yr32wfWaTEFHJ5X6NQHms6X7a/m2bMHtMiUaSB4NLOnawdFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704911; c=relaxed/simple; bh=UOmb8QUKpfB4+WjxyRhNnD+CWLS+80nZ+BSmHaLlkTw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N6EWjMwqyD8XxykJ9mXPQrdqICwXCkMjOpD5yTfYPz+L72L7WN+TviPRYWPJq8zI9Rhf5g/VIFZCaoVDLkPEqo64ojAeRgputSGlVzTaL+ZmyQc5JnHGJd+jmcag6BsBFTn256R4PZtGb0zqVO2fIdrGxNwVaWJsQpbLxVLOgYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nL6RHuJw; 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="nL6RHuJw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42488C43390; Fri, 23 Feb 2024 16:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704909; bh=UOmb8QUKpfB4+WjxyRhNnD+CWLS+80nZ+BSmHaLlkTw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nL6RHuJwX6P4sv9LOiFdft0R4K907aiXbhvYbHDG7+ko+FuVWxFo/VYIyXmgnrJsE jBSvrAFJgcyUw/7LMGlZZV6eB5w9bu9F3EkD4cEqmNOF5qE8oeyY9WDSmjhFtzpNPz jQ5MwIhGnOCsoxY2wAc59alMd7rooFP67+PhqjyWszD8YWQo5oSJsLmeaJaELfcPmK K7f/FS2xRPO93UH//GQO+RR3ybEW/3ztQhqeUVuk4hPrLd+IJv8B06bquM6EC1Mpbt AhfXHZBhzz5IKvWsMLFZr/XugZdDmZ168c6TwAHz8EOLQLs09obz4ayDeppu78lhqq FhZrfTFR5dFeQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:18 +0100 Subject: [PATCH net 08/10] mptcp: fix double-free on socket dismantle Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-8-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Davide Caratti , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6954; i=matttbe@kernel.org; h=from:subject:message-id; bh=g2NHIj59A7epffNx/pwc/bVVEml4bfYZeG26nwfmrmc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqCRQrauV3D9skqzFRuo9n0hpI1aeEHyQo+ f3gjagRL8yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c0FFD/48f2Iv5jX8iHk2IvEhVok3sehVXDBlVamGz89DgI0Lr74tb93HhoYqWdPRwqEByPrZlGF Y9wxH6llNoy60ZSY/LwBTvXQb5mc+LBoI9w4xOOIM3eiUCNKsSBGK3rjKPrAlv77hoAlbylodBf VCH6h/FzZcKCHmJmmYE2q+VmO7kuAdjwFUeWCWXfQDQvE4YRCNwOjTprhCU5a8Hgxoo/nUpBg4j ceyW6lqv2z/KOogyyxrUBThcjWyehP7zlk8fm9zPZE6838S+Wu8TPIzR9PUV3J5dM/7hEby4IKL LuuCXo8kHlmDKq+77RsQf15gzC46IFdxSJYNyxbN5koZ35yRCburXiSY11/WoimyOtxmfecIMeU jQsQXTjXUfuAz4QbSMF8nJvwVGYhHMbLNvBpYOT7O3LFY5pePaOMwjaw7PObDR6gjtw/EFLRII3 lW3iA2sH3suKCGnF7iyyWD9mwNj0x5U1RVadYxM15do/cciVKF2QPkpD8K3eBgZNKLVH7sTuVMc 3Ui/Zm6gLpURKGI2wbAu1gVXifmOI4K+Ry2Ig076B9/Aa4iS1H3EhNHAZePZzBtq/1TCyTRLDOa ZMh1syXjmzRnuuNcJBKpXnswyEgf7cjzIktgXMG4G1Lr2p7jGRKYeDVSDR/+tqTOkp8fMqz+RdD u/XMlexdZIiNulA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Davide Caratti when MPTCP server accepts an incoming connection, it clones its listener socket. However, the pointer to 'inet_opt' for the new socket has the same value as the original one: as a consequence, on program exit it's possible to observe the following splat: BUG: KASAN: double-free in inet_sock_destruct+0x54f/0x8b0 Free of addr ffff888485950880 by task swapper/25/0 CPU: 25 PID: 0 Comm: swapper/25 Kdump: loaded Not tainted 6.8.0-rc1+ #609 Hardware name: Supermicro SYS-6027R-72RF/X9DRH-7TF/7F/iTF/iF, BIOS 3.0 07/26/2013 Call Trace: dump_stack_lvl+0x32/0x50 print_report+0xca/0x620 kasan_report_invalid_free+0x64/0x90 __kasan_slab_free+0x1aa/0x1f0 kfree+0xed/0x2e0 inet_sock_destruct+0x54f/0x8b0 __sk_destruct+0x48/0x5b0 rcu_do_batch+0x34e/0xd90 rcu_core+0x559/0xac0 __do_softirq+0x183/0x5a4 irq_exit_rcu+0x12d/0x170 sysvec_apic_timer_interrupt+0x6b/0x80 asm_sysvec_apic_timer_interrupt+0x16/0x20 RIP: 0010:cpuidle_enter_state+0x175/0x300 Code: 30 00 0f 84 1f 01 00 00 83 e8 01 83 f8 ff 75 e5 48 83 c4 18 44 89 e8 5b 5d 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc fb 45 85 ed <0f> 89 60 ff ff ff 48 c1 e5 06 48 c7 43 18 00 00 00 00 48 83 44 2b RSP: 0018:ffff888481cf7d90 EFLAGS: 00000202 RAX: 0000000000000000 RBX: ffff88887facddc8 RCX: 0000000000000000 RDX: 1ffff1110ff588b1 RSI: 0000000000000019 RDI: ffff88887fac4588 RBP: 0000000000000004 R08: 0000000000000002 R09: 0000000000043080 R10: 0009b02ea273363f R11: ffff88887fabf42b R12: ffffffff932592e0 R13: 0000000000000004 R14: 0000000000000000 R15: 00000022c880ec80 cpuidle_enter+0x4a/0xa0 do_idle+0x310/0x410 cpu_startup_entry+0x51/0x60 start_secondary+0x211/0x270 secondary_startup_64_no_verify+0x184/0x18b Allocated by task 6853: kasan_save_stack+0x1c/0x40 kasan_save_track+0x10/0x30 __kasan_kmalloc+0xa6/0xb0 __kmalloc+0x1eb/0x450 cipso_v4_sock_setattr+0x96/0x360 netlbl_sock_setattr+0x132/0x1f0 selinux_netlbl_socket_post_create+0x6c/0x110 selinux_socket_post_create+0x37b/0x7f0 security_socket_post_create+0x63/0xb0 __sock_create+0x305/0x450 __sys_socket_create.part.23+0xbd/0x130 __sys_socket+0x37/0xb0 __x64_sys_socket+0x6f/0xb0 do_syscall_64+0x83/0x160 entry_SYSCALL_64_after_hwframe+0x6e/0x76 Freed by task 6858: kasan_save_stack+0x1c/0x40 kasan_save_track+0x10/0x30 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x12c/0x1f0 kfree+0xed/0x2e0 inet_sock_destruct+0x54f/0x8b0 __sk_destruct+0x48/0x5b0 subflow_ulp_release+0x1f0/0x250 tcp_cleanup_ulp+0x6e/0x110 tcp_v4_destroy_sock+0x5a/0x3a0 inet_csk_destroy_sock+0x135/0x390 tcp_fin+0x416/0x5c0 tcp_data_queue+0x1bc8/0x4310 tcp_rcv_state_process+0x15a3/0x47b0 tcp_v4_do_rcv+0x2c1/0x990 tcp_v4_rcv+0x41fb/0x5ed0 ip_protocol_deliver_rcu+0x6d/0x9f0 ip_local_deliver_finish+0x278/0x360 ip_local_deliver+0x182/0x2c0 ip_rcv+0xb5/0x1c0 __netif_receive_skb_one_core+0x16e/0x1b0 process_backlog+0x1e3/0x650 __napi_poll+0xa6/0x500 net_rx_action+0x740/0xbb0 __do_softirq+0x183/0x5a4 The buggy address belongs to the object at ffff888485950880 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 0 bytes inside of 64-byte region [ffff888485950880, ffff8884859508c0) The buggy address belongs to the physical page: page:0000000056d1e95e refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888485950700 pfn:0x485950 flags: 0x57ffffc0000800(slab|node=1|zone=2|lastcpupid=0x1fffff) page_type: 0xffffffff() raw: 0057ffffc0000800 ffff88810004c640 ffffea00121b8ac0 dead000000000006 raw: ffff888485950700 0000000000200019 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888485950780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888485950800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff888485950880: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff888485950900: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888485950980: 00 00 00 00 00 01 fc fc fc fc fc fc fc fc fc fc Something similar (a refcount underflow) happens with CALIPSO/IPv6. Fix this by duplicating IP / IPv6 options after clone, so that ip{,6}_sock_destruct() doesn't end up freeing the same memory area twice. Fixes: cf7da0d66cc1 ("mptcp: Create SUBFLOW socket for incoming connections") Cc: stable@vger.kernel.org Signed-off-by: Davide Caratti Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2c8f931c6d5b..7833a49f6214 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3178,8 +3178,50 @@ static struct ipv6_pinfo *mptcp_inet6_sk(const struct sock *sk) return (struct ipv6_pinfo *)(((u8 *)sk) + offset); } + +static void mptcp_copy_ip6_options(struct sock *newsk, const struct sock *sk) +{ + const struct ipv6_pinfo *np = inet6_sk(sk); + struct ipv6_txoptions *opt; + struct ipv6_pinfo *newnp; + + newnp = inet6_sk(newsk); + + rcu_read_lock(); + opt = rcu_dereference(np->opt); + if (opt) { + opt = ipv6_dup_options(newsk, opt); + if (!opt) + net_warn_ratelimited("%s: Failed to copy ip6 options\n", __func__); + } + RCU_INIT_POINTER(newnp->opt, opt); + rcu_read_unlock(); +} #endif +static void mptcp_copy_ip_options(struct sock *newsk, const struct sock *sk) +{ + struct ip_options_rcu *inet_opt, *newopt = NULL; + const struct inet_sock *inet = inet_sk(sk); + struct inet_sock *newinet; + + newinet = inet_sk(newsk); + + rcu_read_lock(); + inet_opt = rcu_dereference(inet->inet_opt); + if (inet_opt) { + newopt = sock_kmalloc(newsk, sizeof(*inet_opt) + + inet_opt->opt.optlen, GFP_ATOMIC); + if (newopt) + memcpy(newopt, inet_opt, sizeof(*inet_opt) + + inet_opt->opt.optlen); + else + net_warn_ratelimited("%s: Failed to copy ip options\n", __func__); + } + RCU_INIT_POINTER(newinet->inet_opt, newopt); + rcu_read_unlock(); +} + struct sock *mptcp_sk_clone_init(const struct sock *sk, const struct mptcp_options_received *mp_opt, struct sock *ssk, @@ -3200,6 +3242,13 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, __mptcp_init_sock(nsk); +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + if (nsk->sk_family == AF_INET6) + mptcp_copy_ip6_options(nsk, sk); + else +#endif + mptcp_copy_ip_options(nsk, sk); + msk = mptcp_sk(nsk); msk->local_key = subflow_req->local_key; msk->token = subflow_req->token; From patchwork Fri Feb 23 16:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775383 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 B3E9313A887; Fri, 23 Feb 2024 16:15:13 +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=1708704913; cv=none; b=oawnn0iozqrwu02CujdlfrCgnirEdX9vglqm6WYi6eyYaSOZ8khV42OhcX1gVWxifE5ki/OiuaN88tXnC0Lyoh61gPfjiNHMydz1sfcRvEDW/uGc/aAqVxfd9J31mNN+edmyD542o4mvD9J8xl6T0lNmSHLcVASy1tFSL+hrzls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704913; c=relaxed/simple; bh=7TtWjndsxVYffCALwoOeo7w2xmYQpzPb4cckMSedr8o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P9kJKYf9J58//ZstaPzrQ/f3CIDpNtGpQ0UtFvHQiC8QM0W8/KNRKBtQJTn/fFTASMO0SOVXfIe2Q07qYelaQkODyezqz76uFCGMGR3XT9EBvkGnL0kErzmSSKbARSxUoVkxRehrf7nPL2rnhZT1ZCb03S6XtHXDp8Kzw6MS+iE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMP9Zs9F; 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="uMP9Zs9F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43753C433C7; Fri, 23 Feb 2024 16:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704913; bh=7TtWjndsxVYffCALwoOeo7w2xmYQpzPb4cckMSedr8o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uMP9Zs9FvAfs8yXXna/ZtizY9EHKjdcpQeCD7uKP4MR3vD01xGG8ZQosUT1+hw+xf oA1W70K/jcKg82oh9UekJDpVQAWhGHi+roXddDAeu38K+SimnnLwkWwSOoQmROPqiJ zzMEs/0R8snoUE0zySjABHzZobcTSdkYTkRETuiEVwQiiHFt42UQ2Ggfh13T/+XNZ0 utgq/pGCiIWLJlqpNrWC7XvU2kLZS5Rp49EYex1a+w530Bx/2gS7Bki4TIc3lavPzp uhvoM5UrGe4LzGCOlyIih5+4AehIuzcjq25othCKufNLvfTx2LWPTFmdf7Y3QEyIvA pwH6tmithjCOw== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:19 +0100 Subject: [PATCH net 09/10] mptcp: fix possible deadlock in subflow diag Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-9-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5011; i=matttbe@kernel.org; h=from:subject:message-id; bh=r5yS2aqxy/UFqDVBdC2SzLwUgEbcbOAGxz23X5YQglQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRqJQlYEbverqjk/Wt3czNkvGndu41GkjAVk Ipdmg1TyUyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c+qAD/9eH6iHyK1RwTYjxr/tAoH+SjQQWyyiQhjuZRa5eOHb/Wzp9QHInrYQhEAcrT2McZ/qBia ngOUSBp9kzlnuljowjUa2wDCVqhW+RE11BWvUqSHvvtONFt9HBxzyQ2RLSHLkFB/2ZMPqbUca8L 2Oot9QjYxQQrCUex4NzQkNiQNlleaTChQpPDUmU6AwaVeVvf1C9d7w9rQxA1rV2BSHNa4C2jsgu JXZY+424zLdFx3MnM0cW6IhfkrK8D+zquFuViCGyh3Tzkp7s3UlnumO48JCcucLouAyb3o2a2e4 AWCzqLcxCoeten7eVvogMlPV+wFQwnEC2S2LbKgD91eXBQot4KqoBcvXm2W5bwO6ScSYfT2HJ5q bihP/eSvTpdtNN2XlqarlQqC1ccgxKOm7x4LiXwm4BPnNgOBOWtKVFKrXumFB7bcgt8DEfJ4GfZ osl8rwV73RgwfLCOJX+Iunv2dYGwXKnbNEB9paFifPw2SsqeXwdwDDl23h5HDb6PlDJ0vLvKSqW 6tQ+r3siPX5XS7MTyTS0mlYNd3pw6v/BoN5q76wIUJbJtdO7w7iUfGUD/LtCwERJIvZs0edULIu hM0WLZ4gVlGgw2YyESGr+HphdIbVLsk/TKEtc4oRBXRajGJf8rapMqw4BaVQRrnM+lFzJIdRSBB 4lKYfuJ0BLEbuMw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni Syzbot and Eric reported a lockdep splat in the subflow diag: WARNING: possible circular locking dependency detected 6.8.0-rc4-syzkaller-00212-g40b9385dd8e6 #0 Not tainted syz-executor.2/24141 is trying to acquire lock: ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline] ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137 but task is already holding lock: ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline] ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at: inet_diag_dump_icsk+0x39f/0x1f80 net/ipv4/inet_diag.c:1038 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&h->lhash2[i].lock){+.+.}-{2:2}: lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline] _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154 spin_lock include/linux/spinlock.h:351 [inline] __inet_hash+0x335/0xbe0 net/ipv4/inet_hashtables.c:743 inet_csk_listen_start+0x23a/0x320 net/ipv4/inet_connection_sock.c:1261 __inet_listen_sk+0x2a2/0x770 net/ipv4/af_inet.c:217 inet_listen+0xa3/0x110 net/ipv4/af_inet.c:239 rds_tcp_listen_init+0x3fd/0x5a0 net/rds/tcp_listen.c:316 rds_tcp_init_net+0x141/0x320 net/rds/tcp.c:577 ops_init+0x352/0x610 net/core/net_namespace.c:136 __register_pernet_operations net/core/net_namespace.c:1214 [inline] register_pernet_operations+0x2cb/0x660 net/core/net_namespace.c:1283 register_pernet_device+0x33/0x80 net/core/net_namespace.c:1370 rds_tcp_init+0x62/0xd0 net/rds/tcp.c:735 do_one_initcall+0x238/0x830 init/main.c:1236 do_initcall_level+0x157/0x210 init/main.c:1298 do_initcalls+0x3f/0x80 init/main.c:1314 kernel_init_freeable+0x42f/0x5d0 init/main.c:1551 kernel_init+0x1d/0x2a0 init/main.c:1441 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242 -> #0 (k-sk_lock-AF_INET6){+.+.}-{0:0}: check_prev_add kernel/locking/lockdep.c:3134 [inline] check_prevs_add kernel/locking/lockdep.c:3253 [inline] validate_chain+0x18ca/0x58e0 kernel/locking/lockdep.c:3869 __lock_acquire+0x1345/0x1fd0 kernel/locking/lockdep.c:5137 lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754 lock_sock_fast include/net/sock.h:1723 [inline] subflow_get_info+0x166/0xd20 net/mptcp/diag.c:28 tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline] tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137 inet_sk_diag_fill+0x10ed/0x1e00 net/ipv4/inet_diag.c:345 inet_diag_dump_icsk+0x55b/0x1f80 net/ipv4/inet_diag.c:1061 __inet_diag_dump+0x211/0x3a0 net/ipv4/inet_diag.c:1263 inet_diag_dump_compat+0x1c1/0x2d0 net/ipv4/inet_diag.c:1371 netlink_dump+0x59b/0xc80 net/netlink/af_netlink.c:2264 __netlink_dump_start+0x5df/0x790 net/netlink/af_netlink.c:2370 netlink_dump_start include/linux/netlink.h:338 [inline] inet_diag_rcv_msg_compat+0x209/0x4c0 net/ipv4/inet_diag.c:1405 sock_diag_rcv_msg+0xe7/0x410 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 As noted by Eric we can break the lock dependency chain avoid dumping any extended info for the mptcp subflow listener: nothing actually useful is presented there. Fixes: b8adb69a7d29 ("mptcp: fix lockless access in subflow ULP diag") Cc: stable@vger.kernel.org Reported-by: Eric Dumazet Closes: https://lore.kernel.org/netdev/CANn89iJ=Oecw6OZDwmSYc9HJKQ_G32uN11L+oUcMu+TOD5Xiaw@mail.gmail.com/ Suggested-by: Eric Dumazet Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/diag.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c index 6ff6f14674aa..7017dd60659d 100644 --- a/net/mptcp/diag.c +++ b/net/mptcp/diag.c @@ -21,6 +21,9 @@ static int subflow_get_info(struct sock *sk, struct sk_buff *skb) bool slow; int err; + if (inet_sk_state_load(sk) == TCP_LISTEN) + return 0; + start = nla_nest_start_noflag(skb, INET_ULP_INFO_MPTCP); if (!start) return -EMSGSIZE; From patchwork Fri Feb 23 16:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 775637 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 93DCC13DB85; Fri, 23 Feb 2024 16:15:17 +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=1708704917; cv=none; b=Wbm8oUwBQqm7BTW1jbSaya3ePCYa4OwVUDsWv5kar7R/5VExP4wb72s4pZ2wUelg+UwUXrZasKyP0qt82lTetXX/TrUpKAg4tMx39+h185hdGoCebJ6cq31XVPpKWu5gb+bscMgcY53BcR7/7KXIE4XPgjkniQHyS4X5XPW6EDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704917; c=relaxed/simple; bh=ZSGo7VHZyNR7YikLSbNgmp1YKx0wCf2OokDYsGJL+As=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qgv0sSLclLHKuJTtPsgZ+jMGZ1ymmJx5n45LWKB8c+GEODZTRbS7kiUihKHTbV2KXmDrshRKNfRxhcFqq1rzT1/brozeLayGRMtbBS83EEW8nLIzpE8/YhoExCAJ7HQqucrrjKj0EUE81JPBq/pFDaje+oop2DBW9bgVkYKEUdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JBjLStuK; 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="JBjLStuK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14A43C43609; Fri, 23 Feb 2024 16:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708704917; bh=ZSGo7VHZyNR7YikLSbNgmp1YKx0wCf2OokDYsGJL+As=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JBjLStuKGQ0t48uwI1VrVmLaTDYnoIkrdhjftdozRlGVTAUAgw/hwuczEBCAHnt42 s/7ZzBInK7SOqpN+W+spe9ndugxSgTTgTFcLF2GdTWmIhaegZ/qGReKB08DYSLMcgR o4PVQ0RSpoyENGUayzzKh5g+zccA3yQVpbcUwLLYD1ga/olLjjMPpeAt7YL0yTPGVF 6Ju1u3SfSLPMNK119vSfY9t8Qn3cMfOuVJUUjJyAfsimyUmxBljnYRnwqmhEIyXXol eYRCseyWA+PhfOHGrtbTlq/T5SO2K0j17xZsu9m7CYUUTQdUqb5zUJygsUk88blg3Y L9sDO7i68RI7A== From: "Matthieu Baerts (NGI0)" Date: Fri, 23 Feb 2024 17:14:20 +0100 Subject: [PATCH net 10/10] selftests: mptcp: explicitly trigger the listener diag code-path Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240223-upstream-net-20240223-misc-fixes-v1-10-162e87e48497@kernel.org> References: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal , Kishen Maloor , Shuah Khan , Peter Krystad , Christoph Paasch Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2320; i=matttbe@kernel.org; h=from:subject:message-id; bh=Ne1BFOJ8rufpD6X3EV4YUBWac7B/xdGlwDdg9Uo0pFw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl2MRq0+MEzZSnwev80cxcGJ5DUjoTnWmkQGn+T ORD5K9o/5KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZdjEagAKCRD2t4JPQmmg c/eEEACXKB41A5Zk89fIhexgG1iewjTQEovm2Tk0ABOWuYJ3GncWoL7pzYh+pVQk5PlrilDozrM uQIU/48MtEPJ8JPAXZrhB/cTxWlZNJZiY20Zq0q+QWulujauQOBrc2/ZULjVuTVW1TrAlaIwO16 aU3jjo4zmQg6EpG593OoRFcJgmwi77YW9kJ7z4oB0tx2o3nS/6jABZV/dUP+4SnNAQTyIgy3/sz ruCIS7ZYzYDPa7vogidjjQUEgtVQTNB0X8lDbnVdW72scYgBCLsOWWTUgFZ80qgNGJJsPQXBXKL NJchr6yND2BSHCw4Zp4bvcjfzKUk9zUyFwTnyYWmK5AJgn32fMUisvG38rFs5585NFoGhzqu5ty BixA4nIh08HLtcMd34s2Fho7KVN+Lgpxe5Sjr6ly9pfG8W7WQ3P0NB+1DeB0cWIH4j3Y7nA6BsP 7BdaRdIvgn0M1ku5YMdEHlpnyhuv9cC8uJ0iNbD4GweZfn+SFgVfL7b2B335ZfkFCROOQGurj6M s8JmqDeoC/2asXLQNsB5Bgsmd5P3qxrEhyIwqkvn2rFS/Hm+0DdnoLamLoADPkh7cNDIhcsqqgK 0zghC2hXr+jlrNGOBky+8rXgROoYa8x/n1lYs1N2ovGXh2KaR1BbvvfMKjkTarOsFTpbI9ho5av tqfJ2eOQnUWq4lg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni The mptcp diag interface already experienced a few locking bugs that lockdep and appropriate coverage have detected in advance. Let's add a test-case triggering the relevant code path, to prevent similar issues in the future. Be careful to cope with very slow environments. Note that we don't need an explicit timeout on the mptcp_connect subprocess to cope with eventual bug/hang-up as the final cleanup terminating the child processes will take care of that. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index 0a58ebb8b04c..f300f4e1eb59 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -20,7 +20,7 @@ flush_pids() ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null - for _ in $(seq 10); do + for _ in $(seq $((timeout_poll * 10))); do [ -z "$(ip netns pids "${ns}")" ] && break sleep 0.1 done @@ -91,6 +91,15 @@ chk_msk_nr() __chk_msk_nr "grep -c token:" "$@" } +chk_listener_nr() +{ + local expected=$1 + local msg="$2" + + __chk_nr "ss -inmlHMON $ns | wc -l" "$expected" "$msg - mptcp" 0 + __chk_nr "ss -inmlHtON $ns | wc -l" "$expected" "$msg - subflows" +} + wait_msk_nr() { local condition="grep -c token:" @@ -289,5 +298,24 @@ flush_pids chk_msk_inuse 0 "many->0" chk_msk_cestab 0 "many->0" +chk_listener_nr 0 "no listener sockets" +NR_SERVERS=100 +for I in $(seq 1 $NR_SERVERS); do + ip netns exec $ns ./mptcp_connect -p $((I + 20001)) \ + -t ${timeout_poll} -l 0.0.0.0 >/dev/null 2>&1 & +done + +for I in $(seq 1 $NR_SERVERS); do + mptcp_lib_wait_local_port_listen $ns $((I + 20001)) +done + +chk_listener_nr $NR_SERVERS "many listener sockets" + +# graceful termination +for I in $(seq 1 $NR_SERVERS); do + echo a | ip netns exec $ns ./mptcp_connect -p $((I + 20001)) 127.0.0.1 >/dev/null 2>&1 & +done +flush_pids + mptcp_lib_result_print_all_tap exit $ret