From patchwork Tue Feb 7 13:04:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131485 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 092AEC636D6 for ; Tue, 7 Feb 2023 13:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbjBGNE4 (ORCPT ); Tue, 7 Feb 2023 08:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbjBGNEx (ORCPT ); Tue, 7 Feb 2023 08:04:53 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B0A39B8F for ; Tue, 7 Feb 2023 05:04:44 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id m14so13447284wrg.13 for ; Tue, 07 Feb 2023 05:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=YigoELKCrpUqlWaz+JzApl9ulOjOQ+EyFOAYydAJKAc=; b=IfVVHcp3uqHqEHMUodirLKV+dXsscALBdeOGPQbKFW6YuAquAX6NESuO3GSahqcYWv 7KmTfF2qeaeD1eWvN8U5ylBM5V7qbox8mQN+p8wWvBj5u8hNLVx+iYK0pFmKU9UtOdnT ujhNpsLiblDQ7eNJX1K6CFUipZw0/Is5c2yIBVfx1ieQmiA1aSlFw/yvbFY4AdA3wj9c A4JiPQ7A9gl4wEt84KqtAVLIQfnoYLa/SwbSpJDEGodQsmXA2h1cfGDYUwTgDkvQnd+B pNySZheaW08JAdpKf2EJKXwkDFdKAlwsmklctaEJmXtffXFoocF/b10vpsJf8lvp+e+Y uHGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YigoELKCrpUqlWaz+JzApl9ulOjOQ+EyFOAYydAJKAc=; b=zEgtjd6E6MGXu8np8TO23P/G54UWNovDMUhtpLNndomyq70y11UnsmYv5M0YrRaCfu i5f7rl+li+gskutsbbNVhBC6pS4n4UrptPEXqSOh2x48mj/ZlE/9DNhGyxkW4qMMRQ95 IjFSBzVRPO3cZtTlgOsQDfPao4tAageaH3Ojf9nHgs73fpw+qdV30fNucukFheMUvXNh JAkTGp+3jwBXmKdyrMB/ws1VisDxi862lLJUTNiIFlktONzUAWmAIqScuPtmRDXLzxaj SD453kMqAgKgrydcyZSnHZNRjrTwJesh0TplVT4eEQiZYW7H8OC4H6oRPSK3rnZHKRlw kwHA== X-Gm-Message-State: AO0yUKURtC+As4QYbtQaUmhWFdomyDRfEnykB7WUzWFZLF3Q5vKylCPl 0xphXC77Z4zAoKIBW9IpDFkBweZ941iSYW50pJ4= X-Google-Smtp-Source: AK7set9MJrNmL54fvgoCvb2c3yURh10pY5u360N8noAgikphDF+SSpzSDOjfORofL68VUEULOFAIvg== X-Received: by 2002:a5d:6791:0:b0:2c3:f00c:ebaa with SMTP id v17-20020a5d6791000000b002c3f00cebaamr2686389wru.4.1675775082895; Tue, 07 Feb 2023 05:04:42 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:42 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:13 +0100 Subject: [PATCH net 1/6] mptcp: do not wait for bare sockets' timeout MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-1-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1997; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=BKFYEPn2x47UTnz/1wV7jxosBMkqNJMuzJVlkB5njrY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxo9wElir7BZ5w/IUv9IpIMUHyT6BLACenEJ tIVcWuEAdCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c994EADn03+OGgtrXU/XxOfxmNW5na0cI1MzmQxrlE78RGt7nyu9UXNYGaVzdzR+9wxLK9nFW61 pE4fpwus/sVZlWfwwGavQyzGrq1n5ij7Qp2oE36H5dQ6Nfm6yAfE+02CovR0thRQxR2eHaneBt1 W9U1YDIwqj3X/g3auJ8FIVlj+Ucb2FItNBO7VEu3hcwWU+LQ/kvJG6tR+OzLLVqZPQCcMrt8mTb N9bpDWHWKmXQa0GLqz9Mdo4W/tmvZcr0htX/2TqhqWMgjQcJxJpdkpH9xyEY2fcuKiAcO4oZOxI u5/YMJ418AMs+T2JPghbb7/rULAEZWPcLaL1sA/oCV2zJnCNzepVvPaQVI8zSVwdON0p0xBWAoO vktbXiiyHyQCZyWIkhxmIFUpisvNOnqRnSCAvzvwrI732ONKUTEvxOb9uM1b4mFwvXGaAPbHTB/ nEXpoPCXJgGeoSRVsaRc4Wf1nEyGxnPWS9H+2CUayoajODACyHcMcVrCwcilimCCF5UaUPW1Gex /fER7ayaSNmN0qwQyPwDvbtEZOTTwvF3iBa73l2IPRRK25qwyDMQFZOr6e5u4irG5SRQlrPSof2 JLT8IztvKWh9+84olpjQ7HNn1g6gSTPRj9G0S60GFvcWLNdjZS8F6bB9UN6BLZOVniEzXVaNttT QM28cN8cFKZdsvw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni If the peer closes all the existing subflows for a given mptcp socket and later the application closes it, the current implementation let it survive until the timewait timeout expires. While the above is allowed by the protocol specification it consumes resources for almost no reason and additionally causes sporadic self-tests failures. Let's move the mptcp socket to the TCP_CLOSE state when there are no alive subflows at close time, so that the allocated resources will be freed immediately. Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8cd6cc67c2c5..bc6c1f62a690 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2897,6 +2897,7 @@ bool __mptcp_close(struct sock *sk, long timeout) struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); bool do_cancel_work = false; + int subflows_alive = 0; sk->sk_shutdown = SHUTDOWN_MASK; @@ -2922,6 +2923,8 @@ bool __mptcp_close(struct sock *sk, long timeout) struct sock *ssk = mptcp_subflow_tcp_sock(subflow); bool slow = lock_sock_fast_nested(ssk); + subflows_alive += ssk->sk_state != TCP_CLOSE; + /* since the close timeout takes precedence on the fail one, * cancel the latter */ @@ -2937,6 +2940,12 @@ bool __mptcp_close(struct sock *sk, long timeout) } sock_orphan(sk); + /* all the subflows are closed, only timeout can change the msk + * state, let's not keep resources busy for no reasons + */ + if (subflows_alive == 0) + inet_sk_state_store(sk, TCP_CLOSE); + sock_hold(sk); pr_debug("msk=%p state=%d", sk, sk->sk_state); if (msk->token) From patchwork Tue Feb 7 13:04:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131488 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CEF1C636CD for ; Tue, 7 Feb 2023 13:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232191AbjBGNFF (ORCPT ); Tue, 7 Feb 2023 08:05:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232108AbjBGNEz (ORCPT ); Tue, 7 Feb 2023 08:04:55 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA18D39CEC for ; Tue, 7 Feb 2023 05:04:45 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id d14so13469012wrr.9 for ; Tue, 07 Feb 2023 05:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=SEx05llstpytJjDvzeR65GSYxlxUj4nkxDXeYbz8g1KVIb0Cb3MBtIJKUJTdBiSGxK nqg0ItCQ7Y10GTLXSkh12lZ+pKIWyLIlQv/E46zBlTonmoKx2mWJYGMAuPKguy5a5s38 ZQHKK6D/KF5JrMs/GPFEYrGMjnpaaPp6NQEz/OFGb7kqUnpJ0ZHyAfb32uxjObStvn6m AvLhx1z7UZJVeRMJ6b9cTBP631IM6ofU27EJO1XmaI6VT3fbl57PgjuIwMKP3QGJv9DM jgAz++ZmB77D0h97Ncpwa2l56NdiiCnUQE9m07syabj0j+tTI9faAHNa78v1uHl7Odw9 KWTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=zSPNbG4K4xSLq6MwNPJYKFgoWk1AKj+jALEJ2cDOkhjwEKUJnpkLynqVPb3dfODhTf UVSxrlw0uA2n1GpuQ6zuImJLOOCP7/uym6Da/pizEvO3W6we47AcnvLoN7iY5OaxoAjM kcMOmTv2AzG8X6pF8rcCjN/htj0yLUzFkcCwD9+Qt7tP1PMkXcVG8SSmvZMR6fR5WQrz C0zNvrxeh2WU5tcpkIUB+XWhcbLeeaHxUoszNT+WDL1rPRFlu5eSPuzVMx9xEnVRjiWc GxJiOjkr/FBvb61W9+Q6SHQHIim9G2c2/9C/Pq9GIVRRFmeOy5BDh3fHBGXl+Gvfv+cr gjlw== X-Gm-Message-State: AO0yUKXHsPmSF4/nBLJZ5TnX0TdfF+ONwv8lb06gTTf+IzwwKK0vcWiF eT3khDB+VjKYwih8/sFHGavFuPKFmuUxalRigYA= X-Google-Smtp-Source: AK7set8BACEuCqBdlUhOpzEs9iSk0+Ev3Cz0G1FqEtiOnCLMzuI5nG6VfPyZbe/GjrTiJIW17+B1OQ== X-Received: by 2002:a5d:6046:0:b0:2be:5ca0:a7f9 with SMTP id j6-20020a5d6046000000b002be5ca0a7f9mr2642129wrt.33.1675775083981; Tue, 07 Feb 2023 05:04:43 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:43 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:14 +0100 Subject: [PATCH net 2/6] mptcp: fix locking for setsockopt corner-case MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-2-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1507; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=tU92Z5FtU+rxP2x5Q9J2r5aQ+mvHt8iWMbRSULE+GL8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxo3Fz3M6U+ZqFEqliFhKp6GfvWCWFMRgKtp KfknMVgtAiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c7XfD/43VLBXwdb+RbXPVii16WQ7mY2RSpjNlzgqZ3sBZup/f8WZGkVzNABwdXWm9QMzPNHwEnU kBeYf+UtjhvF+f3lkdU0PZ756cNxJQkbS7VxrzFt5dpy9doA/i8xTeV7TNLnA5NaVR6BGSbXit6 UZzXqoPZRWErMWFN3jcTkiKsbGX2Z+CUSRdo0jh8YLXpZtLt3Slxi5x4Xr3xNv6cFKpUCzDGEAX vPi8JFtfMzVzfQx3R1PK2kGGXE7qmzVJZVrQNwRba7s32pGuYOn4w1quZ9oALgBbNWw1YtxH+5y ZK8JwgaGyxrVOyrREUKORoLrTVkzc8oDze9MGSxQ+Fynn2k+uy9PcEK5blZwGWIRP/ChPU8XZ2P jANo1DCq5XrEqkTP2Qo3b3kwmoFggzZO5H6M9VBCWgjpl+OOF/zYTVZ+bi3RiD1yUWSlKDV4F27 mtE3FPGWfLBedr2gZnIBxjWDZBvaTQL51YgyuPKYMKW8y8lxu+LDG1ExexmXgoqLefI/63OeMdz kRa9NAD2ineJZd5cChSQRpvDIlTcHKyDVUMciS14uuZwA76y37D5NgG8F37JBHZx+HUrymsYqDj NCXByJtLbR0eu8vqlsd7DOGznFk5E8C8sRiVAcGnqjuObFdNHmv7kekqWhcoHGW30OFm78J9Scz CJvs9L9o6bHugmA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni We need to call the __mptcp_nmpc_socket(), and later subflow socket access under the msk socket lock, or e.g. a racing connect() could change the socket status under the hood, with unexpected results. Fixes: 54635bd04701 ("mptcp: add TCP_FASTOPEN_CONNECT socket option") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index d4b1e6ec1b36..7f2c3727ab23 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -760,14 +760,21 @@ static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int optname, sockptr_t optval, unsigned int optlen) { + struct sock *sk = (struct sock *)msk; struct socket *sock; + int ret = -EINVAL; /* Limit to first subflow, before the connection establishment */ + lock_sock(sk); sock = __mptcp_nmpc_socket(msk); if (!sock) - return -EINVAL; + goto unlock; - return tcp_setsockopt(sock->sk, level, optname, optval, optlen); + ret = tcp_setsockopt(sock->sk, level, optname, optval, optlen); + +unlock: + release_sock(sk); + return ret; } static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, From patchwork Tue Feb 7 13:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131486 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30945C64ED9 for ; Tue, 7 Feb 2023 13:05:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbjBGNE7 (ORCPT ); Tue, 7 Feb 2023 08:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbjBGNE4 (ORCPT ); Tue, 7 Feb 2023 08:04:56 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75013A587 for ; Tue, 7 Feb 2023 05:04:46 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id g6so5500000wrv.1 for ; Tue, 07 Feb 2023 05:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JmesjpDIr41PWKtzB6vOyUJvIfGcXoSXXW1ARPTGITM=; b=owM3VR/jlNpYcBXX8SZAxXp1etnWM6U2dXrfws3gNjXUFOyb7fN8PzE3YmG3EI7Yyg 6/8Q66QFBkLywuVTaZgLQ+M3i8Glgkldi0YROlbo3qGt+vn/wmbEDjkQlr+Wh6pW4ny2 MJfwTU/dX8l8Es5leQcD2/8jG7BSJyB0CGKlT1+P7jchzA3TRvUoIZ0IUL/sq4GyGP82 vo1lpuNAQdsgKrMhDVIgoWmeFHkc/vu9zAfjE04M0Bp4SZ31NGfXorI0czA7ZRgzuT/Z uKuq/ZXWUDqTQB2x6m8ZkFQJ/QxjDyFgyVnBmZ+QGwaRB+/WzgbvP+q3Qd066gJQC0Dd +7ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JmesjpDIr41PWKtzB6vOyUJvIfGcXoSXXW1ARPTGITM=; b=Emzdg/cxcWG0Qb/breUi55ufwTbZJHCO5pMpS+/iRgPsOxL+mlkfyWzA8AF9EYmkuB 3DAcmvGOKM1hFwx5chtKKm/DIWEkgpZnD/Y2SeQJSLPj8m6BQDgfSSE6zHztLhG7yflE zqKU4M6poIwkZiSbTXRC9mBdxUqDTtRQyDgzMY6tm201p6si/tGnFi5Lvaz5IzjLuNGq BIOumuqGCKiDYfg8+QRYiNBxjC5u38j9oyodcGCTiRCLq3kUtwk1tbG12Zhe3+MJd6aV gVwDCCtRe/C+AMJv7cqnFQJGHpnW53+xMKFDhyqO5PTl7d3bXf/dN+7He3y4Bl+rGZtI nAxw== X-Gm-Message-State: AO0yUKVogyflRrzrEGS5hLSg18UJqhWZqaXOCujuUIWuS4Kdj/3qA2v0 86cO8oipoz6HG/Tv7Rmlf2ehII7T8JKh89YujXk= X-Google-Smtp-Source: AK7set9+zwthM+/G6Yk0ww+saUL5xnqbN6hgGphVYrxhToDm2a6eruPHUgp6XRQU1dt8w36BxWLp2Q== X-Received: by 2002:adf:f783:0:b0:2bf:c741:5956 with SMTP id q3-20020adff783000000b002bfc7415956mr2476789wrp.19.1675775085136; Tue, 07 Feb 2023 05:04:45 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:44 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:15 +0100 Subject: [PATCH net 3/6] mptcp: fix locking for in-kernel listener creation MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-3-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2251; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=XqGLRd5Gpr7HPf6uQpX8sWyYQO0xBG7RUyxFxCjNxK0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxovoLKV49l0355uwyXmfmFrMmpaxMCjYT6d x2e2nb+W/WJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg cx4JD/4qaEwAHa2J7Ygws0P1+1OO4C/tG0wO+xAF48Op10/BYRxRsw8VL1OyifNuO46USuHEcoK kRhuZsn4dUiinVV7xNUK8zW/yayMo21TZEzheAd9zx1C6ut48HKofQ3XMbQir/T4C/Mv0qprdrQ p+k9FjgW3eph3rq1FUhI5n0/GYGmh54+wfo3aA4Ache57HqU3/K0+4bMix16VEi2sWEIsGh2K4R Xw0FCTdZkh5Rm0xRVQzHgSEC76MSzukJ2T8ggFTOOLdWNbt6wkBv8PuVrWpJjSk+0S1aIu2j1y3 sdvQ/ieBfT4dOzKnM0QrpLRN8pjgxbUg88SHthyfPs6z0yOLaVJxS/0da1o2tRHKP9NVE3S9EI3 9Q41hVCZ1T/7nu1HL3w+80ryzuxAVEFb2QbnVNnQABWHq34iJ5eFKb3N8JkhoBzu0XtAwzP+qta 3a8gNgC0mSUltHexuRf3KgpgUgG9yKuP2wOddCRlTJjt62hW1EBW6KhKbEc/JCMqdMZMeu/xz3s y4md89lL+0ThShZNKZzUhtP+9MTIFeXiaBIMnIk9BR7g1hISdugxKR445k0LZk/L8bkPdWTjBj2 7Q+1Ks8kvhzCztT5/Zu38EUJ8f2QXiwjdyCrrFRAC82ylDIr6fT26MioCzQPilLdUcXHhJU/h80 AmaL9/lyTTi0+Ng== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni For consistency, in mptcp_pm_nl_create_listen_socket(), we need to call the __mptcp_nmpc_socket() under the msk socket lock. Note that as a side effect, mptcp_subflow_create_socket() needs a 'nested' lockdep annotation, as it will acquire the subflow (kernel) socket lock under the in-kernel listener msk socket lock. The current lack of locking is almost harmless, because the relevant socket is not exposed to the user space, but in future we will add more complexity to the mentioned helper, let's play safe. Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 10 ++++++---- net/mptcp/subflow.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 2ea7eae43bdb..10fe9771a852 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -998,8 +998,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, { int addrlen = sizeof(struct sockaddr_in); struct sockaddr_storage addr; - struct mptcp_sock *msk; struct socket *ssock; + struct sock *newsk; int backlog = 1024; int err; @@ -1008,11 +1008,13 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, if (err) return err; - msk = mptcp_sk(entry->lsk->sk); - if (!msk) + newsk = entry->lsk->sk; + if (!newsk) return -EINVAL; - ssock = __mptcp_nmpc_socket(msk); + lock_sock(newsk); + ssock = __mptcp_nmpc_socket(mptcp_sk(newsk)); + release_sock(newsk); if (!ssock) return -EINVAL; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index ec54413fb31f..a3e5026bee5b 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1679,7 +1679,7 @@ int mptcp_subflow_create_socket(struct sock *sk, unsigned short family, if (err) return err; - lock_sock(sf->sk); + lock_sock_nested(sf->sk, SINGLE_DEPTH_NESTING); /* the newly created socket has to be in the same cgroup as its parent */ mptcp_attach_cgroup(sk, sf->sk); From patchwork Tue Feb 7 13:04:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131487 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4845AC64EC4 for ; Tue, 7 Feb 2023 13:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232176AbjBGNFD (ORCPT ); Tue, 7 Feb 2023 08:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbjBGNE5 (ORCPT ); Tue, 7 Feb 2023 08:04:57 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF8E7A91 for ; Tue, 7 Feb 2023 05:04:48 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id g6so5500047wrv.1 for ; Tue, 07 Feb 2023 05:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=Mi8N6Iq2DI8Ul1mH9lMJJRrndmrDMvovgwpackgY4PdmKqJoW0+QLwR3POasUEYrZA uOBTki03AnF5sJ2JCFsG4wFchwFa4Bd2mNSYWCbOodWOdlcZpdcNNIPqFDbX66064UtG UOa76jSMsBZYPs68Cn6Kz+XjInIbVpYcLOeejoV5MuzC9ctkqBHU947UBVFsOQnSU+MT mNkNYB2JZftpHBEv8WGMJohb0WMUblsv4czx8XmeJio0VNwgcufa7AxfspF6MyVfwF6x td5fm0tjAQl1VcJFc1i/eVGmW0oMwUYatCJeQNrdya+9k8PidB8Mu+A2tKmuBwfnUKv2 N3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=Qd5xQ0D8xxUOzZIHjkPFXuw8uWXpYuDoSgY9KwX6fuvrg2K7vf08+ZFonxrHPruhOJ FvQnd9Mxm76+5PqMsR6R2YSB1POCqhRlNImv8Nji1Gib3jW29FU6oWpvTsRJZtUmommS f1MmfKOknDEbSrpFp5D3HbkttnkFFd2PcBkGWe+v04dTKiRnEkegV64iIfKTPy68320i kWC1yidEreVG2wS+K1iCsDZkIrhSeY9h2OV4IrW31mThgFpwIPJ7iImdWKPD55O2NwZQ f4285VOyRuWfw097wQ5ieUbFD723VTlGR2YsQDjYgc+WJ8Z9FHYlNqLgZxkfLK7z+1PK JVbA== X-Gm-Message-State: AO0yUKWOzxs6M/GPU5g59Sy25vUibhGH7kGXfd309IqF41GOMZMhDlar +oRwmMWW5MMGNao02GFnPj6JhzA2nmNtfbCvtls= X-Google-Smtp-Source: AK7set9f5GaKmutrLEu2WZcxvZaneTWgw5s0q0HCSv/IuL41zx278i9qCNPiIyJG3ZXk35mqgnLtJw== X-Received: by 2002:a5d:494f:0:b0:2bf:df72:fe03 with SMTP id r15-20020a5d494f000000b002bfdf72fe03mr3138556wrs.70.1675775086305; Tue, 07 Feb 2023 05:04:46 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:45 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:16 +0100 Subject: [PATCH net 4/6] mptcp: be careful on subflow status propagation on errors MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-4-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2148; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=XAts6+yHbdNSvA+xupWdCh0k36YlOwYaclLeEeUJtYk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxotj/IXQmKVqdQ2qxY/yMJkzCN9cpHlAfkz KxpMx1ZmEmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c3snD/4hsygAbCvAnR+5LM/7q6FyHNQQJ4NENc9Srbahyd77zaYHqqgOZMeIeXIiPIHvFSnN2t2 prsfQQHP9L7XH48Vdah4QsdCxUE5ElsFUcTUIPo8A8we1vlWCF0KgT6Oh4EITgYms+VV7mMOi+7 /zJTG9Fcb6kj9PPKqhTpuLdri/ZqVzsdcX4EiisPtcflwF7o2t/H5fj1zj7d6AFsr3xXA/B5+Ip 41X0RJXwFcNmwz5Wznk05fz6vDmgXij66vFOEAOyLvRVkBd/on11Up+IVZuDF+KM0/FZJyJtzgj Vprpo50N9RFYudzFDg/X0rXbCYtL08ysOjNKr9HBMZ0SCUJAVHhatFlRxHHC34o3OCcVom7deQN nL65VC5VxHCSoclkPHKbjGgvqTqxtoMZQfWWPWvBp6PIrU0DerZXv6e20cVlMBKVrljytPhTRa3 Rr69eY8aVp4HFOEySXCNcSCDugNItDqMAY/uAHluBWzKK996oAQpEMiRF/pAP8GHSR+veU/vx3w 97Ft05WIwrTWByKEkQBlmDhPz4bSwWKV7T0WQV2qsZytyQ/Mbya7Lvugzvp/v3U9w5cA9KxWbfw uUghkOHb8CmK3SYg2YlUQcYGkUXJfjD5/LhSxFrw6GXT5TseAU8B8CB8CwMKbG1YTRUhEzHmpGk /Jql0l/SAPHwc0w== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni Currently the subflow error report callback unconditionally propagates the fallback subflow status to the owning msk. If the msk is already orphaned, the above prevents the code from correctly tracking the msk moving to the TCP_CLOSE state and doing the appropriate cleanup. All the above causes increasing memory usage over time and sporadic self-tests failures. There is a great deal of infrastructure trying to propagate correctly the fallback subflow status to the owning mptcp socket, e.g. via mptcp_subflow_eof() and subflow_sched_work_if_closed(): in the error propagation path we need only to cope with unorphaned sockets. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/339 Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/subflow.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a3e5026bee5b..32904c76c6a1 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1399,6 +1399,7 @@ void __mptcp_error_report(struct sock *sk) mptcp_for_each_subflow(msk, subflow) { struct sock *ssk = mptcp_subflow_tcp_sock(subflow); int err = sock_error(ssk); + int ssk_state; if (!err) continue; @@ -1409,7 +1410,14 @@ void __mptcp_error_report(struct sock *sk) if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(msk)) continue; - inet_sk_state_store(sk, inet_sk_state_load(ssk)); + /* We need to propagate only transition to CLOSE state. + * Orphaned socket will see such state change via + * subflow_sched_work_if_closed() and that path will properly + * destroy the msk as needed. + */ + ssk_state = inet_sk_state_load(ssk); + if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) + inet_sk_state_store(sk, ssk_state); sk->sk_err = -err; /* This barrier is coupled with smp_rmb() in mptcp_poll() */ From patchwork Tue Feb 7 13:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131489 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92CEEC636CD for ; Tue, 7 Feb 2023 13:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232211AbjBGNFP (ORCPT ); Tue, 7 Feb 2023 08:05:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232133AbjBGNE7 (ORCPT ); Tue, 7 Feb 2023 08:04:59 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D97035246 for ; Tue, 7 Feb 2023 05:04:49 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id h3so5644326wrp.10 for ; Tue, 07 Feb 2023 05:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=a0Y8tyC3pK8u+WZc5J76WveIdzupFDlp0O56ysPrgH0=; b=3WoqCjTezdZ2HvWTXpQgaeHBror8v9K25Pq7QMpyvy9K+LXX+CluHaMFg0NR+NHRdd UzX24bpsqKjYuM4wa1XKMkFZM5FT5JcoY9KqpTrz5YPzDmxtMT8lUXfhOcTVGfaBLI/c TnpYs22zIw/Sphcbm2C57LK+UWuNKaLKeQoLdLwAxz1FwJSnK5Ax/HoBeSLw3nGtR4uv PWRkT/DoTbvXfXOfLlzeRc/0We/IjvG+HxeidLe84FG9HelSlOI0wtqgNWsABYoshlEv NVnhpyVOos7i3+UXtlZuuMPF/G0qqhZ+BqOaxmJqtDHU5QWdAOSuIoxeZt267tdR7AVh hD0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a0Y8tyC3pK8u+WZc5J76WveIdzupFDlp0O56ysPrgH0=; b=T2pVQa3HyFgehJoEq7BTSpAjF4rDefhxUgFEFjN1YFXXNkG6DYjU2rfKRdKoYNTWn2 1wwEPcko+FpVBJmzykXRBFuWFD9Rlbg81Ve2k0F2gfBUQ7TYDLXT1zYNU8vKnujsoRRa dNAqZSPW2kKBN7NQ2/83XLOqNuBlTuOKEq1KAWy41zq4/nlpTwsVFCIEJUr+yKslDDV/ YdEejnoQ5WWsAHFjTkxMWdMZkfvmHOWIXEVMBaPcqubI/jkdog4KMajSxNgQY4MnDjJT G/ZC9fazChRh0P9lJ+evWt1c+BR0vxUSi1IV0UgTD71nCeSsI2js9CjoROJg62ffmodX 1b7A== X-Gm-Message-State: AO0yUKXG0KZviiDPCe8814XmudFteAhHNnglm4Az5WIKjkepQbztx5+R S2CeKlyDfrLidaz46mXqFY7Q03ogk1QOKzgMXPo= X-Google-Smtp-Source: AK7set/ScvLTSPdWOiUsdHz4wMaykHV+Tz8Bdlp16+9fg49JaRV5zs3FsOsbnWnbUkyqh01eBwmdNg== X-Received: by 2002:a5d:54c5:0:b0:242:5563:c3b with SMTP id x5-20020a5d54c5000000b0024255630c3bmr2597223wrv.59.1675775087480; Tue, 07 Feb 2023 05:04:47 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:47 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:17 +0100 Subject: [PATCH net 5/6] selftests: mptcp: allow more slack for slow test-case MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-5-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2005; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=AILf6Fyo4IBHsevAQsi9GsBqKL6JDAR81hNQ+zuL7qM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxoxL9EoJ2PfjY7DmpSW0mNFaszQF/VMNcBh wBdajIFnweJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c8a6D/9my65gtxLGq2sJ2h8g+iW00BjsGojU58vmtp2V4SMJb1/Jjoq2D2uiHVVNkA5dfCKTSZk DL8HKJ44dOEC4c7zWRZpRlB8OmCkn29yxwc70IXHjlUJUAdjHgAY65uNCYs78i281cj655/DDJv zRHvr5Ui+3RPE3t5pwBOhzfGOs10CKc2BYW14J7tITTBf/2o8wLrRtiuUNU8rIFPurDPVB6YUUt R4Jvrt9xjzopjxKfDfR7jXFVxZlU3k2N9fKlb/S3WBkO9+O8oNDnOYH9zcUsEXPQEDd8NLEgv2F dhIOWjfDgh6/YUM1v8eNt6Lmq81HNLGqZ7zYQxYzeXxVnlFfQEmkHCqmNrhHzK4gtKWeeq1WpJW 2J/tfS6B66PQWZGEnZ6QStdBEPpoB588DSz2eQ60tO7JI4H7KsmbNLbLxJB/llUPndeN7Hrop2R 8rW1UOSJR5kZ52CjNw8PjtNm/SnRNZjR+MGjNKEi5RMDjgI7d5dP+1o3iG+VMt5QLJ5/QbBoQpr IhI94VCeiWb8+O4X1i/rPCali5u3Cxav9/eiZvwJhZu4f+ghZQLigj0nMJaUxsEg7zcbr9vU96i PogIwvnJIleTjFvgnQT5a67ck+n98yLx0sGytl0rmqZU0mlC37FnHGU3V8Egzcg4yEVxG0RdxnG SC1b0DqfqERZjVg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni A test-case is frequently failing on some extremely slow VMs. The mptcp transfer completes before the script is able to do all the required PM manipulation. Address the issue in the simplest possible way, making the transfer even more slow. Additionally dump more info in case of failures, to help debugging similar problems in the future and init dump_stats var. Fixes: e274f7154008 ("selftests: mptcp: add subflow limits test-cases") Cc: stable@vger.kernel.org Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/323 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d11d3d566608..f8a969300ef4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1694,6 +1694,7 @@ chk_subflow_nr() local subflow_nr=$3 local cnt1 local cnt2 + local dump_stats if [ -n "${need_title}" ]; then printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${msg}" @@ -1711,7 +1712,12 @@ chk_subflow_nr() echo "[ ok ]" fi - [ "${dump_stats}" = 1 ] && ( ss -N $ns1 -tOni ; ss -N $ns1 -tOni | grep token; ip -n $ns1 mptcp endpoint ) + if [ "${dump_stats}" = 1 ]; then + ss -N $ns1 -tOni + ss -N $ns1 -tOni | grep token + ip -n $ns1 mptcp endpoint + dump_stats + fi } chk_link_usage() @@ -3069,7 +3075,7 @@ endpoint_tests() pm_nl_set_limits $ns1 1 1 pm_nl_set_limits $ns2 1 1 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow - run_tests $ns1 $ns2 10.0.1.1 4 0 0 slow & + run_tests $ns1 $ns2 10.0.1.1 4 0 0 speed_20 & wait_mpj $ns2 pm_nl_del_endpoint $ns2 2 10.0.2.2 From patchwork Tue Feb 7 13:04:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13131490 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47780C64EC5 for ; Tue, 7 Feb 2023 13:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232246AbjBGNFY (ORCPT ); Tue, 7 Feb 2023 08:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232170AbjBGNFB (ORCPT ); Tue, 7 Feb 2023 08:05:01 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62A823A5AC for ; Tue, 7 Feb 2023 05:04:50 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id o18so13491236wrj.3 for ; Tue, 07 Feb 2023 05:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hw9n2rz8EZk7Zwt4b/TCgbVGXyOC2ofikV1UOhbOy28=; b=h0oK28sxWQ1yiqlMPhLdbuZWdEiu8VJlzmakwm4khsZ3Pcw3Uc4PYyty82iPHrAEBN vmQhIRRuVpTpUsCLcNwLDmYy3SxIfS8mmABlz5UAWrfpaMFnQyb4LSaMX+inmt5oxUvs PwtEBJZ7HK7TcRCALF0k84zaCwfjRDy6JN0rY0XSJg2aHb8jEpZ2Z1yufZn683gaSBrR uqsB14inHMxquGjIF6L1biGZBTrtDsXUjps0gaBo2WBqT7WBGLknJhVA5n9IzvYhw0rM xKPINz/lHHvwsETQ2x3V//PQGJAAvOhrgMiRwxNe2zf1NZjMXicjJj+YEehS8E4bsA5P R8hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hw9n2rz8EZk7Zwt4b/TCgbVGXyOC2ofikV1UOhbOy28=; b=4IX2YoN3jV0T4gQr4dS57zHV9HWRFKnBjbB7iNbn/ONiv+OR+bQjeY3mz/27GrrErl KHOBIJfTWp7vA6qQvIVIN5Ve8pusHD0kDvIXZO8SPNDHsPsHumIx74EHjIJXaHdkxf/x wxzci7+CERUmAMjHbAYyioj4Kt2HdAdVWnAQuHbDtp8PXHnV49/EQIxpSzHe47fMQtX4 c9zykjdIHAoNTG2QYOaw7FXKNKdqaDqxbGlkfIpfKrlHVRUH5uDBEoUZ07Gy2TCHEb/T i5aM6pVkYCJYhCU5T4dxtE4fNrlwNogsReXCd0mm5/JjyY6Kccwo9S3Wl0gp0RpHaAhx jDxQ== X-Gm-Message-State: AO0yUKXge5RBa1WZ8TjXblke/F0/Z3QCBCVhidowJnWh+jFKFBSKyKKI pq9TItyMkBIVDXaAkcpohvDt7qnITxI2ZwF5qkk= X-Google-Smtp-Source: AK7set8r31gVm7sG7P21njAagUkRUkg13ZEgePjdspPbk83jINW58WYZkT0Yj4PsigiNCJj09jtAaA== X-Received: by 2002:adf:df83:0:b0:2bf:f027:3c30 with SMTP id z3-20020adfdf83000000b002bff0273c30mr2725354wrl.56.1675775088552; Tue, 07 Feb 2023 05:04:48 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:48 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:18 +0100 Subject: [PATCH net 6/6] selftests: mptcp: stop tests earlier MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-6-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2465; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=KTY0Kro9lRunsEJq380yUjc2D3jyyLZ/WohBOjvZgO8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxokI/kZwP6C9bNbWeMsWwDSDCb5JP9QFQRt trEDx7PjpGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c5NDEADmKOaYKUbBF/+HG67xP7kMvxCcOzFsp1s9zGzVvE0+pyXFA2MJIfp3qxHnYQBIuoIbQUf iyCFcfok/5Yqy6eKpWprWVXJ/u3i9GxXgGwDb2zpfqWBzCBrjy3l1Q9IZ/nrZZkO92tMC6BjEek KgTuYMdlTWZuSLP98K0jOGbgiUjZpqs8GVBv0IhV3ucjYowAq6PbZSqtGb6/y6Y9Nhf/Pd1V2ac bLxCSnJCHtqZEdM5iT2EnrTGQkffFuCyi7fSRklOQQ0WSdQ9/1Bahdz2JCVTfdO/QpptzX7UGnU 4GFvMlwy8E7tM3KMAekkq5Z60C059BwSfCFsr6npt/hnxebwWFQ41LMrWo6705cpUutECeYN3LN gWzH3zFXc9jFw3KZVvsiQWC+Oy0OUV6nXNb1NfkRbfzQMESWhbJlnnDX3QW0CaEg2eigLE/ciXw d32t/4ENVtroYL/bmKZMBRDGwPHM2g14GBpJ2Hq0bePkvhjUKfw5JHrTMu4coUHilTn1hS7E5Vr 2t6smyy1HHPGqAnc8bSpLTLILvvkEbVDW0881pcI59kM903uYKlseyU3kkk61kogi1dSXEmJF8j h0PN+ZF9XOlqQkhYiQYaSSSSNdDYy0meih/C8uPQKmD2fS9X1JZE2YLYzJAbrV2U2p/2nTZp/zZ cgAz6jAPYs9n+yA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These 'endpoint' tests from 'mptcp_join.sh' selftest start a transfer in the background and check the status during this transfer. Once the expected events have been recorded, there is no reason to wait for the data transfer to finish. It can be stopped earlier to reduce the execution time by more than half. For these tests, the exchanged data were not verified. Errors, if any, were ignored but that's fine, plenty of other tests are looking at that. It is then OK to mute stderr now that we are sure errors will be printed (and still ignored) because the transfer is stopped before the end. Fixes: e274f7154008 ("selftests: mptcp: add subflow limits test-cases") Cc: stable@vger.kernel.org Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index f8a969300ef4..079f8f46849d 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -498,6 +498,12 @@ kill_events_pids() kill_wait $evts_ns2_pid } +kill_tests_wait() +{ + kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1) + wait +} + pm_nl_set_limits() { local ns=$1 @@ -3055,7 +3061,7 @@ endpoint_tests() pm_nl_set_limits $ns1 2 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal - run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 2>/dev/null & wait_mpj $ns1 pm_nl_check_endpoint 1 "creation" \ @@ -3068,14 +3074,14 @@ endpoint_tests() pm_nl_add_endpoint $ns2 10.0.2.2 flags signal pm_nl_check_endpoint 0 "modif is allowed" \ $ns2 10.0.2.2 id 1 flags signal - wait + kill_tests_wait fi if reset "delete and re-add"; then pm_nl_set_limits $ns1 1 1 pm_nl_set_limits $ns2 1 1 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow - run_tests $ns1 $ns2 10.0.1.1 4 0 0 speed_20 & + run_tests $ns1 $ns2 10.0.1.1 4 0 0 speed_20 2>/dev/null & wait_mpj $ns2 pm_nl_del_endpoint $ns2 2 10.0.2.2 @@ -3085,7 +3091,7 @@ endpoint_tests() pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow wait_mpj $ns2 chk_subflow_nr "" "after re-add" 2 - wait + kill_tests_wait fi }