From nobody Sun Feb 8 19:39:36 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6638:38c:0:0:0:0 with SMTP id y12csp1899574jap; Thu, 6 Jan 2022 16:20:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+x+bBcwI0ombI1BAyfg55siOyDfIGTESOYTfwaVSYfbPda0kBCNgEtJEeVhcWtmaLpxnY X-Received: by 2002:a25:d142:: with SMTP id i63mr68540641ybg.253.1641514854024; Thu, 06 Jan 2022 16:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641514854; cv=none; d=google.com; s=arc-20160816; b=T6bHbFsWxJm0T6r47A5jn+MW/nD7ioberNn+CspKrlIN4m1T9OHS1dhgr+CK5tN2fb Dk51tGg/UzQ0nmoM8fcWbaDf7w2ANeOfbCU3sqOJvU3PM+LdTntlJ/bM+vSJ5QZWM9Q+ rGkV//6shEK+eG62EglpkITZ4ICrR4xu5fqcNxb7uZ3Tye9nxAv/qFpPkN9RIUqpcKQ1 /vhfonhrshisjRxLxm0WA5w4MuWK/Tq+UKVsQCw3EalM1v1XvlcTv8TbdWoxh/OwYGUd dgc04tHZw3gfZm/GNH0wxbDSTMU/hPs3xp8HajOcMh40UeQRHyFKVMlZTPcHMDMQPoJU 7b2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=K48eyw5fjuAVZre/g5ndUBqJK3HcGIMFWbnxcooGleE=; b=0/iB81J6jhrrAwZPdftn/C/vN2gAWmAHImpIgcOvPTfguUmfk/TIbVXolivODZq7uq lKgdYBjqntETbEQVncyA46EWB9laN+qnH/zr33APas9IAmgQ3Toj7iFXG5QXwGHxtU7K tO8B9BgIR8TEe5i++kB4EmI3deJo3oNzOojf0NRVIxFZU+TlqvE9rg9Yt9xzO5zd2T+3 3Nk/muUcxebMdzsbcqA1tnHPBkenpmhWWF2Gs1AJAAOnhtgoOWHisiohfw7uy7oZpVEh hcNVI53KJKGExYWoJ1nX3fTxpTSvPxpWB/DFQc1QX6mNi5hMAbTMUVZcsZF2sSkTSjNP /8/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QhZBFbrI; spf=pass (google.com: domain of mptcp+bounces-2947-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2947-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [2604:1380:1:3600::1]) by mx.google.com with ESMTPS id x10si2976360ybq.698.2022.01.06.16.20.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jan 2022 16:20:54 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2947-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) client-ip=2604:1380:1:3600::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QhZBFbrI; spf=pass (google.com: domain of mptcp+bounces-2947-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2947-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ewr.edge.kernel.org (Postfix) with ESMTPS id C01481C0F0C for ; Fri, 7 Jan 2022 00:20:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F19D02CAD; Fri, 7 Jan 2022 00:20:50 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB262C9D for ; Fri, 7 Jan 2022 00:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641514849; x=1673050849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UtZL9lW6Z7vfWdyQtIYFyHhpXBqpKoVl0bB1B2rjZSc=; b=QhZBFbrIyBWibl1Rt6EsJkRTONeHM1IykGUkIzc/R4uEt2rBZfNFA+R7 8l9ji9KRs53k3jE7h9ob5NNDzvAy3XOoAslCq8tracbA4lkZiAFGvR5JY NUIGhiWPqgiLkPa68IAVl4DFYc2rgxihWe1gVbbPpWn6YGS9ENQw8ePtU PtijtLzr9J6xFqimcjiHY0UJnBXae3rrSrf3Kfu+359XL3ndE96W0pYBN usUYcICH4ZHtUNeQWukFE+r9+hdsO4k7a/f3LSDWhkv8HyykBHL5t0/Sd 7BMSRCMTo0PfQ4FxHoaongVUnlo8uMefglmN80b4T/v8ObsTencJjG1rJ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10217"; a="329111022" X-IronPort-AV: E=Sophos;i="5.88,268,1635231600"; d="scan'208";a="329111022" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2022 16:20:34 -0800 X-IronPort-AV: E=Sophos;i="5.88,268,1635231600"; d="scan'208";a="618508494" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.94.200]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2022 16:20:34 -0800 From: Mat Martineau To: netdev@vger.kernel.org Cc: Paolo Abeni , davem@davemloft.net, kuba@kernel.org, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Geliang Tang , Mat Martineau Subject: [PATCH net-next 02/13] mptcp: implement fastclose xmit path Date: Thu, 6 Jan 2022 16:20:15 -0800 Message-Id: <20220107002026.375427-3-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220107002026.375427-1-mathew.j.martineau@linux.intel.com> References: <20220107002026.375427-1-mathew.j.martineau@linux.intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Allow the MPTCP xmit path to add MP_FASTCLOSE suboption on RST egress packets. Additionally reorder related options writing to reduce the number of conditionals required in the fast path. Co-developed-by: Geliang Tang Signed-off-by: Geliang Tang Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau --- net/mptcp/options.c | 57 ++++++++++++++++++++++++++++++++++---------- net/mptcp/protocol.h | 1 + 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index fe98e4f475ba..46d35a235f35 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -768,6 +768,28 @@ static noinline bool mptcp_established_options_rst(str= uct sock *sk, struct sk_bu return true; } =20 +static bool mptcp_established_options_fastclose(struct sock *sk, + unsigned int *size, + unsigned int remaining, + struct mptcp_out_options *opts) +{ + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(sk); + struct mptcp_sock *msk =3D mptcp_sk(subflow->conn); + + if (likely(!subflow->send_fastclose)) + return false; + + if (remaining < TCPOLEN_MPTCP_FASTCLOSE) + return false; + + *size =3D TCPOLEN_MPTCP_FASTCLOSE; + opts->suboptions |=3D OPTION_MPTCP_FASTCLOSE; + opts->rcvr_key =3D msk->remote_key; + + pr_debug("FASTCLOSE key=3D%llu", opts->rcvr_key); + return true; +} + static bool mptcp_established_options_mp_fail(struct sock *sk, unsigned int *size, unsigned int remaining, @@ -806,10 +828,12 @@ bool mptcp_established_options(struct sock *sk, struc= t sk_buff *skb, return false; =20 if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { - if (mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { + if (mptcp_established_options_fastclose(sk, &opt_size, remaining, opts) = || + mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { *size +=3D opt_size; remaining -=3D opt_size; } + /* MP_RST can be used with MP_FASTCLOSE and MP_FAIL if there is room */ if (mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) { *size +=3D opt_size; remaining -=3D opt_size; @@ -1251,17 +1275,8 @@ void mptcp_write_options(__be32 *ptr, const struct t= cp_sock *tp, ptr +=3D 2; } =20 - /* RST is mutually exclusive with everything else */ - if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) { - *ptr++ =3D mptcp_option(MPTCPOPT_RST, - TCPOLEN_MPTCP_RST, - opts->reset_transient, - opts->reset_reason); - return; - } - - /* DSS, MPC, MPJ and ADD_ADDR are mutually exclusive, see - * mptcp_established_options*() + /* DSS, MPC, MPJ, ADD_ADDR, FASTCLOSE and RST are mutually exclusive, + * see mptcp_established_options*() */ if (likely(OPTION_MPTCP_DSS & opts->suboptions)) { struct mptcp_ext *mpext =3D &opts->ext_copy; @@ -1447,6 +1462,24 @@ void mptcp_write_options(__be32 *ptr, const struct t= cp_sock *tp, ptr +=3D 1; } } + } else if (unlikely(OPTION_MPTCP_FASTCLOSE & opts->suboptions)) { + /* FASTCLOSE is mutually exclusive with others except RST */ + *ptr++ =3D mptcp_option(MPTCPOPT_MP_FASTCLOSE, + TCPOLEN_MPTCP_FASTCLOSE, + 0, 0); + put_unaligned_be64(opts->rcvr_key, ptr); + ptr +=3D 2; + + if (OPTION_MPTCP_RST & opts->suboptions) + goto mp_rst; + return; + } else if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) { +mp_rst: + *ptr++ =3D mptcp_option(MPTCPOPT_RST, + TCPOLEN_MPTCP_RST, + opts->reset_transient, + opts->reset_reason); + return; } =20 if (OPTION_MPTCP_PRIO & opts->suboptions) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0486c9f5b38b..f177936ff67d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -423,6 +423,7 @@ struct mptcp_subflow_context { backup : 1, send_mp_prio : 1, send_mp_fail : 1, + send_fastclose : 1, rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */ --=20 2.34.1