Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3686051lfo; Mon, 23 May 2022 11:24:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiF7dPL8RYcYYj30GoJEOLGJwCk4vL1m30+F8A314O8eDoM6TXrElfYcln693vPFeYGEA/ X-Received: by 2002:a17:902:ea04:b0:161:c283:8c0b with SMTP id s4-20020a170902ea0400b00161c2838c0bmr23924684plg.52.1653330268974; Mon, 23 May 2022 11:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330268; cv=none; d=google.com; s=arc-20160816; b=xCf5KS/X9q6asXOXBI7jpVuAhZlWQI/s2ZWgeCBlCAw0bdJbfulYOHtMM16iV06V5X bp4u1b2MrR6xEPyLZWu1+bR+sQXl/I6tnu/0kMfsdNoQ9hwKewwfbw63a+qs2IiN44mk P4IyUtYlaR27lhZ/uq5x2IgKTJvBiOt9L7G20euYU8MZo4l6AMHLyqTqKzDlEg8i821E gALkpl7XlyBlB+3nIQADDkvK/wYr4ctzRx4YsNZ3sv4GFoST/8WixazfXY10B4+Ml4Dw i9puoJV3w513ME20qwAO5YKJas6qpeACDj+xYDHGUlByLeLPmeJnNkFFQVKBPKX8B/7E KpgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3H8xdeSLxl2n/oUgdmN51sgau36EVTPKTCVD5UnlwL4=; b=tntpSEBnZPvqx47N2tv+QMHlgFDpb4uQhawGwVHoZR7A5LdTpRa988s10waF9+Bl2e seF0V8xbe/mB+V7fuD81Tik+LNyH0ACwo7ROkS5pnaYHDiacmNghT5xJmeNFH7Ig9DP2 yhPu+OIrekla4bsZwJWebjyXaZDe7JpoUZG7YYbjd9H8ETKFRlg0lyTJgb+IJWtIVJwI SgM0VzvDKYDabbAmdZG+/aEu9yXlIK3LPMgAdkyTT1+Wqpp2WlE/diEKsNDJ/Zp64XBE Yb0whPll68QYcPd7HATxgQig3a4YPqAuaoWU6hvMeUFxbxc3jRzw9PHtn+SFo7LYNOUD IwYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xQzOtvM9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f8-20020a056a001ac800b0050d4265128dsi19519985pfv.313.2022.05.23.11.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:24:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xQzOtvM9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2378D19FB21; Mon, 23 May 2022 11:24:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244690AbiEWSRT (ORCPT + 99 others); Mon, 23 May 2022 14:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243232AbiEWSBU (ORCPT ); Mon, 23 May 2022 14:01:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32FB6DFF74; Mon, 23 May 2022 10:46:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 101B9B81202; Mon, 23 May 2022 17:29:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CCF8C34115; Mon, 23 May 2022 17:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326969; bh=4lto3opJQdBcvB9mshv3B7x9QIIiku/yZIV+JmzGeQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xQzOtvM9JC0V7HwfC58bMUbkkTAuEsHm9mALqlQWRf7QXU0Q3EqHT5zjE30AVxSMt 7+iSAdVAQZDR5mfEhbT+KjvR3OyneIjUrGh7DhkZ1no4g+Raj+8hG/Khu9eo6LCANa nFTQLGvsOW2FPBuGDh9oejvjeDKIgfblX46mZp9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 115/158] mptcp: Do TCP fallback on early DSS checksum failure Date: Mon, 23 May 2022 19:04:32 +0200 Message-Id: <20220523165850.007093415@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 From: Mat Martineau [ Upstream commit ae66fb2ba6c3dcaf8b9612b65aa949a1a4bed150 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 e4413b3e50c2..8015389859d9 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 e27574e9f969..7a3a70067c80 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -958,11 +958,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 = 1; - MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX); + if (subflow->mp_join || subflow->valid_csum_seen) { + subflow->send_mp_fail = 1; + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX); + } return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; } + subflow->valid_csum_seen = 1; return MAPPING_OK; } @@ -1144,6 +1147,18 @@ static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ss } } +static bool subflow_can_fallback(struct mptcp_subflow_context *subflow) +{ + struct mptcp_sock *msk = 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 = mptcp_subflow_ctx(ssk); @@ -1221,7 +1236,7 @@ static bool subflow_check_data_avail(struct sock *ssk) return true; } - 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 */ -- 2.35.1