From nobody Mon Feb 9 12:09:30 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6638:bd2:0:0:0:0 with SMTP id g18csp2020401jad; Thu, 24 Feb 2022 15:22:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0LGP5iA/p4oAjtiNlz5cqpAMD3BfLOZkNfAO8+WOdnKTT44tX0Td3FPFTzQylmT20zrSv X-Received: by 2002:a17:90a:9408:b0:1b5:3908:d3d1 with SMTP id r8-20020a17090a940800b001b53908d3d1mr407688pjo.188.1645744956311; Thu, 24 Feb 2022 15:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645744956; cv=none; d=google.com; s=arc-20160816; b=ip6oAiSxky/tJ2UvYWu4u5VTwJCNGBA1hvCB2PltMMAF2TJnsXdGSiyTjlDZdAQHHC tAU8WDzUAYDnmYC8Y/8bZwLJvVsV+9LI+Og/ywJzA72HMhqRMhQru3Cijwl6Oxtfctc1 /LlucPlJoihjz46CCvScF0bvnfDKMGDq8+xj7LAuuYewiaCb6LWrivzhNbXJuaJnh79k z8/p3fgwmutzpMaLQt9Z0tUPQbgkes99Dw8TP3MLUbJFHqh3AgrKwGEs9hqIlEtrmSOP FRXUm2uDJukUqSLqYK8fWRzY5RhJD7kmVMpjHTDFa282qxUJkrSUX/SgqGH6oZST2OtP ieSQ== 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=j7BEh702zJvVyiLCDT5WBGbJRNKxuoU4tUYAvEh8+kg=; b=w1aG7foeyVPnh90HiPjS6F+b361JM3mHQr92pVlJIUjCuYvKa88C+In6v8bTldAq9+ RiYWAi1x3+3o5puCKFWOn7WL2dEE60LdzHjdfkC/3gto+DAjeVEP1MNmeFQhOTDAbeqs wraq/v1aVxBnzm7Vb1PEqUTb1IqHcL7a/SyX2GCJfhlaJGvwoWnWWEf1YFz22UdByau2 LZWwR6RwStgTD2YLsrdRX5CH1/N36kURZlxeLFhPGlLG/2aN/PM1Blkl3WlZuQzHxx5f bbJUC479GUBMSvxT0QFD7Dzd2KEXwnY19HXYpdOU/N3/OUUKUxXLAnPStd4E2yE057hu ETLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V1xqvcKv; spf=pass (google.com: domain of mptcp+bounces-4030-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-4030-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [147.75.69.165]) by mx.google.com with ESMTPS id g24-20020a170902869800b0014c8e454184si423539plo.199.2022.02.24.15.22.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Feb 2022 15:22:36 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-4030-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) client-ip=147.75.69.165; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V1xqvcKv; spf=pass (google.com: domain of mptcp+bounces-4030-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-4030-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 sjc.edge.kernel.org (Postfix) with ESMTPS id 96F123E0F62 for ; Thu, 24 Feb 2022 23:22:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8C4F10E1; Thu, 24 Feb 2022 23:22:32 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 D44E010E2 for ; Thu, 24 Feb 2022 23:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645744951; x=1677280951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MPcoIlfb8cRyOXEBIy/zCEWbrLuumRm9LC6RGE9AxLE=; b=V1xqvcKvlT5VrxakkfF5GRJNF9ZrioiJagQnLFOrjAb/mxEO6KlFGZsn cIzdGTwxOGk2qr83JBWfcfLxkxHB/ncEOD+2xrGh3HfoRwy1mOvTBpgw5 D3TyRYwbPbWDDFZU7pUPlqgBHM9QpNDvWxNa3iYn1FetEfk78xSipW1IZ LwGbLQK0aiA/MIiIwUXOV3ygVuli+4rLvcLpshUlYvFpFTqT5RqXM5jMy nf47ILy4z1Gak4j4FSPg/RbqHHAlPvOhwOQyQ2sJtJykIcl4raOnvcRbc /1l8sdYDS7lTrecdSwXn/kEj8qx9jZVICcPHjrw4mZOn3BPWvhVIWaX23 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10268"; a="232998400" X-IronPort-AV: E=Sophos;i="5.90,134,1643702400"; d="scan'208";a="232998400" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2022 15:22:28 -0800 X-IronPort-AV: E=Sophos;i="5.90,134,1643702400"; d="scan'208";a="491784933" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.28.67]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2022 15:22:28 -0800 From: Mat Martineau To: mptcp@lists.linux.dev Cc: Mat Martineau , fw@strlen.de Subject: [RFC PATCH mptcp-next 4/4] tcp: Add TCP hooks for detecting MP_JOIN on a regular TCP listener Date: Thu, 24 Feb 2022 15:22:26 -0800 Message-Id: <20220224232226.259304-5-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224232226.259304-1-mathew.j.martineau@linux.intel.com> References: <20220224232226.259304-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" MPTCP uses a TCP SYN packet with the MP_JOIN option to add subflows to an existing MPTCP connection. This uses token lookup to match the incoming SYN with the appropriate MPTCP socket instead of the port number (in accordance with RFC 8684), and it is possible for a TCP listener to be present at the port that the MPTCP peer is trying to connect to. If the TCP listener ignores the MP_JOIN option and sends a normal TCP SYN-ACK without a MP_JOIN option header, the peer will be forced to send a RST. Given that a peer sending MP_JOIN is guaranteed to reject a regular TCP SYN-ACK, it's better to attempt a MPTCP token lookup and either let MPTCP continue the handshake or immediately reject the connection attempt. The only new conditional in the TCP SYN handling hot path is a check of the saw_mp_join bit. If that is set, tcp_check_req() returns early and tcp_v4_rcv() or tcp_v6_rcv() call the MPTCP join handler in an error path. If MPTCP is not configured, all the code added in this commit should be optimized away. Signed-off-by: Mat Martineau --- net/ipv4/tcp_ipv4.c | 7 +++++++ net/ipv4/tcp_minisocks.c | 8 +++++++- net/ipv6/tcp_ipv6.c | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 73e5726af8d0..124ad393e6fb 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2082,6 +2082,13 @@ int tcp_v4_rcv(struct sk_buff *skb) tcp_v4_restore_cb(skb); sock_put(sk); goto lookup; + } else if (req_status =3D=3D TCP_REQ_MP_JOIN) { + struct sock *msk =3D mptcp_handle_join4(skb); + + if (msk) { + sk =3D msk; + goto process; + } } goto discard_and_relse; } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 3d989f8676a5..4fdca31b33bb 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -572,10 +572,16 @@ struct sock *tcp_check_req(struct sock *sk, struct sk= _buff *skb, bool own_req; =20 tmp_opt.saw_tstamp =3D 0; + tmp_opt.saw_mp_join =3D 0; if (th->doff > (sizeof(struct tcphdr)>>2)) { tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL); =20 - if (tmp_opt.saw_tstamp) { + if (unlikely(tmp_opt.saw_mp_join) && + mptcp_is_enabled(sock_net(sk))) { + *req_status =3D TCP_REQ_MP_JOIN; + + return NULL; + } else if (tmp_opt.saw_tstamp) { tmp_opt.ts_recent =3D req->ts_recent; if (tmp_opt.rcv_tsecr) tmp_opt.rcv_tsecr -=3D tcp_rsk(req)->ts_off; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 4706aad6dd8f..d46fa8243e83 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1731,6 +1731,13 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buf= f *skb) tcp_v6_restore_cb(skb); sock_put(sk); goto lookup; + } else if (req_status =3D=3D TCP_REQ_MP_JOIN) { + struct sock *msk =3D mptcp_handle_join6(skb); + + if (msk) { + sk =3D msk; + goto process; + } } goto discard_and_relse; } --=20 2.35.1