From patchwork Tue Apr 11 20:42:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13208241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42650C7619A for ; Tue, 11 Apr 2023 20:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjDKUmf (ORCPT ); Tue, 11 Apr 2023 16:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbjDKUma (ORCPT ); Tue, 11 Apr 2023 16:42:30 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB0C4EE2 for ; Tue, 11 Apr 2023 13:42:26 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id o6-20020a05600c4fc600b003ef6e6754c5so2960382wmq.5 for ; Tue, 11 Apr 2023 13:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1681245744; 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=EwF0PomNECDDUOOp20oDb80C76i370h3UDr06DP9I3E=; b=AhJ4Nl72uzaN1JjDbbVWk7/9sNqAzcKUEt3q79fGQ6jXFsIWOdFWieqkn0youXhbQi qN3KDiVxOjtnT03q5V1ivqaWktKCH4QhA16mDYtg12tJCj3hz3YQsbcpPX/jWFIT7d5j Dd81/6HKW8Bw/qBYgZBW31Jv/eEEc2G1q7d7LF7p8H86X8MhDjB1NFV0mdp17Kp3QFCH +CGk2Yfez55f09f1EaXEYHEdgkUYJxOyKdAS88BUtpaMZ5KjJ9CoWEaPHxK15DdNCx51 gZXKrq9YuEQJFgkp3R7tIhnfn7y5ZtHXTqXybBt2LAdCTVCfuAdINX4JKc+lvGjyqtti veww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681245744; 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=EwF0PomNECDDUOOp20oDb80C76i370h3UDr06DP9I3E=; b=Qmc2pAH2ua58L9wc23PAqzs5MuaLs2eRdB0r594gALAaH8HcgFu5ugu5OJO7yg/SUK KpVt8HvGjFhfn5pPyEJgcNiInrMSasRRlb0EBwwz4tQEWgsS8ippwwBOZELvokTpF5Ge IgOxAT4po3Ef9BJOcoPE+BOUCmjE2VA2wDi1zLQkrYvmoNqF8r0YIKcDh8DD+Gvfriq5 uwyIF+yf8DHe+UWIrSDa2q9dF6rvapB0UhM2bs0Lod6u4vEhJ5ZqokBfBkUSSBSkbaen wEErnr+fQL9ymbUvyIro8qI/WglU8a1WNsRhg+mDCXtU9isGxRiMsNWnN2CJYd0EXXH7 pz4A== X-Gm-Message-State: AAQBX9d7VLYZWR1QjsKryAhgV7CTiBu0qKWQRkLM5Syv5PZr9aVdoyk4 lL4wNK2KO94lcVXB/lJqQsahMg== X-Google-Smtp-Source: AKy350Zls2SHdHmNAC2DbLyuiYu/jh89wReNkdMz3I0heC14eNk/G9iiRPMuMSIwzsGcuAg5Ph5APA== X-Received: by 2002:a7b:ce11:0:b0:3da:1f6a:7b36 with SMTP id m17-20020a7bce11000000b003da1f6a7b36mr10876922wmc.0.1681245744378; Tue, 11 Apr 2023 13:42:24 -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 p23-20020a1c7417000000b003f0824e8c92sm86887wmc.7.2023.04.11.13.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 13:42:24 -0700 (PDT) From: Matthieu Baerts Date: Tue, 11 Apr 2023 22:42:09 +0200 Subject: [PATCH net 1/4] mptcp: use mptcp_schedule_work instead of open-coding it MIME-Version: 1.0 Message-Id: <20230411-upstream-net-20230411-mptcp-fixes-v1-1-ca540f3ef986@tessares.net> References: <20230411-upstream-net-20230411-mptcp-fixes-v1-0-ca540f3ef986@tessares.net> In-Reply-To: <20230411-upstream-net-20230411-mptcp-fixes-v1-0-ca540f3ef986@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Dmytro Shytyi , Shuah Khan , Mat Martineau , Geliang Tang 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.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2977; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=nbBO24auZXUWf308UdJEaew2MvvQb/ZCL4hcsSnZZco=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkNcYtUcj7Q6j4WeO0kFmzxIFRoXZWHxD6M2oLB BWnzpr5r2OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZDXGLQAKCRD2t4JPQmmg c+xXEADiejdeMpap2B6k+q3lrU8trhAf2j0xGXgLdkVwGw61AzzT7bfu3PiekvRxxODFuSInxVh RbX7JzVzzNvc4FDm4Ry/tBoLuKA6vIeOG1ATl3WShoP6SaQbtRiKxkfE3tkeC6xGWGioxtTtBzf j9sLuFTCjJlnAP2mwta+XBiZPCk6NPTK5q6BlqxLGo/C2ejI2+DT2oMNvJDUxudNYZy45Lo5UKf Dab41taPjznxNYS955adjfwlvjHVXRfNBYd/bHSDHCOVB1hGzGfjjSnuR1Jy93lNnr0djnE05iT lNzUYqahz8JGujV480GapHd4eiRcKEw+9b4nIEr+VgHa16hyyoOGs8czHyqex8HTNC/NC5KbnZK VfR8K1iZa7DFKlbsOFwzvwh4sztHFPFj0ZFCrt/qWaiwhEQV0w8WhpnW1abaqy7aTIvePanaVcf MuGaqa+KFTU+AHUWySD+KZFwJYmGp0j3KhvGOcQbI386NNm5alCT7mbMbRkv3gPT1AisER/nVgq UbDIyIsWjmV92skkC6P9zTiuI3jGuQiAVzFyzwPAr7PmGtAtkIH1omSWtFc6JYoklDTg25anefL 25/pMtBa0epgjyUBU/uGx4ivtiDme9pRj1zgyAYHGSsWA0m7e39+pkYUjyMdC7UQPe+KFdudK2x ZAOTVtGRyl6mesg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Paolo Abeni Beyond reducing code duplication this also avoids scheduling the mptcp_worker on a closed socket on some edge scenarios. The addressed issue is actually older than the blamed commit below, but this fix needs it as a pre-requisite. Fixes: ba8f48f7a4d7 ("mptcp: introduce mptcp_schedule_work") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/options.c | 5 ++--- net/mptcp/subflow.c | 18 ++++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index b30cea2fbf3f..355f798d575a 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1192,9 +1192,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) */ if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) { if (mp_opt.data_fin && mp_opt.data_len == 1 && - mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64) && - schedule_work(&msk->work)) - sock_hold(subflow->conn); + mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64)) + mptcp_schedule_work((struct sock *)msk); return true; } diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a0041360ee9d..d34588850545 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -408,9 +408,8 @@ void mptcp_subflow_reset(struct sock *ssk) tcp_send_active_reset(ssk, GFP_ATOMIC); tcp_done(ssk); - if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) && - schedule_work(&mptcp_sk(sk)->work)) - return; /* worker will put sk for us */ + if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags)) + mptcp_schedule_work(sk); sock_put(sk); } @@ -1118,8 +1117,8 @@ static enum mapping_status get_mapping_status(struct sock *ssk, skb_ext_del(skb, SKB_EXT_MPTCP); return MAPPING_OK; } else { - if (updated && schedule_work(&msk->work)) - sock_hold((struct sock *)msk); + if (updated) + mptcp_schedule_work((struct sock *)msk); return MAPPING_DATA_FIN; } @@ -1222,17 +1221,12 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb, /* sched mptcp worker to remove the subflow if no more data is pending */ static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ssk) { - struct sock *sk = (struct sock *)msk; - if (likely(ssk->sk_state != TCP_CLOSE)) return; if (skb_queue_empty(&ssk->sk_receive_queue) && - !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) { - sock_hold(sk); - if (!schedule_work(&msk->work)) - sock_put(sk); - } + !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) + mptcp_schedule_work((struct sock *)msk); } static bool subflow_can_fallback(struct mptcp_subflow_context *subflow)