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: 53874 Return-Path: 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 + 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 ); 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 ; Tue, 7 Feb 2023 05:04:44 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id o18so13490965wrj.3 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=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 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 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: 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?= 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: 53871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836171wrn; Tue, 7 Feb 2023 05:05:48 -0800 (PST) X-Google-Smtp-Source: AK7set+OK9wUjLi8tps9Q4q8km7HgQ8/K65EI9qu6/vjQ+IHGj0yCmSNEB17sV8qKSQXc6kB/6zM X-Received: by 2002:a50:9f09:0:b0:49a:f52f:eed0 with SMTP id b9-20020a509f09000000b0049af52feed0mr3782827edf.13.1675775148696; Tue, 07 Feb 2023 05:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775148; cv=none; d=google.com; s=arc-20160816; b=IeZBUsZAFUXnAlLa2ulTDnZ+VUt+bNand7Fy+Xw/VedJ/6g7/qHTnTlDFZIv1ZvZuu KneNGhi/z0LmxdPqcTBBVHI55UJXgRJEjlRNJKGB9BJq8oHeKpSIfJGn3T66xEnxELFU fmvAzYof6LxB2nSeeB3/DWbaiZfJa2qQobyBr18vXPhw4tgdjX23wFoKLLsjJsMO513Q HFgngVx8+Sefr1YNQ1IVdb0/O24Kr3ncL1M7F5adWPN4E1W4CZC0qZm3IiXpweRB6Gzl nnNt1Q+Un6+Pb44UJidEDJfWDxsXnMP/pJXs7bRaxYEkcG4fSL2kFLDejbYXj2T+NfT/ VC9A== 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=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=XazWiTg0tSm7etQs4g+LXSvn0QmaK9OSMRkh0iRWAKO9aW0HJPClTyguPmnC+pMn2g QpAQ20TY2px9uGHSeOWdsgo+5b5Swp55ibUWimqBsF3AM+hgt2J4UqThK1CIwDdKEHON iDckRIuW3gbeFMelEqSYpiaYCKZ27+2IZVzuOyAqDGvh8pDj1xsq5Y7ZZP7KFWr1v8Sm fUGY1HMXjbpNz9jRNKh+lWO4w0gERSUy1KAfKIeJYh6q06pXP62E6imuwQDBpsX/Ht4P ooTAXck353qxP+qQMlUI3hbFBgWpmcPrbDF2u5ebAuQMIBadsskR27AOz/Nsv6KJ67o/ Q4Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=SEx05lls; 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 er22-20020a056402449600b004a21cd9fef7si15276712edb.323.2023.02.07.05.05.25; Tue, 07 Feb 2023 05:05:48 -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=SEx05lls; 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 S232152AbjBGNFD (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjBGNEy (ORCPT ); Tue, 7 Feb 2023 08:04:54 -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 774023A584 for ; Tue, 7 Feb 2023 05:04:45 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id m14so13447322wrg.13 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=u/Vdrq5uLfHswBR2HwZLHQOGDA2OFuE/muOqZJ7C6lTZ3HKCs04j7MUPeGs8OqOim5 Lg2tAhXCLiwzytSWaaPZu8UjI+3jXAsHahJfKulYOIHWMLcNpo1UAABkAoiRnSU0RXzn 2XTpOHCkb+DeThGlcREXj85zv4ETdX5GPEpveV8inu9Fu+SseRMp3KXIOYRjf8q7IzXo arUysqmcDKRIpOX5RpiQfej1Km4jnmH4oE+hQmtb9oVIQNrBLshamWyQaZwHzYpYkPF5 L/Im83PMRv/aJtzQMYhZ3WlaIHJhyzunk9AsUK3me0bf58id9W7h4qhq283MLgPn41sq 10zw== X-Gm-Message-State: AO0yUKWPKiVsHQK0Eg5k9u7gzsNfD+i22suplhkh8TsMvZoZBv4BhSDN Urz+4a9vLaUlDV2F5kVzqtdgtQ== 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 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=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177602199154181?= X-GMAIL-MSGID: =?utf-8?q?1757177602199154181?= 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: 53872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836206wrn; Tue, 7 Feb 2023 05:05:52 -0800 (PST) X-Google-Smtp-Source: AK7set85QLTKoWLetWNpbyMDK778cy7OU0C0VAbaYrM7W2NpNzugPJm5xvF9lsA+ALPGd34m6AyK X-Received: by 2002:a17:906:ae5a:b0:887:d8b0:27c5 with SMTP id lf26-20020a170906ae5a00b00887d8b027c5mr3429929ejb.52.1675775152052; Tue, 07 Feb 2023 05:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775152; cv=none; d=google.com; s=arc-20160816; b=fwSBy67mwPC3SgaDIuT0Lpvw9a88DXfmBEjjHc1ZCLY09hPHOp870oFFPj5Kt4a/JM TzJePnlE2ifQD3rP365NpGhStGNFniMB9J+bvFUZNXLtNN0yb1FWkl6tC8cN0RigVPmM k596Di4Uk268G+72/f10cnI+fAJ64NgTQpU5oU8Ym7pwN3ADj3Fv3vi+qpdtWLZD2/79 HmVaKz6TcS5C2ky+Nmfd6EQ/i1zUnScm4w8yui2M8XhFYN7kGPGoh7fB1ePfIC5MDcgy F+CHlNsMkdz9GtEBFrN759RI7OqpwprmQ781wEoVL4lfKa3slG/C3q4jnfedX02IaVdo W4Hg== 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=JmesjpDIr41PWKtzB6vOyUJvIfGcXoSXXW1ARPTGITM=; b=BgpKfb7xeckxrEwiY7dE1rTYoBC7/Wv1zIZcsJilPz4c6M8AGLshftD69G0o9NRX4V zw5hrDMOhhQn4nwyIvC5M7ZJ8XtjgX2PxAKAZqMNTKRuH5ZvXUx18jRu6DGCgFYvov/1 qTc0coJ0OAyqwqTdFNVazydPkjIfAXPd+YwbsK0w1vrjHGtos29HpUz2qwTv1Zg5pPk8 SHHOxCjUXwA0knQst8rMJh6jxEmMaOX6PW4bdO2s80A3rBczE/vzYDcWPITIpiwzMfAy pdS88Pkm7+kzz2JiEkXyJHs+5K7DJc4omlqx91HG907rgmk2Y+bgg486yFXLvM6WZjIx G6Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="owM3VR/j"; 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 k2-20020aa7c382000000b004aaa94fbe4bsi8458236edq.385.2023.02.07.05.05.28; Tue, 07 Feb 2023 05:05:52 -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="owM3VR/j"; 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 S232144AbjBGNFH (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbjBGNEz (ORCPT ); Tue, 7 Feb 2023 08:04:55 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5F139296 for ; Tue, 7 Feb 2023 05:04:46 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id i5so6312675wrc.0 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=1S1VZ+hHoVQZLPqZBKGizuG6uM4yMKgSnsIu9222S6tzkjfZoaCQ3SXjcB0NmMnG5K byRmrjEkzKJ0M5tAS4pbVb4kpVBWJgpCYzMzRzp5Mz2uwvqsmGK9InD2PNjJxkbQQwqg DEzlkry5t1oubhcslCoTvZRjI+gIj6XfsWpN+VQdaPFNNDYju/YEkDY+C6ggmzBovX3K nGhl7pk+0B5X3NNJV5pKheympTjxH8qWN0s6B5T/x5uGz0VS8O7yYNsjh5djSe46G+fH RTiNMYz9zflW1IUa0XSeWIFCGu27F0fVgknBwpzyFclHfS4VjSGwuAiPf1PtUDqTa7HJ uCcg== X-Gm-Message-State: AO0yUKVRz3wIBhgwNqq+T2AhKBjjRspN3eZPqWK/mkUmOecH+7r+stac TcEnUBguy/U/NqvgcUUDkzukHA== 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 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=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177605785684012?= X-GMAIL-MSGID: =?utf-8?q?1757177605785684012?= 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: 53873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836241wrn; Tue, 7 Feb 2023 05:05:55 -0800 (PST) X-Google-Smtp-Source: AK7set9cKieMz+b9ALw9CKue++Nrz0CDiY9Weax+sG7egi9LVg5wXcEge6c6J9sKjJB/GARPKg6X X-Received: by 2002:a50:99da:0:b0:4aa:a72e:bf2b with SMTP id n26-20020a5099da000000b004aaa72ebf2bmr3221602edb.2.1675775155026; Tue, 07 Feb 2023 05:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775155; cv=none; d=google.com; s=arc-20160816; b=D6RtPuY6XzRChfsEG7iQwnFz0Kzf95QQ9YmbvsAM8W2fhfO4iopaOx+KWX7TWDvJCr Y5uLCOQCJTls3oOdacHNW3lnTozxbjIMtYMYcCWGe4uGePJQIELTJj8DVIBWuHyEqUpC QZ6AqR5kSGfpICVWvN2RoCtgOSX5KJTgSVDBu0GT5PVGupwqnGtBWyEBJajoVk7vP2B4 ZPvVnmBcxAUhZViPOdMPa8pceVnmdjCLXWzldkvHEvbtOpUjkLPHm6A3gfWFU4kA1poh IDeRUS4FUkEW+d5OsNK6OqovNToGqHBnVSzRnpZrlcRHaMvIIgx+QpTHAQNSIN4U5Bsn wUxw== 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=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=bcEDvmi5Jzt81nDtXWr/V4i2cooSQcPMGTZynnxBQ0P6hGQcsBckWKtPZbKyw4lR83 n3D2OkBf4Hou936IKjzxQ9e5wxdSF3ojU3GJqLR0TRzfOR2TIq84xifyHjyLtKFsUwfK XsIJBKSmZH7Uz4l7NICwX2t8pkjoc3dXZmqYbU1AYJMPEYyW5TYBt4GpoQRr6b1ejUkG KAabQ0KS7/mJMkXxZa0sZOJNBuAlBKnD/H5YjuMpGRnH5I8rk1pfACD9UEWNrZnIqgX0 8rntn1HdjT5aawZqxcDgJycYC/yFuB1vRex+jS5xHE1y7+YHCU1uOVdcE6VQzW0dD9tD misw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Mi8N6Iq2; 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 10-20020a170906008a00b008814f25d095si18633348ejc.71.2023.02.07.05.05.31; Tue, 07 Feb 2023 05:05:55 -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=Mi8N6Iq2; 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 S232194AbjBGNFL (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232128AbjBGNE5 (ORCPT ); Tue, 7 Feb 2023 08:04:57 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DE33A58F for ; Tue, 7 Feb 2023 05:04:47 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id k13so6077348wrh.8 for ; Tue, 07 Feb 2023 05:04:47 -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=IHMzI9Y6Dvnj97qVVJgsRo5GZnmQXWH943p5GIk+NTpaHZcnoGKq/w+li9AfzSJpNI +uV28dZC1WltwTjnv8aKbddpGKfuVRuHr3ogEL4/K9MEEoKWlltmUfx4fK3VEONfLSAP 55JPqzKev6iMslRyT3uXbr3+olcZGygS0BrEiH79tdKS8jk2K8BETJcgUu7O5TZ4gDrO EKAb4yO+Z1FFCRezlU5CTBP59EAHomxD466EzUUrrspV8RNhgIZk9PIUscHr0rMT5NtH 4PdGGhJo4m6ofk2imAk3RG0K7zQjeiuhBEcx7mZP25DoxZEHiRT9PLaHYgnF9uxpf4Yg qAHw== X-Gm-Message-State: AO0yUKVim9NzpmlvSHYd9VGIsJU0mV6/qDES32l1Na/RA7ladW3wQ/4+ b7B6UqSU8ZtVbA/qyqDnDi0wew== 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177608715493224?= X-GMAIL-MSGID: =?utf-8?q?1757177608715493224?= 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: 53876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836509wrn; Tue, 7 Feb 2023 05:06:20 -0800 (PST) X-Google-Smtp-Source: AK7set+IIDKSRylHk9oTngpg5AjinqRjVsNY8Fg9XGroe2MmKgg5/K0/gvtINeNzqAsL2Z9Qf53Y X-Received: by 2002:a50:d0db:0:b0:4aa:a767:798c with SMTP id g27-20020a50d0db000000b004aaa767798cmr3612962edf.0.1675775180674; Tue, 07 Feb 2023 05:06:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775180; cv=none; d=google.com; s=arc-20160816; b=XlpvYDQcPGiUt0jCU0zzvQZkTxdFV35xARNCUa3Qb9/jiEws4Up7hEWGwS4svHRgsK MDUMJ75MjGurLn2aq6byQ+ny7i6okFwM4nrU800IYR0kbEU2Rxpr3trZZUgeDlGS3UKz ORWH9WByXwz52+n5eFb+nWnwyPxCqlTg2ubrhmM3Y9hKXrpnyMHdvSGm0zh9QjcwcxDA 3AawJLrSRsqnGzw/2oX4jT3uhZ3Bn+e3SVvqmSXIRf95SymqyOSl4YTrtrkR9kxIotb3 LnFw+nkgC4YaY3rNoYsFkQJy1JxcyQwNg1xiCviXZx6FIx1/TOI5fi7H+jmlK6Qe4c5s /zFQ== 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=a0Y8tyC3pK8u+WZc5J76WveIdzupFDlp0O56ysPrgH0=; b=NlCrp4TIGr2ADJz1cXvlKX2a950bM3AdkPqfUGyie/pZYxVwVDQ2ydkraMw7xi6JGn Z+HyUHIX+WzZcU9jMJ8uWP3cr9LU14WFfqoKesN17l339lzEujkrBzaGHuLs3mumNVLP MpCCXyciz+D5d/Vt8excC2OE4wHuIceFjm03AujLCwbyJelvQGE/dDllQ9W2Ux1J5Zpn LYEqMihmFaE/dYBEWGdxFC7RtQqmMf0QurNJ9Jz7qO9icRrU0MkeWnbXr8VYsEyAHn91 frX2wqwaf+oec8hmD6Wu67KSqe/lP3zsHv+0n2wPPyIeHQvxs0K5l9HOyuGjv0B3scs0 LBmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=3WoqCjTe; 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 fd24-20020a056402389800b0049e45a5ad04si15746422edb.290.2023.02.07.05.05.56; Tue, 07 Feb 2023 05:06:20 -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=3WoqCjTe; 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 S232212AbjBGNFP (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232140AbjBGNE7 (ORCPT ); Tue, 7 Feb 2023 08:04:59 -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 E618939291 for ; Tue, 7 Feb 2023 05:04:48 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id o18so13491160wrj.3 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=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=Q67GHV1O5QVZnSNwhv9xpKThbKziGa2j3wHD0L13YXg/dN8CYjtZCt1leOpA0nExME dA90ZaqBGivdQplbfIIMNp5zo6pF7fctucH6eOK8OR02jTAbg6Tcu2iUq7qtl5S5VB/i LOzvaCINVK/OVQlL3sKqyQUQIo7iOynRSROM6DWUGCPxsm+x9bRxe7meuGPr8wOPfVer 5uvJ03ZzAU5V/gJDj5NriUtz90p3NJHGnI6EOPgizyBY0SlbfWZ/74bF8GcXUSWsBhY0 zOrOY2wyBT/I4v+B9BQgVrGdNGZZIiAki/vbF0e1r19lmd+GSTt2tOqbvDzvze8fFLh4 o78w== X-Gm-Message-State: AO0yUKU1Gr2bPaGS25747HFffdsraXANF/6CPFr7mXuhWOmjmgIwSrRm Fk6t0gOZCiavesJgZe6aoEhBqw== 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177635640170310?= X-GMAIL-MSGID: =?utf-8?q?1757177635640170310?= 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: 53875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836377wrn; Tue, 7 Feb 2023 05:06:08 -0800 (PST) X-Google-Smtp-Source: AK7set8g5Jxppu3ZCxgYwRT2GzFMyLmxA5NupiRFjnTucde1QMXJTjfvwFQfl6mRXJkpfEUlrXuD X-Received: by 2002:a17:907:97cc:b0:8aa:bf4b:f968 with SMTP id js12-20020a17090797cc00b008aabf4bf968mr137175ejc.16.1675775168364; Tue, 07 Feb 2023 05:06:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775168; cv=none; d=google.com; s=arc-20160816; b=LCJayrgiIdnAjcgdWF/LcnMdzqLrhYgBxmmttkOadQIKVyKGLVjIergMfsf6LHgwaH 8SS1GUJ3YPeV9vTWwZucEvtqB4aQBb+wSuYfy+TufQu8/Je5A/nLIaPCy5y7GKERYBy0 csp49IFFbepnk+jitqb5i/ypGsl+hcauUcekTG7fqWyv5BjDGZSZluykpT8aqEm+R4Sr fxjAQYIJ/FFj0lP0lKc5AAiIgSYWnZpXw2RGHUuad1yfS1CXbh2ZyMQACsgeDOFkd/wN qq6etzhkr8hhkwopEyEIJb/aIEzPJe854WyQqLVBzNGe5feFWLJ9JU5arVV4mDm/Tiw9 Hb1g== 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=hw9n2rz8EZk7Zwt4b/TCgbVGXyOC2ofikV1UOhbOy28=; b=GK3NqN9Hj4kUk9+oRMFQAp2K39v0qtxQmHvM4A4eZ0xUFT5i3qMas6GCcVn7MRpvWW 80hYuOAh5KNFSEB8JdKZ8F5T7Rojo5BiDUjmtx6VJHZUFuiGBluUm3mBfkd+diCl4wkd p8Rf2zfosB8Zv1+JbzK81PDWGA5aZfZTrqRCLY9opMUnpyWaQL6hV7pYm7aJXu0h7KD7 3Rp2C1vt7QAAKU5uRGP9bZcLFpFC0E/V4kcDECCzevYXAWLohBbOjOgaawTU7Gh9BaJi mNgCtdzgO/7RVKcOd1KHdpG7HD+LUqQJRKL9Wts18mvepWy/JOWAD48cN4JX/4dahiZ/ ty+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=h0oK28sx; 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 mg12-20020a1709077a0c00b008aa00ebb13asi1450525ejc.23.2023.02.07.05.05.45; Tue, 07 Feb 2023 05:06:08 -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=h0oK28sx; 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 S232236AbjBGNFW (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbjBGNFA (ORCPT ); Tue, 7 Feb 2023 08:05:00 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7423A5A6 for ; Tue, 7 Feb 2023 05:04:50 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id a2so13209125wrd.6 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=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=Xa/VupuWDSY6xq/wjk0CnxNfxqjnTY4SmpZTYlm7vF/1i3u2wDB2OvD8Y7GpOLBfwe LpsxLajqgDwvFhYT8KdkxSwgGgjlMw+ILXW5VHQkZcHP/7n+T2yhnLNh1+UuSF9nvFn2 +qNembZfRZU6so2sdmd7Apin9jau94blBphKaX88OlOZOFDiUnOQIrrCZqxqKHrCww3u 8SH12cCKUOYIhRcKtHoU/uHvbXV2qnGrhem0WmbR8Nn7RQXvEKnmk95e6UBS4s9MKmru /6VGcicpE3DKOJLrrg3tlde1X9+Tsm+99B8Znzs6jV1KHtKUbTbyB30qaAoEU5tmLcX6 ebdw== X-Gm-Message-State: AO0yUKW0B1fpFfiM8llaCRBM/JPSCz/xxZmwjK58nIgg3t16dVzyRXdL jsQFBskac7rp/ScWsUVzLrQvag== 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177622925880894?= X-GMAIL-MSGID: =?utf-8?q?1757177622925880894?= 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 }