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: 82189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2854744vqo; Tue, 11 Apr 2023 14:06:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYwFcN6b4tv70TlMx3tjmIaxni1UooU+CA2BlXbFxgBdqTUaoTxwihm/+cyIfuE0M+oYCH X-Received: by 2002:a62:ab14:0:b0:625:524b:9712 with SMTP id p20-20020a62ab14000000b00625524b9712mr582356pff.2.1681247179839; Tue, 11 Apr 2023 14:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681247179; cv=none; d=google.com; s=arc-20160816; b=ydb1QhbnkYAsloJSaOOY80E4Hg5nq5p5TG7jvGIkVTEQoAcIRlKJrb5CI+Fa8IiqjK kejUcPhj2ZOv7e1e0oVAMqU8ouAO/Xm1ODU/6GkqF0EbNiLx8/kczB+h8/09VHBPVufX xDglzIuG896VDKjRHN3gzUc4+37XIBQpB77hHY7pE6kwTz2Ajt97CTAVJSZC0iZHodgj uRHDGvFCPvJ8GWfqxpf4isUlkcJf6OqlgFSb4XR3+WDCAPR19Kw/c9gssEyPe0Y7YD9j MhhP3TfXTL514mocmYJCzRJwI3POhhKo/llcP5yFSd0xa+t96wC1U9sMgA1UZifWi6F2 4rMw== 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=EwF0PomNECDDUOOp20oDb80C76i370h3UDr06DP9I3E=; b=HM7CvA5G9kSQgDgxdbvZxSsyx1u47hIrRrjQ7/cN5MCvNHp5QbtwhlQDdOa5Ck5hxB 1x+YbgQPUfy09vSYzSrnfTviftMjxHovtn8PBGrGuj/wsPcNhEDfoWE5zZ7XC/wBTk5f alqlt6PVGubPCtqlDhZQowHpv5dkOrJQyDluY1o13T+Z5aVEk0fQjL+B4aKKS+A+6d99 gEEC2vM3naH4J/cdAF0OxosVSQS9SYm0Cqapdr8BtxUCnLfNRlzXJDlSuaRI+/r5MLl4 WZHckMy78S6y3yayZWvDiBETmBtDdNF0JT/wBqN4Xc7s67TJ9azXaI/POJPMyz6Z/P4n K6RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=AhJ4Nl72; 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 d135-20020a621d8d000000b00639b0f72b5esi4538512pfd.55.2023.04.11.14.06.06; Tue, 11 Apr 2023 14:06:19 -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=AhJ4Nl72; 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 S229503AbjDKUmi (ORCPT + 99 others); Tue, 11 Apr 2023 16:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjDKUmb (ORCPT ); Tue, 11 Apr 2023 16:42:31 -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 2DAB94EF2 for ; Tue, 11 Apr 2023 13:42:26 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id q5so5291003wmo.4 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=OJe3KKLYk/1S4kjqwjOWMm6pFfS9FynlyEdzTpblJnLd3UBJ5HtxE/ljIEaMP7zMb8 knfyN/EmmAZRHf0Sy2gMBtl52/mcxaLLQPVDEpaQP3oluhdiah9EgiFjftR7W6IEQlus 6OgUSd3fkNVTs1k1q/zrUXrNjZ64tMdqOGKebL/jH6aOAcB4xLDrAh0DKuT9+Zb14vDK SoFJ8ftLSZtkwtuSltK90QYUu+ugNAnJqIk0CyZafRtqWyO9NnAM0qAI9Rsh/Y2xhQZ8 HFBzLX4vJvfQBDMKc9X0Nv/zv4q7smA0Rm8fuvF50ZwN1vEIzl/xP8lDLd/EyWV/kf3T fINg== X-Gm-Message-State: AAQBX9dEBruXxaKJeQx1T60KaPb1ZxmiBjAOLAsqQvXFGHdfj3JbG5en wGYlcRaNSz/YmBWQ2n3+kwvBHH387kgJwcaOMRnhNQ== 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 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?1762915443086993373?= X-GMAIL-MSGID: =?utf-8?q?1762915443086993373?= 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)