From nobody Thu Sep 18 07:00:25 2025 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6a06:869:b0:4b8:7781:bd2f with SMTP id d41csp2379822pis; Tue, 17 May 2022 11:02:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHsTmchGDHnwopre7oTI0ltW5uCMsdbKlgZudgD21Xyz2E8FGMh8588EVcv/yeSlo7m+Cd X-Received: by 2002:a17:906:301a:b0:6f3:fdd3:4d1c with SMTP id 26-20020a170906301a00b006f3fdd34d1cmr20791566ejz.235.1652810546648; Tue, 17 May 2022 11:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652810546; cv=none; d=google.com; s=arc-20160816; b=aNlpJ1KrpTdIJue9Jlnzg+4MzRA3K1+jHDnYGjupuOWfdOh7oAS5Te7uXQmEh+X+5i SAlqIZI2KvoeWvc/kJO5OBpxEZGT0ceGPkjNFMBX0VN6OyZJKD/+dGjF2wMvUZFt7cgt IIBCFIsBEL6pQNEl6EUYDG+U0zLlNb6mOyQXXKV6lpAM0BtmMF6fJlv2rJrOEW8dRa40 OSf8hx3JwR4EIhPLnZAI0u2SFsXrXoL2VPKL57nS3CQENNL4xCD2mQakqCv71SMgKokH KqABuHMZt3FtLjnApex/sbJyHUesBZSK5e1sQ/5gdnAKpdLiMdJYf1JeA9FSIZgbt40e 73Zw== 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=OGO242RRGGbGBmuyxGaYg4u2JIigZxn7aF6hiPn9Mwk=; b=DoMqX8XR2h9bKzGXF5fb7N2xTlidkr9UvSe+WtRon7Sbuowt0SSS2Zv8iYtlm4IyTi XkfqfXCoMIsQKaKX6+ynX2aqSVRssS2+pB7DWwWn/KX/Ym//ACMLtHCYq00YXXK6O9fr 2V5u+7w5XXwyasqeYv8S6103TB6yYYRCt6jxNCgnK+Y9AM/U0yYHFPFHhtQ1M+BxkT4X Ufn6MwfKeh+PEULIC02Yk9TcBkoe3BB/0zh6yc/QQ9vgc+N3pP5OeDxAOqH81QtM6YeR VuO/sU4ZiwURIhWF8kbyQ7CmbaRZpZEvb0DurQu6SP7VvlcIwS+L57ZqfsU1Faeyw5YA JKrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hfCKfQUc; spf=pass (google.com: domain of mptcp+bounces-5348-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:4040:4f00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5348-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from da.mirrors.kernel.org (da.mirrors.kernel.org. [2604:1380:4040:4f00::1]) by mx.google.com with ESMTPS id gs12-20020a1709072d0c00b006df76385f10si4476341ejc.944.2022.05.17.11.02.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2022 11:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5348-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:4040:4f00::1 as permitted sender) client-ip=2604:1380:4040:4f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hfCKfQUc; spf=pass (google.com: domain of mptcp+bounces-5348-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:4040:4f00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5348-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 da.mirrors.kernel.org (Postfix) with ESMTPS id A89822E09DE for ; Tue, 17 May 2022 18:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14F911860; Tue, 17 May 2022 18:02:23 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 D9C661854 for ; Tue, 17 May 2022 18:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652810541; x=1684346541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NPyjrYQpM53zicvELSUePCB3rJhTOtiZ364J8gH2kPU=; b=hfCKfQUcb+8adg4blFtWp2b4I1oJVPmuZ5hhb8UpSyzjR6QS9Y3Dc1cg iZbRA3a8754oZtrO2hwm+MFd9rKa7L8PNgPdl1IjxM9Oz92C4CycbB33x 2Hda1GzArCyH5EJsmmi73fyrF/mKarkeNskCbE6QOLgSk33uvm6Ac9Pmf EjX0FEiE2YZWfER0oWcYv8QCaKE9bI1QuZgKIMyIlyxqAaG8MvjNqxBaV M52i3/H6hRHWEwrGPdwo0bNgwTWGVH0jp+l3RZSPn4xw6owWF79LRZO/E KeR7E5T0LCMHUwSPp2Dd3khyqX190bj1sbZqNzKJ+vhr0ALhdv6ZvmzYv A==; X-IronPort-AV: E=McAfee;i="6400,9594,10350"; a="331887958" X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="331887958" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 11:02:19 -0700 X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="523080352" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.6.57]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 11:02:17 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Paolo Abeni , davem@davemloft.net, kuba@kernel.org, edumazet@google.com, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net 1/2] mptcp: fix checksum byte order Date: Tue, 17 May 2022 11:02:11 -0700 Message-Id: <20220517180212.92597-2-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220517180212.92597-1-mathew.j.martineau@linux.intel.com> References: <20220517180212.92597-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 The MPTCP code typecasts the checksum value to u16 and then converts it to big endian while storing the value into the MPTCP option. As a result, the wire encoding for little endian host is wrong, and that causes interoperabilty interoperability issues with other implementation or host with different endianness. Address the issue writing in the packet the unmodified __sum16 value. MPTCP checksum is disabled by default, interoperating with systems with bad mptcp-level csum encoding should cause fallback to TCP. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/275 Fixes: c5b39e26d003 ("mptcp: send out checksum for DSS") Fixes: 390b95a5fb84 ("mptcp: receive checksum for DSS") Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau --- net/mptcp/options.c | 36 ++++++++++++++++++++++++------------ net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 325383646f5c..b548cec86c9d 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -107,7 +107,7 @@ static void mptcp_parse_option(const struct sk_buff *sk= b, ptr +=3D 2; } if (opsize =3D=3D TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM) { - mp_opt->csum =3D (__force __sum16)get_unaligned_be16(ptr); + mp_opt->csum =3D get_unaligned((__force __sum16 *)ptr); mp_opt->suboptions |=3D OPTION_MPTCP_CSUMREQD; ptr +=3D 2; } @@ -221,7 +221,7 @@ static void mptcp_parse_option(const struct sk_buff *sk= b, =20 if (opsize =3D=3D expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) { mp_opt->suboptions |=3D OPTION_MPTCP_CSUMREQD; - mp_opt->csum =3D (__force __sum16)get_unaligned_be16(ptr); + mp_opt->csum =3D get_unaligned((__force __sum16 *)ptr); ptr +=3D 2; } =20 @@ -1240,7 +1240,7 @@ static void mptcp_set_rwin(const struct tcp_sock *tp) WRITE_ONCE(msk->rcv_wnd_sent, ack_seq); } =20 -u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum = sum) +__sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __w= sum sum) { struct csum_pseudo_header header; __wsum csum; @@ -1256,15 +1256,25 @@ u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq= , u16 data_len, __wsum sum) header.csum =3D 0; =20 csum =3D csum_partial(&header, sizeof(header), sum); - return (__force u16)csum_fold(csum); + return csum_fold(csum); } =20 -static u16 mptcp_make_csum(const struct mptcp_ext *mpext) +static __sum16 mptcp_make_csum(const struct mptcp_ext *mpext) { return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data= _len, ~csum_unfold(mpext->csum)); } =20 +static void put_len_csum(u16 len, __sum16 csum, void *data) +{ + __sum16 *sumptr =3D data + 2; + __be16 *ptr =3D data; + + put_unaligned_be16(len, ptr); + + put_unaligned(csum, sumptr); +} + void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { @@ -1340,8 +1350,9 @@ void mptcp_write_options(__be32 *ptr, const struct tc= p_sock *tp, put_unaligned_be32(mpext->subflow_seq, ptr); ptr +=3D 1; if (opts->csum_reqd) { - put_unaligned_be32(mpext->data_len << 16 | - mptcp_make_csum(mpext), ptr); + put_len_csum(mpext->data_len, + mptcp_make_csum(mpext), + ptr); } else { put_unaligned_be32(mpext->data_len << 16 | TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); @@ -1392,11 +1403,12 @@ void mptcp_write_options(__be32 *ptr, const struct = tcp_sock *tp, goto mp_capable_done; =20 if (opts->csum_reqd) { - put_unaligned_be32(opts->data_len << 16 | - __mptcp_make_csum(opts->data_seq, - opts->subflow_seq, - opts->data_len, - ~csum_unfold(opts->csum)), ptr); + put_len_csum(opts->data_len, + __mptcp_make_csum(opts->data_seq, + opts->subflow_seq, + opts->data_len, + ~csum_unfold(opts->csum)), + ptr); } else { put_unaligned_be32(opts->data_len << 16 | TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f4ce28bb0fdc..fb40dd676a26 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -723,7 +723,7 @@ void mptcp_token_destroy(struct mptcp_sock *msk); void mptcp_crypto_key_sha(u64 key, u32 *token, u64 *idsn); =20 void mptcp_crypto_hmac_sha(u64 key1, u64 key2, u8 *msg, int len, void *hma= c); -u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum = sum); +__sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __w= sum sum); =20 void __init mptcp_pm_init(void); void mptcp_pm_data_init(struct mptcp_sock *msk); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 8c37087f0d84..e90fe7eec43a 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -888,7 +888,7 @@ static enum mapping_status validate_data_csum(struct so= ck *ssk, struct sk_buff * { struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); u32 offset, seq, delta; - u16 csum; + __sum16 csum; int len; =20 if (!csum_reqd) --=20 2.36.1 From nobody Thu Sep 18 07:00:25 2025 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6a06:869:b0:4b8:7781:bd2f with SMTP id d41csp2379793pis; Tue, 17 May 2022 11:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmUXkEADNEiE5xRuTHPPCgqXCfDicvqRpiKZq8vtcI8orID+MaRFRbrK8FMVMZyV2rcvmW X-Received: by 2002:a17:90b:1c04:b0:1dc:4dfd:5a43 with SMTP id oc4-20020a17090b1c0400b001dc4dfd5a43mr37928016pjb.160.1652810543887; Tue, 17 May 2022 11:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652810543; cv=none; d=google.com; s=arc-20160816; b=RmSFTD8G1Niv6ILS0zbIq4+p39dQKP7ts6YA/W2G8Qc4ML28jrtGZdyaE1FSuad8WL Qq4fKt9dByecwKq8PG5Mwjir0bd1u4QeJa44uhtebael2+NuD+4CVa3EiSC0TZLOlOkt WdcDzTkSwGgUEDjlURDB4XtLeysPRgyk0ukDLT84IrVXGgpJLR4BcvJA3M1Z1XKyqPFp 1se9pVk5NkL2ku4iQ3mqq20WqrWG57mu4DbtNNL3a8XcOlCHhfXBj4gHAcmV12kiyV72 BBEEMvHvkFQzSype1H/wZcjQjwk+7sAm564vHFSjgTTlVLR9wrRRWP2dYXcSAdg1skEH cCKw== 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=O54ECXfJkOhz+y+8be+PlNWnhYIZNkJDd7kihO4BpDQ=; b=IWWEz6123AsL8PuOCrPtFbzEV0rUyxoPjg/V0W61wFlHEQxgYk0/MbtTmRbD2vACnv doLDmh4B4UxfT+/7AqvFuXECJGN2rbs1dwyv7OkVZ/7afUZPXKKCyiCxkjhoylS5kZ0q Gb1qmYlcNW78V1dBvW1ypJFz4S4+kLd4BBYEvp0BoWWSMJcA1Wgn9ovf2lVHKxe+B+lF 45j/KGZtJH2EUsrx6chr0023r1rsxFXSx06bVvXswPbmFn7kEiqvwJ3nD3Jjz/dGnIah 6TKTVSqucQZZMM2fHxt+8B/XYrVwkKGB4ptZ9/5WCUqhVIdzaM/rbjC50vagWVcRx/6m 2BVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V93octjC; spf=pass (google.com: domain of mptcp+bounces-5346-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5346-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e14-20020a170902ef4e00b00156b24c4bb6si16838625plx.120.2022.05.17.11.02.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2022 11:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5346-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V93octjC; spf=pass (google.com: domain of mptcp+bounces-5346-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5346-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E170F280936 for ; Tue, 17 May 2022 18:02:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87DBA185F; Tue, 17 May 2022 18:02:21 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 393081854 for ; Tue, 17 May 2022 18:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652810540; x=1684346540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9i15zZu1wsyIycRzynIEjtH80AivT4HanS2rE/bQPcI=; b=V93octjC6sbwzmva5bwJgg7j2F5qPbMcrw72/LuD7GwSBfeNN+CpM4Yg AJ1vI2xcFtm+/NI3gnLKBEbyOlv4n5tW7qW/Xy/ed61a6nuuyPuGvk9jh K6j0lnDM36xulMVzxeFQCY6dPTZ1mbQxy41c2i24zzU/Dw/Abx/rIo65p 19Hn1vSMFkwXfarvwQGX2idvNer4ju+YXVnvW7ZXMmUPe5zZUvfOSRYul UwAv+CObVZZxP4vOAccoht7omqi8Z3QJjO7bKElb96ijXLO5Ib3u/uArH OuYgHE6LqfZZ2WuvHJDUOHl0Pl356UFJI0xePHFg4b9rsZloEi3D593AJ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10350"; a="331887956" X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="331887956" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 11:02:19 -0700 X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="523080354" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.6.57]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 11:02:17 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Mat Martineau , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, matthieu.baerts@tessares.net, mptcp@lists.linux.dev Subject: [PATCH net 2/2] mptcp: Do TCP fallback on early DSS checksum failure Date: Tue, 17 May 2022 11:02:12 -0700 Message-Id: <20220517180212.92597-3-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220517180212.92597-1-mathew.j.martineau@linux.intel.com> References: <20220517180212.92597-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" RFC 8684 section 3.7 describes several opportunities for a MPTCP connection to "fall back" to regular TCP early in the connection process, before it has been confirmed that MPTCP options can be successfully propagated on all SYN, SYN/ACK, and data packets. If a peer acknowledges the first received data packet with a regular TCP header (no MPTCP options), fallback is allowed. If the recipient of that first data packet finds a MPTCP DSS checksum error, this provides an opportunity to fail gracefully with a TCP fallback rather than resetting the connection (as might happen if a checksum failure were detected later). This commit modifies the checksum failure code to attempt fallback on the initial subflow of a MPTCP connection, only if it's a failure in the first data mapping. In cases where the peer initiates the connection, requests checksums, is the first to send data, and the peer is sending incorrect checksums (see https://github.com/multipath-tcp/mptcp_net-next/issues/275), this allows the connection to proceed as TCP rather than reset. Fixes: dd8bcd1768ff ("mptcp: validate the data checksum") Acked-by: Paolo Abeni Signed-off-by: Mat Martineau --- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fb40dd676a26..5655a63aa6a8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -443,7 +443,8 @@ struct mptcp_subflow_context { can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ - local_id_valid : 1; /* local_id is correctly initialized */ + local_id_valid : 1, /* local_id is correctly initialized */ + valid_csum_seen : 1; /* at least one csum validated */ enum mptcp_data_avail data_avail; u32 remote_nonce; u64 thmac; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index e90fe7eec43a..be76ada89d96 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -955,11 +955,14 @@ static enum mapping_status validate_data_csum(struct = sock *ssk, struct sk_buff * subflow->map_data_csum); if (unlikely(csum)) { MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR); - subflow->send_mp_fail =3D 1; - MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX); + if (subflow->mp_join || subflow->valid_csum_seen) { + subflow->send_mp_fail =3D 1; + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX); + } return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; } =20 + subflow->valid_csum_seen =3D 1; return MAPPING_OK; } =20 @@ -1141,6 +1144,18 @@ static void subflow_sched_work_if_closed(struct mptc= p_sock *msk, struct sock *ss } } =20 +static bool subflow_can_fallback(struct mptcp_subflow_context *subflow) +{ + struct mptcp_sock *msk =3D mptcp_sk(subflow->conn); + + if (subflow->mp_join) + return false; + else if (READ_ONCE(msk->csum_enabled)) + return !subflow->valid_csum_seen; + else + return !subflow->fully_established; +} + static bool subflow_check_data_avail(struct sock *ssk) { struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); @@ -1218,7 +1233,7 @@ static bool subflow_check_data_avail(struct sock *ssk) return true; } =20 - if (subflow->mp_join || subflow->fully_established) { + if (!subflow_can_fallback(subflow)) { /* fatal protocol error, close the socket. * subflow_error_report() will introduce the appropriate barriers */ --=20 2.36.1