Message ID | 20230207-upstream-net-20230207-various-fix-6-2-v1-1-2031b495c7cc@tessares.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836295wrn; Tue, 7 Feb 2023 05:06:00 -0800 (PST) X-Google-Smtp-Source: AK7set8O4JJIFlT7p8vXRVk/oZ2X4X2cjMqgcMYs0Bj9m4LhDD4biMJFyYpsucLT6BK0bnZ/g4Mn X-Received: by 2002:a50:ab01:0:b0:492:8c77:7dad with SMTP id s1-20020a50ab01000000b004928c777dadmr3601821edc.8.1675775160405; Tue, 07 Feb 2023 05:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775160; cv=none; d=google.com; s=arc-20160816; b=pvuGObDBHLEiEsAM1TznoWqOao4GJ9grl+k3d5T2qmI1LaztQIS0lKHto4N3UWnyte cqzNsfUQbmR3rMeBNFi+ifUQeBiutbJTm54tmHXZup5053mFfY3SHGfK8Qrr9vhl8buV CAQxkyxxDkwEPVzjl1KVTCC8Wfs7t7gt2gyQC5QAAY1VbIL4B0c5i0sfWU4XhoDIPjFJ 2O9pnTpDKwnUu6VJfswY4zW4mtsWhRBFuUug2nLiBM/3755JUTX8ISV1FXkaghk6ADC/ ZxfdQGDk7UBnNIE/lJruuytJvAXDdwlYJYpETHHxb1in0nAKoIkgnK7FOz1GJiPFY5bO gs+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=YigoELKCrpUqlWaz+JzApl9ulOjOQ+EyFOAYydAJKAc=; b=TA/5dTqBYKIgKSXK9AegZYXbITtd50p+dQ5qrjyLqIqePFcWXbZZZOcFNou7Hxu374 aLMWpI5GgE5aLK7YN9pK0/VAtl7tOFdjVf+gb8XrqR+tMubsnZ2nzE5DMenBY53PKoHn WAtnWnqAI4axWkQMJozOGsw1YG6e3oJIqJJRl6tPeDBYTzZ+TsofV/gZSPLIrJ3eJnZM GIWqnQsS1j41dfFMHpM3gjsGyZa+SlF41MTXDsK+qjlZaHlmgGdvIsue9A/z7f73g6PA tbQhkhM3ksgvXuIIpEVHGOtCQhDAOiBIeFKtiMsCQb1fqmpdgktXivnuGgbdRwXidU8f kCPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=IfVVHcp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a056402271000b0049fe17759bfsi20237869edd.230.2023.02.07.05.05.37; Tue, 07 Feb 2023 05:06:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=IfVVHcp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbjBGNE7 (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Tue, 7 Feb 2023 08:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232165AbjBGNEw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Feb 2023 08:04:52 -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 664E73A592 for <linux-kernel@vger.kernel.org>; Tue, 7 Feb 2023 05:04:44 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id o18so13490965wrj.3 for <linux-kernel@vger.kernel.org>; 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=EDNiogtYwDAsbBfstNU6VmG1NBQ7XGR+Q2pyH4PEjCvuiZ0uq5XZ+5il0ckj5zVzYt GQ8btOVu4bIEdff5UVi/KvLNojSDgY+5tUhL/1PO0iYNmAQh2exWKhzakdbycHgGDxnq CRlR2u1rJ/eeEUYAKhIlbhzwvk/J3E1PAz0iXcMqumVC/GTRneRcCLuxSvjqm7KuihVd aEsPZDTWi12RePznReJlAiakT9JUnbr/zCgGw11QE53+lkmJM+mayb4qur21Gkgc35RN Qwnyxn44otQqNNo/5W3Q+yE1gJZ8qKpraX39TweJIsj5k2PdpvDpxXdKOXi8k4SvBhvd xKsA== X-Gm-Message-State: AO0yUKVoU+Hy6Pic4Cn8LFVgeoqYYurZFDWfR8CQNXEtaxnWzzSAU9n7 xQY05QDDYpuY0dwHkxE4yWDk9Q== 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 <matthieu.baerts@tessares.net> 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Davide Caratti <dcaratti@redhat.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Benjamin Hesmans <benjamin.hesmans@tessares.net>, Geliang Tang <geliangtang@gmail.com>, Shuah Khan <shuah@kernel.org> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts <matthieu.baerts@tessares.net>, 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177614608048240?= X-GMAIL-MSGID: =?utf-8?q?1757177614608048240?= |
Series |
mptcp: fixes for v6.2
|
|
Commit Message
Matthieu Baerts
Feb. 7, 2023, 1:04 p.m. UTC
From: Paolo Abeni <pabeni@redhat.com> 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 <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- 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)