From patchwork Fri Nov 25 22:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4326238wrr; Fri, 25 Nov 2022 14:33:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Zfcj9223RA2EpjqVKPF9eMXCjin6m8NcDH22vLvhfn0r1w1B7/uKelow78yHgIZkyx3EE X-Received: by 2002:a63:e618:0:b0:470:15cd:d425 with SMTP id g24-20020a63e618000000b0047015cdd425mr17478301pgh.27.1669415581239; Fri, 25 Nov 2022 14:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415581; cv=none; d=google.com; s=arc-20160816; b=0VroC1B75nvhWFlKJ5EoR10iZsfA6BUwI2ShbG1KH4F+BSucYpbLQZ8bY1mUya8bHK vKMsl51Sn0BmyXVVOD5kqeD/Wt8ejQpTEqgiX11YuunqOmsjnhbykzCLASz7MYRme3Qq gKOZnQ3sMkOyMKAnZQ+vDAhhWMSUybEtl2X3tLLdR2UqmGk3bsCMzyOO/6FEs9kICVZj 4XTJi9uEyO6Qdzbaf774zTZT7jSnj6w/xqTVRXK4CvF2KqamXTaITt2z5s5iF6vb5qB+ dwfQmY+nwAqAMGK4Enn4S3V28DyWGkOD6kUs/BAUzTArAkUeqo6JKXZa/fWAEb0SM9bP /xYg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=hCsybuAv7oTRtU9Aw+gUulOcJbsgzhF/xvcc/DULop4VI3FXSm4pOoFXrpMLKxzRBF qWS1gTVpg7Iq2PrZGkTTxoHZa+VuPFnUnGaJAGIRQM2UvEX3xIKTC3fu6z6qOplksR9M AbKAozKGmQNb59R+6+ri4kZj0osTEXMIYdQJRMa7yU61BQ034nN5GjBsJJySsPFd9ex1 0GzIstFGBdTwwQq0Y0U1tr5si2dL2ngHvASUs2mceYyiq1hyyzOcjSgngeMHrZke/qRR DfzovivrLak96yCby67tjheP9dP/jFsyI5YMtXfWO08q/khEVImR142n60/6T+EelwQA 8gnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=dr2wjAd4; 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=NONE sp=NONE 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 x5-20020a654145000000b0042b807728e3si3648702pgp.762.2022.11.25.14.32.48; Fri, 25 Nov 2022 14:33:01 -0800 (PST) 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=dr2wjAd4; 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=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbiKYWar (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbiKYWai (ORCPT ); Fri, 25 Nov 2022 17:30:38 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C4858024 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id fy37so13005527ejc.11 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=dr2wjAd4gkwx+qYAtXISU4a8RG6hRFOYZoFmqFNU6SaL98Blbwc7dc0T5r169CVAVo SJjt4RdA2bP92GkTgHeNLWQdCy6d7nnesUwT/kvtdx47MWUUhTqRXOd8Ndvtg/z+dD+V 38Mm11HKR1Do/MM3zAGeyldzbGwqI+dGLmQWyl6+Su7Y1SMXcTgZSNydfInI9watehPJ Dc1kVCZ9YdLEiEcO5IAui8rojV+A/uR/P0ur3YOIm6rPSXWDzJue77p5Kn7jKG6hKENg pmCcZ77YRLYLtIbxwqqHgp/JbGbn08ceEljjUqVC9SwoK72sdSpnVwlS0yhZuMeCBtx2 O3+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=bxhiAfY6hpCh9n3sveTLNEdvoc7NimrQz7HmaYKNLdb2paGoCMNpkVUSyjrGDEU5kQ +8rO34pDW7u8cTknmftP/+BOFzaNW2PTg8i4OgI+oYdrKKHP5b0GB0BMN1ie5KAIvB5D aJLFSjIxLo6n/Ur7gJaaAXov4nCkdXbHTNWEf8Ehzu+sP69+aHJw4iPlqwllrRcKnkuA 685rM5ON7RCey1mUWWgjeQa3ToiGn1OqDYihgWJQJrBzotwfdyUgimTcqUEPmuMcCpbR wSBxG1rCqsltohhUtRt5nZx7Rhvk36kkEO6fFE8IJMMcfszOPj7YWRG7iyXdJt1ybFCs VIFg== X-Gm-Message-State: ANoB5pmA0FRyOG4a70QvLWdc3VGHofINtJ7wXoGj4aNKXRgq+Se9f+ps cwBSe0ii8snqCPg892UCPxKcSw== X-Received: by 2002:a17:906:7f05:b0:7af:a2d4:e95c with SMTP id d5-20020a1709067f0500b007afa2d4e95cmr34927417ejr.666.1669415427505; Fri, 25 Nov 2022 14:30:27 -0800 (PST) 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 q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:27 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dmytro Shytyi , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/8] mptcp: add subflow_v(4,6)_send_synack() Date: Fri, 25 Nov 2022 23:29:51 +0100 Message-Id: <20221125222958.958636-6-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6996; i=matthieu.baerts@tessares.net; h=from:subject; bh=fdHE6VR0e50V3X4U9+VV9KhWPpVVAiIAwbBlfqLVJp8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHP3MXt3FbPPsm+gevtwbsKKSJstEFM/rU6ZzUm 6Tmo8giJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgcwbMEA DLIGqNOZL8Z7PBRtg5eTSLam0r2PV8s8wx7018znKHUSypysd7eiiM/YVsRPayrkWCfXcfDO32CHVz 7xNqxpkoP8CWcEY0tQHUHJfz9qfApswpBmmng1IcC9Rr0o5xt3cx4YXi33c/dcdo98h3bMNusIp0gc reIUux4e04ciaF6nm0NGsAoXkb6kZ8pLw7ouaWuuS8xT9n3fEQOPNEKlZua3It02ltFswIBH1nqYkz ljvPTcwun77le5LjTma922mtesD5SVtoZsZxcP/aB2hJ5HvCF2++/sph1GdKHSpFB3HKdHjp9UfRTf q8S1GObmWvuwOt1gNgcB+bq7sSJdXEZgZVVakmxYFHsCYMOZ6ESTA4WycMUrENU0wqoL6RyDH1gber c3y6+F62/xiDujNdkFT/qvhF3bZRT4upioYyT8F3WvchTSqZCTYd1vVr0jP1qT94b2JJFZLAko8Jri h3vL5uFV88iF2NEB632PwyojhD57wljYrBw57Sf+FCw9Z8/brn+euXG+FGrjulprQUscXPBo5S81V3 uiX8NcBSrXpKdNmw+3/hQNYOgxqZEIBChwevVgc0c1iSX0+W65x5wx712wBScYGWHeZ53t7VTCOGEM I4fb/1bCES0swP3NBLtiFcb6J6NcTXfNlbNhcmu0aFdeeqbQIcvy5KdMIl+w== 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?1750509112498692249?= X-GMAIL-MSGID: =?utf-8?q?1750509112498692249?= From: Dmytro Shytyi The send_synack() needs to be overridden for MPTCP to support TFO for two reasons: - There is not be enough space in the TCP options if the TFO cookie has to be added in the SYN+ACK with other options: MSS (4), SACK OK (2), Timestamps (10), Window Scale (3+1), TFO (10+2), MP_CAPABLE (12). MPTCPv1 specs -- RFC 8684, section B.1 [1] -- suggest to drop the TCP timestamps option in this case. - The data received in the SYN has to be handled: the SKB can be dequeued from the subflow sk and transferred to the MPTCP sk. Counters need to be updated accordingly and the application can be notified at the end because some bytes have been received. [1] https://www.rfc-editor.org/rfc/rfc8684.html#section-b.1 Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- net/mptcp/fastopen.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 3 +++ net/mptcp/subflow.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 19c332af0834..d237d142171c 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -6,6 +6,51 @@ #include "protocol.h" +void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow, + struct request_sock *req) +{ + struct sock *ssk = subflow->tcp_sock; + struct sock *sk = subflow->conn; + struct sk_buff *skb; + struct tcp_sock *tp; + + tp = tcp_sk(ssk); + + subflow->is_mptfo = 1; + + skb = skb_peek(&ssk->sk_receive_queue); + if (WARN_ON_ONCE(!skb)) + return; + + /* dequeue the skb from sk receive queue */ + __skb_unlink(skb, &ssk->sk_receive_queue); + skb_ext_reset(skb); + skb_orphan(skb); + + /* We copy the fastopen data, but that don't belong to the mptcp sequence + * space, need to offset it in the subflow sequence, see mptcp_subflow_get_map_offset() + */ + tp->copied_seq += skb->len; + subflow->ssn_offset += skb->len; + + /* initialize a dummy sequence number, we will update it at MPC + * completion, if needed + */ + MPTCP_SKB_CB(skb)->map_seq = -skb->len; + MPTCP_SKB_CB(skb)->end_seq = 0; + MPTCP_SKB_CB(skb)->offset = 0; + MPTCP_SKB_CB(skb)->has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp; + + mptcp_data_lock(sk); + + mptcp_set_owner_r(skb, sk); + __skb_queue_tail(&sk->sk_receive_queue, skb); + + sk->sk_data_ready(sk); + + mptcp_data_unlock(sk); +} + void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, const struct mptcp_options_received *mp_opt) { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a12ee763e52c..cd9ad6e461b1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -191,7 +191,7 @@ static void mptcp_rfree(struct sk_buff *skb) mptcp_rmem_uncharge(sk, len); } -static void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk) +void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk) { skb_orphan(skb); skb->sk = sk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 618ac85abaaf..8b4379a2cd85 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -633,6 +633,7 @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent); struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); +void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port); @@ -842,6 +843,8 @@ bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, const struct mptcp_options_received *mp_opt); +void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow, + struct request_sock *req); static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 21cf26edb79a..fb3361f4b1e5 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -307,7 +307,48 @@ static struct dst_entry *subflow_v4_route_req(const struct sock *sk, return NULL; } +static void subflow_prep_synack(const struct sock *sk, struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type) +{ + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + struct inet_request_sock *ireq = inet_rsk(req); + + /* clear tstamp_ok, as needed depending on cookie */ + if (foc && foc->len > -1) + ireq->tstamp_ok = 0; + + if (synack_type == TCP_SYNACK_FASTOPEN) + mptcp_fastopen_subflow_synack_set_params(subflow, req); +} + +static int subflow_v4_send_synack(const struct sock *sk, struct dst_entry *dst, + struct flowi *fl, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type, + struct sk_buff *syn_skb) +{ + subflow_prep_synack(sk, req, foc, synack_type); + + return tcp_request_sock_ipv4_ops.send_synack(sk, dst, fl, req, foc, + synack_type, syn_skb); +} + #if IS_ENABLED(CONFIG_MPTCP_IPV6) +static int subflow_v6_send_synack(const struct sock *sk, struct dst_entry *dst, + struct flowi *fl, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type, + struct sk_buff *syn_skb) +{ + subflow_prep_synack(sk, req, foc, synack_type); + + return tcp_request_sock_ipv6_ops.send_synack(sk, dst, fl, req, foc, + synack_type, syn_skb); +} + static struct dst_entry *subflow_v6_route_req(const struct sock *sk, struct sk_buff *skb, struct flowi *fl, @@ -1945,6 +1986,7 @@ void __init mptcp_subflow_init(void) subflow_request_sock_ipv4_ops = tcp_request_sock_ipv4_ops; subflow_request_sock_ipv4_ops.route_req = subflow_v4_route_req; + subflow_request_sock_ipv4_ops.send_synack = subflow_v4_send_synack; subflow_specific = ipv4_specific; subflow_specific.conn_request = subflow_v4_conn_request; @@ -1958,6 +2000,7 @@ void __init mptcp_subflow_init(void) #if IS_ENABLED(CONFIG_MPTCP_IPV6) subflow_request_sock_ipv6_ops = tcp_request_sock_ipv6_ops; subflow_request_sock_ipv6_ops.route_req = subflow_v6_route_req; + subflow_request_sock_ipv6_ops.send_synack = subflow_v6_send_synack; subflow_v6_specific = ipv6_specific; subflow_v6_specific.conn_request = subflow_v6_conn_request;