From patchwork Fri Apr 14 14:08:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 83430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp414114vqo; Fri, 14 Apr 2023 07:13:21 -0700 (PDT) X-Google-Smtp-Source: AKy350ZPwl+GC13vB8TBnsscPMIU8ZWBQ8f+XIj7ENienlggOCJAQboNtJSh178q+OEHhJ3vheT4 X-Received: by 2002:a05:6a21:3388:b0:ec:6649:3668 with SMTP id yy8-20020a056a21338800b000ec66493668mr6978824pzb.56.1681481601395; Fri, 14 Apr 2023 07:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681481601; cv=none; d=google.com; s=arc-20160816; b=UrLn13mqNWf0b7tQojqg/l1+Z9AS5+qcsVoOQoSkNOA0rrRyevgQW9Sue2jA7f1br/ RfMxIiKQS8ejFsWCF5gTSaUGzFf3TMh6zN3f4Q2vWJuhM9EOUHtt5jpXh04dKoqTWnLm yTOQN2ozlIAU12ODPbyC0TC3LPrrnMMAbtMNgFXQSxh7JuS3BPWX0HWT9CVIZH1EwYkG E6GfLoxn+dQ2EuA/SScqTnSVGy+LcAfZhR35W0XPdyGvAdOO/dvpIPyo3KZhy9V4J4Ur blNmUU4jCOTY3D/RmvSAALe7b0u9wpzebgUJOJyZWyZ7QotyCD3ulxM0ZTx+IdEwg9eR RGuA== 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=dmK0FCUfNmeHXQ4DJ8Hz0byh7p8vyN8GhI+Kn6kA5ic=; b=MtUT5EoVZsk/sxc1h5gqL6lZyQ504682hKbH+PcMyvdN2NzrhmXWQ/FkYEyFZt0E6o Mk5Xry4Oc+/ymHG2ENDMRGsbgNM7b3uWNb9PHeRem3NqidfLoD6E86DlW95/rrkvoxtH Y+kwbs5UcD018xbti05D9aHra4qMfEwN5G89dS432VG7HGSX3UZqb0VFi8meytRYvKAZ 0L1NcFlNbLHZIognKm5y1xA/umep8DOUVcnnY64TNDf07bDgnWkhRpvI2kcGHH8yiaXg R+1P13yCaod0gZxGZ39SvLwJccC7/1DuUMWvUPkIYrO3Cv8FH8cuCIOrSuZdF94nCkL+ +zHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=qngY7ZD1; 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=REJECT sp=REJECT 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 w64-20020a638243000000b00518cf8916e2si3687282pgd.415.2023.04.14.07.13.08; Fri, 14 Apr 2023 07:13:21 -0700 (PDT) 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=qngY7ZD1; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbjDNOJL (ORCPT + 99 others); Fri, 14 Apr 2023 10:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbjDNOJI (ORCPT ); Fri, 14 Apr 2023 10:09:08 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468FCAF2F for ; Fri, 14 Apr 2023 07:08:38 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id v27so8426449wra.13 for ; Fri, 14 Apr 2023 07:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681481308; x=1684073308; 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=dmK0FCUfNmeHXQ4DJ8Hz0byh7p8vyN8GhI+Kn6kA5ic=; b=qngY7ZD1pySsHI+SAimaDsNO2GfF1aBNavcCotGj6RdfSeKnt4YJQkhECqjrPwvKyI ndDoTuaPtt+tyGY/v+PVpKunlsL+oNr2CURiMl7B6Z6LBAUc9hvzU4To8Qu73jiyQ9mA 9PbM2z8jwDYYaBz1NktgHk5QXskA/YewaLddhgDC7F0WaU4YxA4+DRW/jt+WkPZp+gtj 3o5ajMHfd3NKcF0+MDEXbbS1ArNBwWtc6KAuG5yt/o9cTjY9Y2xhu/uyT3y7sQHRxzue YYc6ucBESWMBcn1q20hDULFGMAUTGovrsLek3Y+QOCZoTjzFuBFijgzIa3ZwWTOsOYs5 ccVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681481308; x=1684073308; 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=dmK0FCUfNmeHXQ4DJ8Hz0byh7p8vyN8GhI+Kn6kA5ic=; b=klpSoQlUTeZvTHRNpNRYJOtSA9ErmaeCwRf9UrKbu8V925/MXkazuYkmA600RjYtGr r43STclp8kjaSt5bTfdpKpqjw94chO0wAtzDV+f7du5uc7Opub2R2INLCXcnfcMO4lPm FzqS5NB1GOb7d9w+oIk87GzCCYn5ozVtshMAE++htkIc9CrURw+GRHOK86GbMtTbYaEr 8khOVM5PqAJmGk/DyMx0B2PTvEmDigOb8lkseXdgW9+OapFru+FWXtJ+I2y3MjuB2a/d n7lfmCUVIGtS2wwq9e+xW7zBiVAAIYhJa2QsY0zF4po5r5S9/SBEs31TGTwBaX+0g4q4 uABA== X-Gm-Message-State: AAQBX9e5x8FRMugP5xfnfv+JSHI0LNZ6mWYtuomTFE8juCmHhrkQTnAf 3nfRJoG1rPQAJRbCVOg3GQU/2Q== X-Received: by 2002:a05:6000:182:b0:2c9:b9bf:e20c with SMTP id p2-20020a056000018200b002c9b9bfe20cmr4061444wrx.2.1681481307476; Fri, 14 Apr 2023 07:08:27 -0700 (PDT) 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 o5-20020a5d58c5000000b002f47ae62fe0sm3648185wrf.115.2023.04.14.07.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:08:27 -0700 (PDT) From: Matthieu Baerts Date: Fri, 14 Apr 2023 16:08:00 +0200 Subject: [PATCH net-next 1/5] mptcp: drop unneeded argument MIME-Version: 1.0 Message-Id: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-1-04d177057eb9@tessares.net> References: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> In-Reply-To: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ondrej Mosnacek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3214; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=MaZ06pjF4key6Fm9pULF8bD6R2n9RR6/Lph50fcV+5c=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkOV5Z+BGDys8VB1jwJ/I95s1ZAbmqPntjUxuM3 BCQfTkfm3aJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDleWQAKCRD2t4JPQmmg c2PGD/9a2M2J4FmsqD7mq031j8Cw/jOwb1MYLrqouMG34GWmqBSZTRN2432RuVEXzlqWl7lcF3P nK4fXBnc+uB2G3aky9mhS5WCebwI4/TEmXJ0p0LJNdtTHxpzK0Jqmi1A6Idls4fKqE555Y/sgrM OLxVbunskkX7fKVFj84sKxCWPEzi/vwUt6g842ntgziVq2ZnWdtpamTO9E1fJxqe47Mvm0VqYtk fkFvCCaWhWEAemff14JdYiiPggwsomZI9r9ky8piC8QdthtS4mBLidupihPLpvS9kE/aKqAr04q d/TlBOp0vYTOUbAj0qGnCcpYleUowgtXgPGidKtt23qU2sEapehdyPFpHw7CkwUGrFc75LMdPr8 2LIzOgy/bMTPJDE/sK+JlTSSIFIprz85cQp8ImKf79O0Lvc2DSRSsuFMLrnpVLRzW+mfrTzOn72 lKdVYua8JSYcSU77iWhTMNBgKJ2NZk4rUHkSQRouiyHNjDytlxoTitIskjhH1ZINJ+I8aJtLhj5 JDxlsyiLqumzsjP2D+56JYU04mE1CTGhca/+xkoSbTYGTn4asVFpKtz7Eh7pTimaM+mJmRFxKTf 1L0v/7WBNNtvxhXJRrusDMNrdwh5zTHpUDSrXb8xmyQukbzsiJcq5Qr87VXD/LsuCCP2JyHQ6eJ Bag0J0MVQK7B4Sw== 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,T_SCC_BODY_TEXT_LINE 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?1763161251591589005?= X-GMAIL-MSGID: =?utf-8?q?1763161251591589005?= From: Paolo Abeni After commit 3a236aef280e ("mptcp: refactor passive socket initialization"), every mptcp_pm_fully_established() call is always invoked with a GFP_ATOMIC argument. We can then drop it. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/options.c | 2 +- net/mptcp/pm.c | 4 ++-- net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 355f798d575a..cd3b885c8faa 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1001,7 +1001,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, clear_3rdack_retransmission(ssk); mptcp_pm_subflow_established(msk); } else { - mptcp_pm_fully_established(msk, ssk, GFP_ATOMIC); + mptcp_pm_fully_established(msk, ssk); } return true; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 70f0ced3ca86..78c924506e83 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -126,7 +126,7 @@ static bool mptcp_pm_schedule_work(struct mptcp_sock *msk, return true; } -void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp) +void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk) { struct mptcp_pm_data *pm = &msk->pm; bool announce = false; @@ -150,7 +150,7 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk, spin_unlock_bh(&pm->lock); if (announce) - mptcp_event(MPTCP_EVENT_ESTABLISHED, msk, ssk, gfp); + mptcp_event(MPTCP_EVENT_ESTABLISHED, msk, ssk, GFP_ATOMIC); } void mptcp_pm_connection_closed(struct mptcp_sock *msk) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e1310bc113be..a9eb0e428a6b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -782,7 +782,7 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk); void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk); void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side); -void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); +void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk); bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk); void mptcp_pm_connection_closed(struct mptcp_sock *msk); void mptcp_pm_subflow_established(struct mptcp_sock *msk); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index f46d8f6c40aa..80bbe96c0694 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -850,7 +850,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, */ if (mp_opt.suboptions & OPTION_MPTCP_MPC_ACK) { mptcp_subflow_fully_established(ctx, &mp_opt); - mptcp_pm_fully_established(owner, child, GFP_ATOMIC); + mptcp_pm_fully_established(owner, child); ctx->pm_notified = 1; } } else if (ctx->mp_join) { From patchwork Fri Apr 14 14:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 83429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp413462vqo; Fri, 14 Apr 2023 07:12:30 -0700 (PDT) X-Google-Smtp-Source: AKy350YQvkzK8UDkHr4ARM+ipqMpAIlwXCBsOdER6jJavacGGQ5bt/4wAL29yIcBE+mqeXSlAfZ8 X-Received: by 2002:a05:6a00:240a:b0:5a8:8535:18b with SMTP id z10-20020a056a00240a00b005a88535018bmr8380475pfh.11.1681481550505; Fri, 14 Apr 2023 07:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681481550; cv=none; d=google.com; s=arc-20160816; b=hymAawD7N8Y2VYMicDt9OAKBeGWst+jv4xCu1xDWbxaufMSrrYX7kYteANxZTGtdU7 Gr5OtUQC8kIuuVE1t0V+1iehXY4vYIsUSYkfdFahdeAYZ/SSzOXiMsnFy6BJlYVZSV4F empYpLclXVRJ7Tj99pydpSMmN3ZvuPpeumZINnE7oZVqrTPhPd6IQra1+fm0LGoH8rFd qOi4uusCfqnGS2jZtIcw0RDtwlzRi3f8jUIgfEQryOTsfv1xAXYJRTAamzVAItI8Yh3V HtLPWXJPSlhXciNp/m/xJctsTdKK026K/UtdJBHmxt/gkU6th125b+gP6m8PG68qi+3W DkZg== 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=m66cRDfB61TtjfV8yD54rvNQYmtYBLMGnE8NSc4/AeM=; b=Lx5iqx3EFXboGKUTQljlR+dhY2Jwum3DaYb98xiGcgs12lotstr3/7fqYH4ABgfyvi 4NcSR2fG7bGbcMKvinlPSWYKrBm5h1yu8j/V92/Kc4YDot3SLWGtMEQgqoxf6ZH9xoKa Q78By3aAj5d4RMjuvR0WfMBgfiKX8ZuGnrMyVKLEejL+6kygFC8pnO7mp8G0sp3mP8v8 RiAT8otJshu1DBEHt2AqgjzW7xGXlM9dvkXwgzPlDP75fa1ySBpC3Wi91mDOlLQ9lWoC BJ181Rs/t6l4iTZG2UAz663/g9LuSwv6/X+rwB3UNZs9aF+PLgBv6tN4tIGvzfYWH/0A o2WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=fY6FXzLy; 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=REJECT sp=REJECT 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 p185-20020a6229c2000000b0063b54679d0dsi3719929pfp.44.2023.04.14.07.12.17; Fri, 14 Apr 2023 07:12:30 -0700 (PDT) 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=fY6FXzLy; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbjDNOJY (ORCPT + 99 others); Fri, 14 Apr 2023 10:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbjDNOJT (ORCPT ); Fri, 14 Apr 2023 10:09:19 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A04ABB8D for ; Fri, 14 Apr 2023 07:08:44 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id q6so6171473wrc.3 for ; Fri, 14 Apr 2023 07:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681481309; x=1684073309; 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=m66cRDfB61TtjfV8yD54rvNQYmtYBLMGnE8NSc4/AeM=; b=fY6FXzLykolJ+i9Za1CV4ll8jWr69FyB35y2mOLGOihNwAFCEZQOp8fOjHcwtyL02I u5vd0ml7sD3Fr4Qtnbfyc5QH5cfa43RpmK1NozI/0c0gdHT7ZwNSc8qluqcpm7795JpG xqtP6e/1jo172fq3SmjUOzkZRVIJAJ76/GgZ6JE5HTIU0wKD/Oz/SMwO5RJ5L4CPVmuJ 4p7BCaZ1DPzd4Eec0cxV2PeqngvlIZgZ5jfshNLHoIWa+GPsjezIkLKixGvFyJKfUgRy r+mLB4xBUezdkFjGOvXayAqFaXyqYmd8Ts7Njzc3JVGvoUxVYYPgjcGnB74F/Y1bCadg 413w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681481309; x=1684073309; 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=m66cRDfB61TtjfV8yD54rvNQYmtYBLMGnE8NSc4/AeM=; b=AkOUCQjRNohQfGEfYxxJupP3cH8XaHT7J8YrTcc7YFWVnk/9ldQGOXW9ZTvrELoif1 JsObuF7k4P5EJSO/wHn6uNyxz8fcFgAdDk6rStFfSQ0TOBYgbfz0t//NaHmgysxVYI/7 FNE9ZmqnsAQDa1t9lPpKUu4vSSxCb4EFDqOj7Tk9Fx0sZ34uVygSdRJUBs1aBK2vg3QF bsJ8vMUWEUnfNrDQOEPJUBuZ8JGjFHongUwcpX3vp9GD3xC/ej+pYpTymGMbnpYl1jYg tnGYN3jgnBc14MK09B6ZPSMJ9YIn9DCJJoG8Ez0bcCYLzd3CfA8wo96Wcuu7Wa0F8vAE 5jPA== X-Gm-Message-State: AAQBX9daVhzKhp3xw5L7GpD5kzu0I8Kzu+mpHE52pYn+Vu7wCj+UoApq GySwnC6bRXZ8DDap5GahLXiTOw== X-Received: by 2002:adf:ebc7:0:b0:2f6:6f0c:a2ba with SMTP id v7-20020adfebc7000000b002f66f0ca2bamr3318268wrn.63.1681481309191; Fri, 14 Apr 2023 07:08:29 -0700 (PDT) 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 o5-20020a5d58c5000000b002f47ae62fe0sm3648185wrf.115.2023.04.14.07.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:08:28 -0700 (PDT) From: Matthieu Baerts Date: Fri, 14 Apr 2023 16:08:01 +0200 Subject: [PATCH net-next 2/5] mptcp: avoid unneeded __mptcp_nmpc_socket() usage MIME-Version: 1.0 Message-Id: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-2-04d177057eb9@tessares.net> References: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> In-Reply-To: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ondrej Mosnacek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1864; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=v3ERWSmGTwhX1zfSOFHxV4yLOCVx2TIDjGL56UvMCw0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkOV5Zyl/LCHrWjit6z8vyaL4Okf2RFmEt3FnMi GJI4vpLCoiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDleWQAKCRD2t4JPQmmg cxroEACJ0K+liYP3kEeK1Y3OyVkmSgD4Y+GGfKtR0SOc9aYpBCMnVKufnipdwiV2iJ4j4hfwbt7 6Q5g3VcDB7g/210e3iBTx0pjawiePuwz7YknZA1hHl3l5nWcuTLQG1yAESzwTTom7WJNTTJFJLu VpaNJFTtU1twEV9JmF+qBVReTZ+sa0A2cpgznnnOXii8zLtUzTsAWUXSrSWxJT1Y8c5mgjhbGmu Z8m+d3/Tm8izeLQtZfhnnyCV/ZG3950G7+te/gzIjeY5SAD4+ByZyz2F7Z9+O8sOKLTMwXFBGxv IRtATjxXwHzmW+tzijxnL4mODecfX7KRfD+P6soi4dj/hQHGzbfcNgj5n+SBT/3NEPZljm9CSw1 zK9iUKr6Te4lW2Ewzd6uA+wzpfb3ibluVyV21Q5TLiqu3vTC2ZRoyzl2U0HGKbyuWufsRfeJ2jR eTWOSL7ZuAH+q6a6Hf1gJZ8IHXI0KhymFlKiMsvTY/kCBmvQkLeg04q7FRXuk5Cs9Laekn0nGQi jtd29DF6maOOO5NLdMAlf1puJ+zIybKP9kUjg/PtkKK6G+pWswf8W99JHjnQSlKn/78jWLUJtbj 0wy2DQD86waQ+ded1+8otDps+5fSarm7qr/c8XEkbLZkD54ZiT197PngORD7nCpmr4JCOtzE5ho g/llVsoT5mxWjjg== 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,T_SCC_BODY_TEXT_LINE 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?1763161198521576181?= X-GMAIL-MSGID: =?utf-8?q?1763161198521576181?= From: Paolo Abeni In a few spots, the mptcp code invokes the __mptcp_nmpc_socket() helper multiple times under the same socket lock scope. Additionally, in such places, the socket status ensures that there is no MP capable handshake running. Under the above condition we can replace the later __mptcp_nmpc_socket() helper invocation with direct access to the msk->subflow pointer and better document such access is not supposed to fail with WARN(). Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e6cb36784a68..9cdcfdb44aee 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3143,7 +3143,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, struct socket *listener; struct sock *newsk; - listener = __mptcp_nmpc_socket(msk); + listener = msk->subflow; if (WARN_ON_ONCE(!listener)) { *err = -EINVAL; return NULL; @@ -3363,7 +3363,7 @@ static int mptcp_get_port(struct sock *sk, unsigned short snum) struct mptcp_sock *msk = mptcp_sk(sk); struct socket *ssock; - ssock = __mptcp_nmpc_socket(msk); + ssock = msk->subflow; pr_debug("msk=%p, subflow=%p", msk, ssock); if (WARN_ON_ONCE(!ssock)) return -EINVAL; @@ -3709,7 +3709,10 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, pr_debug("msk=%p", msk); - ssock = __mptcp_nmpc_socket(msk); + /* buggy applications can call accept on socket states other then LISTEN + * but no need to allocate the first subflow just to error out. + */ + ssock = msk->subflow; if (!ssock) return -EINVAL; From patchwork Fri Apr 14 14:08:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 83433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp417690vqo; Fri, 14 Apr 2023 07:18:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aFD5xvl8cr/zpyLzBS3IoS/vkM8SlSXjAE2DuDH9ABuF+Yr6lSwY9TEs9kMFCreoA0n7KD X-Received: by 2002:a17:90a:1102:b0:247:180d:1a82 with SMTP id d2-20020a17090a110200b00247180d1a82mr6793425pja.15.1681481894157; Fri, 14 Apr 2023 07:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681481894; cv=none; d=google.com; s=arc-20160816; b=xTcSfaPsfMgzjwVGg4Eah2nXXMYTOQog/N3XqrN8GWPfuLWrapRqTWeCxVHQJq5hks 1QINbPj7ohxUjVdGGToRC7ua84Wr9BJ4FcJBXQfovtZ+zCIlUvINhKzsgO9Ifmt7T0Ff rkqJd0d0tzbAXz/eSHib7lGSV25Rr8J0mvA1ZcehJ3Fv8tYcf7kNEPAcMw4uxJn7kVm0 jprCJ0JsRgyYjqpRZaqzMytLkFy2LXD5UyYvkffe72wUPJUjnwAJE61sf/w8/K7a0CJ8 hZtEwD1dqG06IC4qpz4hEGNKzNVLVhGciqdRU8ehy0B67N4Ie17TP5IZkxAZ+fr6KBml 09IA== 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=xZhYE929PeAd0ZLAU9yqicLsmxgzSrjpBPOp2nmL8n0=; b=hznqRixbAi6ff1b/2+Jq/aHywMPsiAu6XheRaK/8W/SR0hFb/dw4cqbqoEO5gRh+4n 5UjhQa18HBdFpR0vAwTAGu1qwTVZf8I39hDCzOSI1TKBkxEmLpDvwWoK/c/6pewNKum1 HapCQlWg/ThQhooCk6/h0hMr1kIek0C/rqeSXt+sLMpZj9VOnU5rvp/V/ijAuwVFKT49 u6lP0lC1dNJVDE619iLglLbVNsH8CCHF1q5l/V3VPNXO+O/iHZQuPUxQFX9u5h3+yuqE D8jyuwpYtY4421M3TpdXMp6qUd/7uKewic2NfjdVGhtXjbqOwf8dts3h3sqNSmMpxka5 CDFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=aqtuhrKb; 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=REJECT sp=REJECT 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 t21-20020a17090ad15500b00246abe40ca9si7522064pjw.9.2023.04.14.07.18.00; Fri, 14 Apr 2023 07:18:14 -0700 (PDT) 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=aqtuhrKb; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230447AbjDNOJb (ORCPT + 99 others); Fri, 14 Apr 2023 10:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbjDNOJY (ORCPT ); Fri, 14 Apr 2023 10:09:24 -0400 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 23BCEC14A for ; Fri, 14 Apr 2023 07:08:51 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id s2so14368871wra.7 for ; Fri, 14 Apr 2023 07:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681481311; x=1684073311; 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=xZhYE929PeAd0ZLAU9yqicLsmxgzSrjpBPOp2nmL8n0=; b=aqtuhrKb79sOWSOu6w3w1lpzSVh3Aokv6l+YXXFIQk+r0U0XQFAQqKBQLM5r7wKuig OycDp8uWtXg5G+e0+tVn6uv1AGd5hFY+wzwFgha++3wfanjGcmK9aXvavN7Ok2OJNlVV DxdVfuipATJj0lHVqp0Z3LCDMu9qIyxNRc5hHYG43D5lcpzinDtK4roPAWvZkbqTX3Z4 8EdLMUw1qkgGCR9llXwHMpe1SKug/5WLudbCbnnR+36Yfn9vZUKUAMrvzUiOLqS+HKRC TEdFZ9CxNHMMhWXg/tTL3BdSAz3oEUbXDIDnbf62SuJj4LUdzUwzMNgJ3RxAiEq+B46K XAkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681481311; x=1684073311; 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=xZhYE929PeAd0ZLAU9yqicLsmxgzSrjpBPOp2nmL8n0=; b=QBhOBstnU8q7+pUa9C9jpPMpc0wV5sn7ulcJssGdg9QH69oiNMn22KmU2iXSNqCLx/ En4KTaqPz+YDa6Y1akNnBSmMwPzlS7MpAexTszWCbHhfMDkGn2ERwfLuE9r7hLDZmhN3 lJxm/NsDGv6ohFi/b0cL9uUYIOcYKaAr5hx0hhh0bxb3HfJrv0Qtraw/DBWrGDEbO27l FEZ2hwtcv49ATnK3oLFtszp5b++Pfxiv8viAhRnai7oxTr79JqMuro1EGwdkNxfvsqA4 S2oW4xRvwur6wrn5SM7dBll8QKbqqDkHX2Ngi2sodFkgGsUDzgMJ5UXToz2aQeJ3Fo8A kVhw== X-Gm-Message-State: AAQBX9cGulBOTzcm2B2k6sa4ePOvNEP8Tt7riZe0/RYVX4Deo8SObaj+ uewLdH8w+8CJcNklRS6TveQWbg== X-Received: by 2002:a5d:4e11:0:b0:2f4:fd50:9cb8 with SMTP id p17-20020a5d4e11000000b002f4fd509cb8mr4382629wrt.42.1681481310078; Fri, 14 Apr 2023 07:08:30 -0700 (PDT) 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 o5-20020a5d58c5000000b002f47ae62fe0sm3648185wrf.115.2023.04.14.07.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:08:29 -0700 (PDT) From: Matthieu Baerts Date: Fri, 14 Apr 2023 16:08:02 +0200 Subject: [PATCH net-next 3/5] mptcp: move fastopen subflow check inside mptcp_sendmsg_fastopen() MIME-Version: 1.0 Message-Id: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-3-04d177057eb9@tessares.net> References: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> In-Reply-To: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ondrej Mosnacek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2817; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=P9n60YIe/mfn8CQZAad2UIBXi/vdPChGGnKW1QV+jTM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkOV5ZosafB8d9GNmNZ1meFhcnycRNpkZenoavp FVmCcOlLviJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDleWQAKCRD2t4JPQmmg cxHQD/4z3riXqfAZUhX4rcRrvxKx561jC5T5Wn/xk9PLqTfmLJM/J+uDRno+meTIsy3Gt0zlws5 /zWj/eS3bIKsxwNffgmkKUDm59OH2DRnN6WN9mKXadPQ53+30TerpxmXB6GLGCxmMM2Fa22ZApE 8EbRWfppLAO37JDArFx46THJ3SHS0Fghm5DmFbL6X9gdOSNCZElMiRn1mxRheOEaFqAtn0Zl2+w JLV6h+h1kV6RGfN36zxDzMOZhZIQnTcSqAB73D2enOuvukL/LW9nse2sS1Su7Uvu7x7867reBRX NydxcCYUemkiiZVRjePSOKxtc5L3GNoK++uAv78Ey1RdMivWGHmd12tfsP5E4ZB0RaqISBLOuoA DRnwJYNuJU0i5qGgcHX+q21Bo9GoXbxJsllDlIFJ2bGwXk2HLpVMoK83qpq3Owp86/dgPqWqc2R t9qzQO7UCOWO21uRpiDwf3KYtvAMOFINATu8zszRrKngatOAxKlO1cnyn+e9jFXoxw1OTx93NAx +XCSwQwkZh9lfY9CM/9GmFH+hLE+av2heTVPGaw6HbOklRTwGQZc1pjE4DuZnop6+ukd1JGeK5K 6OUp9tsP2FShZcNXuOtG+EpEtUGXPEqRQTtPeK4tQ+MEitgxVJzwKFjW7cX7neAe0xevXESU/0m CsvfP0paDYtH01A== 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,T_SCC_BODY_TEXT_LINE 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?1763161558566800880?= X-GMAIL-MSGID: =?utf-8?q?1763161558566800880?= From: Paolo Abeni So that we can avoid a bunch of check in fastpath. Additionally we can specialize such check according to the specific fastopen method - defer_connect vs MSG_FASTOPEN. The latter bits will simplify the next patches. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 9cdcfdb44aee..22e073b373af 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1662,13 +1662,27 @@ static void mptcp_set_nospace(struct sock *sk) static int mptcp_disconnect(struct sock *sk, int flags); -static int mptcp_sendmsg_fastopen(struct sock *sk, struct sock *ssk, struct msghdr *msg, +static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, size_t len, int *copied_syn) { unsigned int saved_flags = msg->msg_flags; struct mptcp_sock *msk = mptcp_sk(sk); + struct sock *ssk; int ret; + /* on flags based fastopen the mptcp is supposed to create the + * first subflow right now. Otherwise we are in the defer_connect + * path, and the first subflow must be already present. + * Since the defer_connect flag is cleared after the first succsful + * fastopen attempt, no need to check for additional subflow status. + */ + if (msg->msg_flags & MSG_FASTOPEN && !__mptcp_nmpc_socket(msk)) + return -EINVAL; + if (!msk->first) + return -EINVAL; + + ssk = msk->first; + lock_sock(ssk); msg->msg_flags |= MSG_DONTWAIT; msk->connect_flags = O_NONBLOCK; @@ -1691,6 +1705,7 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct sock *ssk, struct msgh } else if (ret && ret != -EINPROGRESS) { mptcp_disconnect(sk, 0); } + inet_sk(sk)->defer_connect = 0; return ret; } @@ -1699,7 +1714,6 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) { struct mptcp_sock *msk = mptcp_sk(sk); struct page_frag *pfrag; - struct socket *ssock; size_t copied = 0; int ret = 0; long timeo; @@ -1709,12 +1723,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (unlikely(ssock && (inet_sk(ssock->sk)->defer_connect || - msg->msg_flags & MSG_FASTOPEN))) { + if (unlikely(inet_sk(sk)->defer_connect || msg->msg_flags & MSG_FASTOPEN)) { int copied_syn = 0; - ret = mptcp_sendmsg_fastopen(sk, ssock->sk, msg, len, &copied_syn); + ret = mptcp_sendmsg_fastopen(sk, msg, len, &copied_syn); copied += copied_syn; if (ret == -EINPROGRESS && copied_syn > 0) goto out; From patchwork Fri Apr 14 14:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 83440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp422466vqo; Fri, 14 Apr 2023 07:25:22 -0700 (PDT) X-Google-Smtp-Source: AKy350YXHQle2XviN8JmaA1EiP7qfo0YRHmPzjR7vdO0zxtDaRxqBdxfYhx+vUjNTVvpRqItviaD X-Received: by 2002:a17:90b:314c:b0:246:7040:a0a7 with SMTP id ip12-20020a17090b314c00b002467040a0a7mr5655925pjb.47.1681482321690; Fri, 14 Apr 2023 07:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681482321; cv=none; d=google.com; s=arc-20160816; b=gzCXh+iXzZ68EVvM2mcsTaHVwi5uq92QQxiXv9twJGfDHGX58CneadKE6oKFC4c224 JxPlAuDrryWXMDzahSGUX5o8WsscdxlvDI86/d5MFw7NdpmaP25AuzAF+921XtYqIpjh 3OhfUxcPoJH+19rcTc6NE0FceRcY82N7vmNjSTtrHwlgrHMgL9hwsQXxdWlizvTQoTkE rlRwzur3GXYCxIoh+slPZrd/ShDH4Zzdf2pG2epsViMg+anOTM4wEFd3UXtqtdcqlooD ayrTjDZJ2fidwRvxWvfFXwSwhEyAueaLtuHU0PHvyo39BouCDgWBLIcXvsB5t9banbi2 5XCQ== 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=CICDEU8TaCbg1GGQaZtC7SyRvWqn9IgSTFJRC3tOWbI=; b=GMiwX8hSNBAGGae2uV8n2m8zRTNHvqaVaIkqVekkOZ6mX2ZTmAo8jbZ5RitFjjhw4A BMhcF7pB7p0fVe2jYtaGVG5g7COy6XNxin/yByei9DIGuzdmsKcjkVzJd+9pAQE8jjMe on4JEvZ1gttf5Zu9o1ZNG5wUo9viULLotSnO2hZX4Gu6gMsVx+xMexo7wnFppxLk7onx qnECRS6JBX6waL9oQIz4b9M8tZklopzaECygasXI7yREZ6g8twgbTkjhHP1U6higOX2V ySTGz0crxZ/zphp3TDaeDUZzmZj0r1rOhFD0F7sxeHEzKMLGFzscWxOON5S8zrrz2S3A tUOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=M97x6TTN; 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=REJECT sp=REJECT 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 ob12-20020a17090b390c00b0024733498c7esi2577975pjb.124.2023.04.14.07.25.07; Fri, 14 Apr 2023 07:25:21 -0700 (PDT) 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=M97x6TTN; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjDNOJi (ORCPT + 99 others); Fri, 14 Apr 2023 10:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbjDNOJZ (ORCPT ); Fri, 14 Apr 2023 10:09:25 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FBD5C176 for ; Fri, 14 Apr 2023 07:08:53 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id n42-20020a05600c3baa00b003f0b12814aaso1113369wms.0 for ; Fri, 14 Apr 2023 07:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681481312; x=1684073312; 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=CICDEU8TaCbg1GGQaZtC7SyRvWqn9IgSTFJRC3tOWbI=; b=M97x6TTNZC5Qr26UxgFeMre1y1tvfELn2/p/fczNWD4CSnqzG/x5eDIGfkD0dbJQx/ nuRVNlFpMG6HjI5n0AmX19DarI5xtVq80bnKtrU5tIQP6qnn0NrwfxAJSU2cWi0hDV76 sD2p9YorJuSEaTC81vPt8bqZhEtsQzrpMcW+lwbNZOEYjTNPs1dToWbtwERUVewm5QBV MiS76EfR+0u+20u3jX4tuA4f9HWK/lJYVEIXYq7Rgl4pQw2rCBiXzOYeelgbyMG7Zumz htF/WQ5aMFsTaHwgNYYznG3GbWg+/Xw41l7DrRTh/mvYAPe6tSx3BXMr/b78miYq+N1N VCjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681481312; x=1684073312; 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=CICDEU8TaCbg1GGQaZtC7SyRvWqn9IgSTFJRC3tOWbI=; b=YI3BU8eCiX3dNVkG3Yy3rBpGg3qIgRRKRBbhdEWE9HoLKoLA26h2Fim9xQ3v4O+D5s iz/jlOUSfdusGQyRTVqb7/9EsJU4iolB4q9v6MQRt6mPNtL06iHnrFxJ+R+rs8bC1Xx3 KSweH50HieZfe8a7X1ZMt8k3bNOgsSeTGbcFJkEH3T6WDM4owQ2jYZXPaZQHGrzkCIl4 w0fJVbuH2GUDpvBX2y11WusSTUiYggfqG7aVn4DZ5NCwWrwF6WAL9ElfKf3sTjyAKD9I COEkjooqaMh9axJe7twXDiMr3RAE8OrwB/SrO+mR8qs9kqfgAhQeKGmcgR8LsiRzHICl wVdA== X-Gm-Message-State: AAQBX9fALyeQwfWX/92ee0uTLnbgsNkwAOlmpZEOvbDrrEeDUZ93KO4G NEeeiCF+M1YA3uzXyYe7/HjGcw== X-Received: by 2002:a1c:7918:0:b0:3f0:8ed8:853c with SMTP id l24-20020a1c7918000000b003f08ed8853cmr4410719wme.37.1681481311706; Fri, 14 Apr 2023 07:08:31 -0700 (PDT) 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 o5-20020a5d58c5000000b002f47ae62fe0sm3648185wrf.115.2023.04.14.07.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:08:31 -0700 (PDT) From: Matthieu Baerts Date: Fri, 14 Apr 2023 16:08:03 +0200 Subject: [PATCH net-next 4/5] mptcp: move first subflow allocation at mpc access time MIME-Version: 1.0 Message-Id: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-4-04d177057eb9@tessares.net> References: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> In-Reply-To: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ondrej Mosnacek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7808; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=5Y9EfyE2tJuCdvufBWHqISerg4pT1Ev9GzL9oU/i0Ew=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkOV5Zj5iqs/ESmRSVO7FxR1JDWbjdG0TCigkvj m6e+3Z3Fg2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDleWQAKCRD2t4JPQmmg cxY/EACqAMhEgib2HptA0PI/AJBsNCGmF+xNwxY8QfBzJh/w/JqT1LQ0V+lqPLP1njmobzTPo5G zS6UnF0Rz+tZzaONcYBlPknWGXzD20eArWrX4stJh+T475AUaHMAZW2h98yCjf/UmG/trzg1jTJ 1doZJ/Plyuicyy+IwiXwZmp24dT5MNcjOt8etsCeKacPGo0GVsl+91aWjX1D8rDBDx+mLqq7Kqa Vgv4L5EUdtV5Y1UzARZ7a2exLEUILgGedGrI3fUuKojL0taBt17nTFwy6/ecEoBmoLKDVNWmi1W MIO8QWYozUd5v2DLk17XG+ZegUKR2XD5FSNiK8Y7WM51wR8fpDa+sBNLSpxla6pxIeuOdsqyeiE 6Yr+feTXZyeLo+nYCV5YyGWFofwThBz+w9lbVVEUszIh71cNnPeHPnpdML6iBGnqtJ9k8abdNJn S4hEySSuWPRm9qojyN795A5ZaFpvZeDI2WTZHEbEDmevzz3i3MaXjIWsLQjlLeLYH2mp8/yKoSW 4CXAi4kHFs7Kcu/o//W037HpSuiKcvVqt5LbWHlwlZ92w3T6ZoYY8SN5HDwnUXayEwi4XuupQzd 4xDCongkzVCYqVscyylJuyQ0TQDixR2LPKRtyYIfMflKZd/OvzVIrf/YL7A8WE3zJngsbhIwR3J gSe00yljSSb6+KA== 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,T_SCC_BODY_TEXT_LINE 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?1763162007181607413?= X-GMAIL-MSGID: =?utf-8?q?1763162007181607413?= From: Paolo Abeni In the long run this will simplify the mptcp code and will allow for more consistent behavior. Move the first subflow allocation out of the sock->init ops into the __mptcp_nmpc_socket() helper. Since the first subflow creation can now happen after the first setsockopt() we additionally need to invoke mptcp_sockopt_sync() on it. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/protocol.c | 61 ++++++++++++++++++++++++++++++-------------------- net/mptcp/protocol.h | 2 +- net/mptcp/sockopt.c | 24 +++++++++++--------- 4 files changed, 54 insertions(+), 37 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 1c42bebca39e..bc343dab5e3f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1035,8 +1035,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, lock_sock(newsk); ssock = __mptcp_nmpc_socket(mptcp_sk(newsk)); release_sock(newsk); - if (!ssock) - return -EINVAL; + if (IS_ERR(ssock)) + return PTR_ERR(ssock); mptcp_info2sockaddr(&entry->addr, &addr, entry->addr.family); #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 22e073b373af..a676ac1bb9f1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -49,18 +49,6 @@ static void __mptcp_check_send_data_fin(struct sock *sk); DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions); static struct net_device mptcp_napi_dev; -/* If msk has an initial subflow socket, and the MP_CAPABLE handshake has not - * completed yet or has failed, return the subflow socket. - * Otherwise return NULL. - */ -struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk) -{ - if (!msk->subflow || READ_ONCE(msk->can_ack)) - return NULL; - - return msk->subflow; -} - /* Returns end sequence number of the receiver's advertised window */ static u64 mptcp_wnd_end(const struct mptcp_sock *msk) { @@ -116,6 +104,31 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) return 0; } +/* If the MPC handshake is not started, returns the first subflow, + * eventually allocating it. + */ +struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk) +{ + struct sock *sk = (struct sock *)msk; + int ret; + + if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) + return ERR_PTR(-EINVAL); + + if (!msk->subflow) { + if (msk->first) + return ERR_PTR(-EINVAL); + + ret = __mptcp_socket_create(msk); + if (ret) + return ERR_PTR(ret); + + mptcp_sockopt_sync(msk, msk->first); + } + + return msk->subflow; +} + static void mptcp_drop(struct sock *sk, struct sk_buff *skb) { sk_drops_add(sk, skb); @@ -1667,6 +1680,7 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, { unsigned int saved_flags = msg->msg_flags; struct mptcp_sock *msk = mptcp_sk(sk); + struct socket *ssock; struct sock *ssk; int ret; @@ -1676,8 +1690,11 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, * Since the defer_connect flag is cleared after the first succsful * fastopen attempt, no need to check for additional subflow status. */ - if (msg->msg_flags & MSG_FASTOPEN && !__mptcp_nmpc_socket(msk)) - return -EINVAL; + if (msg->msg_flags & MSG_FASTOPEN) { + ssock = __mptcp_nmpc_socket(msk); + if (IS_ERR(ssock)) + return PTR_ERR(ssock); + } if (!msk->first) return -EINVAL; @@ -2740,10 +2757,6 @@ static int mptcp_init_sock(struct sock *sk) if (unlikely(!net->mib.mptcp_statistics) && !mptcp_mib_alloc(net)) return -ENOMEM; - ret = __mptcp_socket_create(mptcp_sk(sk)); - if (ret) - return ret; - set_bit(SOCK_CUSTOM_SOCKOPT, &sk->sk_socket->flags); /* fetch the ca name; do it outside __mptcp_init_sock(), so that clone will @@ -3563,8 +3576,8 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) int err = -EINVAL; ssock = __mptcp_nmpc_socket(msk); - if (!ssock) - return -EINVAL; + if (IS_ERR(ssock)) + return PTR_ERR(ssock); mptcp_token_destroy(msk); inet_sk_state_store(sk, TCP_SYN_SENT); @@ -3652,8 +3665,8 @@ static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) lock_sock(sock->sk); ssock = __mptcp_nmpc_socket(msk); - if (!ssock) { - err = -EINVAL; + if (IS_ERR(ssock)) { + err = PTR_ERR(ssock); goto unlock; } @@ -3689,8 +3702,8 @@ static int mptcp_listen(struct socket *sock, int backlog) lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); - if (!ssock) { - err = -EINVAL; + if (IS_ERR(ssock)) { + err = PTR_ERR(ssock); goto unlock; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a9eb0e428a6b..21eda9cd0c52 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -627,7 +627,7 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk, void __mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); -struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); +struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk); diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index b655cebda0f3..d4258869ac48 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -301,9 +301,9 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, case SO_BINDTOIFINDEX: lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); - if (!ssock) { + if (IS_ERR(ssock)) { release_sock(sk); - return -EINVAL; + return PTR_ERR(ssock); } ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, optlen); @@ -396,9 +396,9 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, case IPV6_FREEBIND: lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); - if (!ssock) { + if (IS_ERR(ssock)) { release_sock(sk); - return -EINVAL; + return PTR_ERR(ssock); } ret = tcp_setsockopt(ssock->sk, SOL_IPV6, optname, optval, optlen); @@ -693,9 +693,9 @@ static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int o lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); - if (!ssock) { + if (IS_ERR(ssock)) { release_sock(sk); - return -EINVAL; + return PTR_ERR(ssock); } issk = inet_sk(ssock->sk); @@ -762,13 +762,15 @@ static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int { struct sock *sk = (struct sock *)msk; struct socket *sock; - int ret = -EINVAL; + int ret; /* Limit to first subflow, before the connection establishment */ lock_sock(sk); sock = __mptcp_nmpc_socket(msk); - if (!sock) + if (IS_ERR(sock)) { + ret = PTR_ERR(sock); goto unlock; + } ret = tcp_setsockopt(sock->sk, level, optname, optval, optlen); @@ -861,7 +863,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int { struct sock *sk = (struct sock *)msk; struct socket *ssock; - int ret = -EINVAL; + int ret; struct sock *ssk; lock_sock(sk); @@ -872,8 +874,10 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int } ssock = __mptcp_nmpc_socket(msk); - if (!ssock) + if (IS_ERR(ssock)) { + ret = PTR_ERR(ssock); goto out; + } ret = tcp_getsockopt(ssock->sk, level, optname, optval, optlen); From patchwork Fri Apr 14 14:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 83434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp418679vqo; Fri, 14 Apr 2023 07:19:44 -0700 (PDT) X-Google-Smtp-Source: AKy350blRJG3vVEhA0V35WqAYsXJ+FlLd/oiFILbTmFlNVDN3edq3FIT1F5lSK2Vq4agbE/2F+Gs X-Received: by 2002:a05:6a00:cd3:b0:62d:d6ca:5834 with SMTP id b19-20020a056a000cd300b0062dd6ca5834mr9145536pfv.16.1681481983700; Fri, 14 Apr 2023 07:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681481983; cv=none; d=google.com; s=arc-20160816; b=xx59aDXrfHKh52RZ0F6ykMiMYCt9SX/FxYbJIPRFlH6LgjqNbH5b+O5RK6sDzlwpHa pF3eoDaNqzCVMnWOjTCqdg/wlU7DYU5TazZvsfyxckjlEkIqWRTITRCE/mjjTzjqPXPu Ghr4pJxtoXRamxsL/GVaFsets2xOd8pJqPpY39HyPvnDYIUuccKzwKGs5dbSVYp6sLgE f5IVqhmQ8FToUXeyDKM6trPxEWcjRzlS085Yt/ULuR3dtkVoOfZxiAct8ySsNNrtDmRB nFHWPYNXk95wOQn1syMtP2souhm7Wi8by62qjoZaMFYEoIKn94NIiPNFtfjuS1iy4HlR 1sNw== 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=ogznRyoPP+056OwMwbae8knri/N8tWTWU74IRb36bJ0=; b=rELGLX8yNUpvcyzDwFlikQSzetVo4AQ+cwiHEcbQAn6hYMCddFj9gfPGDtah0rvjvR V2D3HInmq0jHgCXa3M3D9201+XCrFZS5SN9QuSPBGoyJRDSzwRN0ASjQx3WeobeFatXK We1Us+I+Gu1sLa6gzn7/XN56FvX3lVLl+1CYdCOv0NTUCW/AhLuN5wEAZsQnTLOCOE6i QN69AbMKnhZObyfUAzwQMjoatYDcAeafXutUH1LNFOfAjOOXA11TvYvGUpgwiOG5Hsj6 QDCeB5vhDfux8fQFvGTYG1saBg5DMyFyOoQrB7afOFQMfF08b1mpH8+svyGH8W5KYjnh tHiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="sHfPEz0/"; 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=REJECT sp=REJECT 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 bs189-20020a6328c6000000b005136987a02esi4884543pgb.728.2023.04.14.07.19.31; Fri, 14 Apr 2023 07:19:43 -0700 (PDT) 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="sHfPEz0/"; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbjDNOKH (ORCPT + 99 others); Fri, 14 Apr 2023 10:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbjDNOJ3 (ORCPT ); Fri, 14 Apr 2023 10:09:29 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE63AA5C1 for ; Fri, 14 Apr 2023 07:08:59 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id e16so4367078wra.6 for ; Fri, 14 Apr 2023 07:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681481312; x=1684073312; 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=ogznRyoPP+056OwMwbae8knri/N8tWTWU74IRb36bJ0=; b=sHfPEz0/Z8hOsH0W31okcmmWVW7Jz8Y7MBvd91H6QX/yi0LPkhBmL+QziymNrCD0Dt mmq7WRi0bd8OGuFzfPgUfuxbLGAeVbXCIJsR2ZuBbjY2qIAVYDd/sk/9LQImUGfNbqTk QxantsEkC1yRH8lL3RGX4H44kjQTt43PfaXxA5mo0kageEjTFRjT8q1r+thXNImrWBT/ FL4HhDcjzi26OsnYpP3u4fTndD1BqrwDCg5yFMXwoy1xFTKlcjjiiU8TirGN+HzWm3Cq FA552QzpLqx+qdOrqkI1Oxhl8tesZX1b0LrifRo3q6RFhs5HBOFtaS/UX9k60yPvJVnb 23zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681481312; x=1684073312; 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=ogznRyoPP+056OwMwbae8knri/N8tWTWU74IRb36bJ0=; b=e6IqCdJkjPxANCMppixg8eJtdKCG67Ya4wrhPy4KLx04npb9+zIx3Qrx79cMuX2qb0 M4MS97Fuq4TB2xQX8VGjbdYHz3Rr3gNwc2xPYoykN4TeCPjd/cIghPnV/0h6PHrACVHs ReTmENiwJ3GGgd5NA7bT9Y6AGeW1j8HLBL0TNGa7Ot9GwmFyz6kk4FABiI2swDjdVw64 jKA8tFucMS2paao/rVHW8BsCjjqsLRR659z3MWvuL57Aj7wUbP8oOsrPNH9KVT1j8UGa T2uf1OxgoQZcPpsKsssVAKeIf1i9P7ldJ+A0+hvVqxFTmU/AZf1qCB44OuIyByi7pzex JJfA== X-Gm-Message-State: AAQBX9ez0MAhma2IvqzWklRJc0SsdC/Ln0bPgZ/T3ma52bBjhvOLOr3n 3NMMH/lbwk/zf38kpAr5//BLWA== X-Received: by 2002:adf:e48a:0:b0:2ef:4c83:b78e with SMTP id i10-20020adfe48a000000b002ef4c83b78emr7119539wrm.4.1681481312552; Fri, 14 Apr 2023 07:08:32 -0700 (PDT) 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 o5-20020a5d58c5000000b002f47ae62fe0sm3648185wrf.115.2023.04.14.07.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:08:32 -0700 (PDT) From: Matthieu Baerts Date: Fri, 14 Apr 2023 16:08:04 +0200 Subject: [PATCH net-next 5/5] mptcp: fastclose msk when cleaning unaccepted sockets MIME-Version: 1.0 Message-Id: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-5-04d177057eb9@tessares.net> References: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> In-Reply-To: <20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ondrej Mosnacek , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1319; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=94Du3tPB/bRAi77YjNm1E+sPGspDF2pImjBzRfpMGgM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkOV5ZnxzUZCmm4W6LKU/y/OGltXEBtKUntbAZd abPqNuiHgSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDleWQAKCRD2t4JPQmmg czK4EADZTlZwhMw4sDQxk2HQKSNWPPTDQDBWBEvEiAkSXa3HW4mCAEz4MCW+znvv05+henG8DmV AdtFcbeuVrgZiWzPShQUkR/No1m8On2aoEHYPf52GbRXqzBktNWiYE1idnDqOUcYVDz1urBLM51 /YqcPuSmHszvVNWpG2ZHBZ3nMLwHxVtxFuJA4N1tX4Y+aLijYnJqkpnfolwMM0NjJHJUuIrTntA 9Zc/qb4+qu1mtdvW++RBSz7GRqoypv4bGaDLJ0u/nzwLk7YcAbntRyeXioCO1MSKQh9MqKwZ9t+ L0xSkLFbl5f3owh1qCfaSEmCM60i9hZ2BsX7KeXCnOO/O68um2AkTz5BgJlO5O1Pr9vOXNpX4B/ lEYBLj2SzSrb4M+PKY16/TWlFVxS+0tsw3ddWthsmQgFArcHZwjIVcCt8GVGVxYJRftKy+RgAg0 n2Dt0XgSdSXNs4TTIFLl5y4ATXPyuJxSJm7uUspkjHTgwKS9Sf9vOuhjFGtVv3fdAcxSqDYuiuW pgc3zBfMqoB4IFfAnugo90UpjP8jVCYLvyJ4Y5BoeZG5ryWYpc5DN2kjnpD+NR/JD42SEgbciZW oaRda3KsOXarak9Cq8Muz/YginE+PES5quDFIJiYBsrP2GlUtQdh1N6wwo/pBpJGhZWzOBRWmBx eYzbMat2s5xk2Ow== 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,T_SCC_BODY_TEXT_LINE 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?1763161652358413799?= X-GMAIL-MSGID: =?utf-8?q?1763161652358413799?= From: Paolo Abeni When cleaning up unaccepted mptcp socket still laying inside the listener queue at listener close time, such sockets will go through a regular close, waiting for a timeout before shutting down the subflows. There is no need to keep the kernel resources in use for such a possibly long time: short-circuit to fast-close. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a676ac1bb9f1..1926b81a9538 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2953,10 +2953,13 @@ bool __mptcp_close(struct sock *sk, long timeout) goto cleanup; } - if (mptcp_check_readable(msk)) { - /* the msk has read data, do the MPTCP equivalent of TCP reset */ + if (mptcp_check_readable(msk) || timeout < 0) { + /* If the msk has read data, or the caller explicitly ask it, + * do the MPTCP equivalent of TCP reset, aka MPTCP fastclose + */ inet_sk_state_store(sk, TCP_CLOSE); mptcp_do_fastclose(sk); + timeout = 0; } else if (mptcp_close_state(sk)) { __mptcp_wr_shutdown(sk); }