From patchwork Wed Jul 28 09:35:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12405293 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA67272 for ; Wed, 28 Jul 2021 09:35:21 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id n10so1968680plf.4 for ; Wed, 28 Jul 2021 02:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+nucA0AaG/IxWnxJps06L5Bm8x/S0+UE/HTAd/YRgtU=; b=eo9MY5kARt2oWibG14q3vZYU+wfxOdn9B8fhkiS3qY+nMFk8RPLbqgkvwsfkgqnK6i YcMw68i1PO2a0aUTmUo2Si0wNrnkxlMaXdGwb+qnb0L/JHRCwaKV8/9/QLE6r6vT+eDv vhw3J3Mizk9DN7G620z0SBp2NQJsTipvBZ/UsFDsxOaBgDqhBC/TC0PocAfsYHiOPuRa F4mXCRUELSNvvcaiFA8cCkuu4UQ5zt1EiWq5mB+G1A9ZzvwrTO7DRNGjIefGfwOjMUBo f5DAfWPcKA0wfY0NZrsCWMr0h6eFv+KTd2xlZ2Q+kn9SqPiyeXmtKZu5UAQlK5IQER6Q 4ZQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+nucA0AaG/IxWnxJps06L5Bm8x/S0+UE/HTAd/YRgtU=; b=BObiFp/i3PRrEdE829S78BOcYwH1ukmmjFtez7g0HcoPiD4tVAsMasSUCJPibS1bt0 wkfL7nlf8pVRw6kcQZYB7z8wPyoCWsYIUH799xh/RmDgRG/JmXtWYMgozUVAA+bK0XLz KcFjQfwPq5rMN0jQkBjtc1aXWmqjJRb5ixr2M79q0kn5qjNHPBmJbn6sZ+PHllUMocA2 A5Q82a/KXtsChZnzFqf9EyC5uD/H5DS+A5PJ3xn0rZodqT+NnrAinqSmFygLy73jY0Fu G5AMjK8mtawiaPp6oluQwQw4X+zp+mrVooDW2gX1ZFec0fhweRv2/AaHvhNe/dnjx8Yg 0WKw== X-Gm-Message-State: AOAM531rD5KUV9qidoWuXIOV/bGyQh7bty4Lq55rabi9wp+WM0QeZUmh ZKb6Mvo6nHvrQtKYDMsHmry2MlAl0lk= X-Google-Smtp-Source: ABdhPJw1GPAXOnaZdNo60XgEJ0SsB7JCoRiFSrnVeWHpi4cuhswm+4Pt+eZeDh1HE3jwfIGDDG7OiQ== X-Received: by 2002:aa7:8806:0:b029:32a:8632:e35e with SMTP id c6-20020aa788060000b029032a8632e35emr28196374pfo.10.1627464921334; Wed, 28 Jul 2021 02:35:21 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v10sm5312560pjd.29.2021.07.28.02.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 02:35:21 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v6 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Date: Wed, 28 Jul 2021 17:35:08 +0800 Message-Id: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch added the MP_FAIL suboption sending support. Add a new flag named send_mp_fail in struct mptcp_subflow_context. If this flag is set, send out MP_FAIL suboption. Add a new member fail_seq in struct mptcp_out_options to save the data sequence number to put into the MP_FAIL suboption. An MP_FAIL option could be included in a RST or on the subflow-level ACK. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 5 +++- net/mptcp/options.c | 61 +++++++++++++++++++++++++++++++++++++++++--- net/mptcp/protocol.h | 3 +++ 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 3236010afa29..6026bbefbffd 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -74,7 +74,10 @@ struct mptcp_out_options { struct mptcp_addr_info addr; u64 ahmac; }; - struct mptcp_ext ext_copy; + struct { + struct mptcp_ext ext_copy; + u64 fail_seq; + }; struct { u32 nonce; u32 token; diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 753d6ac43bff..2b15063c8009 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -763,7 +763,7 @@ static bool mptcp_established_options_mp_prio(struct sock *sk, return true; } -static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_buff *skb, +static noinline bool mptcp_established_options_rst(struct sock *sk, struct sk_buff *skb, unsigned int *size, unsigned int remaining, struct mptcp_out_options *opts) @@ -771,12 +771,36 @@ static noinline void mptcp_established_options_rst(struct sock *sk, struct sk_bu const struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); if (remaining < TCPOLEN_MPTCP_RST) - return; + return false; *size = TCPOLEN_MPTCP_RST; opts->suboptions |= OPTION_MPTCP_RST; opts->reset_transient = subflow->reset_transient; opts->reset_reason = subflow->reset_reason; + + return true; +} + +static bool mptcp_established_options_mp_fail(struct sock *sk, + unsigned int *size, + unsigned int remaining, + struct mptcp_out_options *opts) +{ + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + + if (!subflow->send_mp_fail) + return false; + + if (remaining < TCPOLEN_MPTCP_FAIL) + return false; + + *size = TCPOLEN_MPTCP_FAIL; + opts->suboptions |= OPTION_MPTCP_FAIL; + opts->fail_seq = subflow->map_seq; + + pr_debug("MP_FAIL fail_seq=%llu", opts->fail_seq); + + return true; } bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, @@ -795,15 +819,30 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, return false; if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { - mptcp_established_options_rst(sk, skb, size, remaining, opts); + if (mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { + *size += opt_size; + remaining -= opt_size; + } + if (mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) { + *size += opt_size; + remaining -= opt_size; + } return true; } snd_data_fin = mptcp_data_fin_enabled(msk); if (mptcp_established_options_mp(sk, skb, snd_data_fin, &opt_size, remaining, opts)) ret = true; - else if (mptcp_established_options_dss(sk, skb, snd_data_fin, &opt_size, remaining, opts)) + else if (mptcp_established_options_dss(sk, skb, snd_data_fin, &opt_size, remaining, opts)) { ret = true; + if (opts->ext_copy.use_ack) { + if (mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { + *size += opt_size; + remaining -= opt_size; + return true; + } + } + } /* we reserved enough space for the above options, and exceeding the * TCP option space would be fatal @@ -1210,6 +1249,20 @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext) void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { + if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) { + const struct sock *ssk = (const struct sock *)tp; + struct mptcp_subflow_context *subflow; + + subflow = mptcp_subflow_ctx(ssk); + subflow->send_mp_fail = 0; + + *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL, + TCPOLEN_MPTCP_FAIL, + 0, 0); + put_unaligned_be64(opts->fail_seq, ptr); + ptr += 2; + } + /* RST is mutually exclusive with everything else */ if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) { *ptr++ = mptcp_option(MPTCPOPT_RST, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e8a36ff52af6..b389fec18c89 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -27,6 +27,7 @@ #define OPTION_MPTCP_PRIO BIT(9) #define OPTION_MPTCP_RST BIT(10) #define OPTION_MPTCP_DSS BIT(11) +#define OPTION_MPTCP_FAIL BIT(12) /* MPTCP option subtypes */ #define MPTCPOPT_MP_CAPABLE 0 @@ -68,6 +69,7 @@ #define TCPOLEN_MPTCP_PRIO_ALIGN 4 #define TCPOLEN_MPTCP_FASTCLOSE 12 #define TCPOLEN_MPTCP_RST 4 +#define TCPOLEN_MPTCP_FAIL 12 #define TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM (TCPOLEN_MPTCP_DSS_CHECKSUM + TCPOLEN_MPTCP_MPC_ACK_DATA) @@ -429,6 +431,7 @@ struct mptcp_subflow_context { mpc_map : 1, backup : 1, send_mp_prio : 1, + send_mp_fail : 1, rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */ From patchwork Wed Jul 28 09:35:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12405295 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C7F072 for ; Wed, 28 Jul 2021 09:35:23 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id mz5-20020a17090b3785b0290176ecf64922so9073803pjb.3 for ; Wed, 28 Jul 2021 02:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YOdjqLBqf8Dzekn/XowyzlY711ZbJxLE7bzcbdPc2jI=; b=JQk1ocbCxaMY497ZkYxKIN3iVhvuEevLxdJ7daJnhWLKccfkVztHE/3ZFpfXLzT9YP +zZeO/Lz51IfAlcNK/9fswQiIZcxnwJR2VfiZl7zH43F7h+VOZA6PkutrOF7xOzbUSKZ 8cIjJTKwf5cUcQXP8okP0sYiM3BDMd4YxUpRmkCIfQs75eJe2Yhe9ChSmkJIZKKFm4Cc 6LZWMydByeBuSLknZbreZPPFG7Uv90iJVAbqBo1iPu/U4KiKA0MTou76KWBMDxsZVoTm oUpw3jdo4g2k35jsnWFOefNd2Pjs3SunttYTgjRtQ+KYGOtKd+XCkNrQE6Axx2zzpATM VALg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YOdjqLBqf8Dzekn/XowyzlY711ZbJxLE7bzcbdPc2jI=; b=DzLwPIrdHh0Jt9ZFMIUj12z9x1zX2xEtVaDDJcyGvLhT7t5zZ5cc/E7bv9nih4rNxj quixbFT1ozuqYUBvz1XFNbqKeBPFfwMjSBX/oKKP0UvfWtUlJa6fYzTFsl8YhwjCWWeV 4gVLGfe6IweQiUwLg6Y6MsMJrboT+oenF4gBBeLprB9tKJlMXBrwXmiAlAKvtZs2RXs6 BWzlq3939P8/WvOWwjNlCTNHRkCUSWiZ1w8f033gecCN/xeEMS1FkxlYtrI/6TF0E1pt HQgCnaxK+8dzYRY0vibwCVHVwL10SJ9tNYhoS2ExejByE6uNiUJoQN/tXOXzZ58jqjj6 obiA== X-Gm-Message-State: AOAM533WGUNthsh0qy7tG5lAvT5YFm6I7QJOIPXvznrigC29iV7m93bw KB5VMIivESBCUuioQI+01ZNM2x4koO0= X-Google-Smtp-Source: ABdhPJzwpAdQdDYGd4AUms9XVFHCySyi/Zl+1GyWUSk8hydhtzvFpiC+c8NFSrTOoNQE1C940gHMZQ== X-Received: by 2002:a05:6a00:218a:b029:3a1:a7b7:bfb with SMTP id h10-20020a056a00218ab02903a1a7b70bfbmr6059715pfi.27.1627464922995; Wed, 28 Jul 2021 02:35:22 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v10sm5312560pjd.29.2021.07.28.02.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 02:35:22 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v6 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Date: Wed, 28 Jul 2021 17:35:09 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> References: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch added handling for receiving MP_FAIL suboption. Add a new members mp_fail and fail_seq in struct mptcp_options_received. When MP_FAIL suboption is received, set mp_fail to 1 and save the sequence number to fail_seq. Then invoke mptcp_pm_mp_fail_received to deal with the MP_FAIL suboption. Signed-off-by: Geliang Tang --- net/mptcp/options.c | 16 ++++++++++++++++ net/mptcp/pm.c | 5 +++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 2b15063c8009..cd9ec4acf127 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -336,6 +336,16 @@ static void mptcp_parse_option(const struct sk_buff *skb, mp_opt->reset_reason = *ptr; break; + case MPTCPOPT_MP_FAIL: + if (opsize != TCPOLEN_MPTCP_FAIL) + break; + + ptr += 2; + mp_opt->mp_fail = 1; + mp_opt->fail_seq = get_unaligned_be64(ptr); + pr_debug("MP_FAIL: data_seq=%llu", mp_opt->fail_seq); + break; + default: break; } @@ -364,6 +374,7 @@ void mptcp_get_options(const struct sock *sk, mp_opt->reset = 0; mp_opt->csum_reqd = READ_ONCE(msk->csum_enabled); mp_opt->deny_join_id0 = 0; + mp_opt->mp_fail = 0; length = (th->doff * 4) - sizeof(struct tcphdr); ptr = (const unsigned char *)(th + 1); @@ -1147,6 +1158,11 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mp_opt.mp_prio = 0; } + if (mp_opt.mp_fail) { + mptcp_pm_mp_fail_received(sk, mp_opt.fail_seq); + mp_opt.mp_fail = 0; + } + if (mp_opt.reset) { subflow->reset_seen = 1; subflow->reset_reason = mp_opt.reset_reason; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index da0c4c925350..6ab386ff3294 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -249,6 +249,11 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup) mptcp_event(MPTCP_EVENT_SUB_PRIORITY, mptcp_sk(subflow->conn), sk, GFP_ATOMIC); } +void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq) +{ + pr_debug("fail_seq=%llu", fail_seq); +} + /* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, struct sk_buff *skb, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b389fec18c89..09d0e9406ea9 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -140,6 +140,7 @@ struct mptcp_options_received { add_addr : 1, rm_addr : 1, mp_prio : 1, + mp_fail : 1, echo : 1, csum_reqd : 1, backup : 1, @@ -161,6 +162,7 @@ struct mptcp_options_received { u64 ahmac; u8 reset_reason:4; u8 reset_transient:1; + u64 fail_seq; }; static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) @@ -727,6 +729,7 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup); int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, struct mptcp_addr_info *addr, u8 bkup); +void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq); void mptcp_pm_free_anno_list(struct mptcp_sock *msk); bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk); struct mptcp_pm_add_entry * From patchwork Wed Jul 28 09:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12405297 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4E8672 for ; Wed, 28 Jul 2021 09:35:25 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id b6so4219687pji.4 for ; Wed, 28 Jul 2021 02:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zpvLXzUKAqdksn9FTjRMQk/to7BWTzvq5aueKkIBJxE=; b=YoQKG4Yk+1YqzJLCp5QNgPJzXKzVO5VMs2UXYGfRv/4dvhOrFe97A2eOYhC9m/Y66C STOW5f/DnEcITU/Uux3cWJdEzPE9uxKhkIImLygOgqNKTNpahvUJyE0RZluNa0tarRCW JIak+EV0BgrVsQmPxGLJdFGop8eWHkudH/M7e4OWbt//y85zNeZx2vaNkkV+HG+Jfj0K 0tfju9w40qmg5A51WDBfyiwho8jIGBQJ4HXXz/16cDw3MkdfydRfapfI+FsCXjNuIIxm VXrq+To/WTqgmY5jwfMe4eb8jl9t4KRGHnnjTdAxSZ+sycGzMmKKh8PPWj6pvGeUgGuy d+2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zpvLXzUKAqdksn9FTjRMQk/to7BWTzvq5aueKkIBJxE=; b=j+9UeXyD9BuELTj8WgSSU6niA06cyd8qY22HbIJZeLBANgi8SCobxqtGZ5j8NTPm/R m9wjvPQ/3wBykQfvu2uDOrCzGFjUkbCV1Av2FWZrtrH3gQz7Wa5bv8G9k6cYpM6Jodon NhdUZRB6L24+q4/hO4H7fdMNg8sry5zD9AVHUXZkFKD0ipfQRaSOrbfseRFGY2OVvCRf IsvRl+hogTFs1UP8Y+gxPpz2EpwmyrIFPOr1cebda1i/6wFY9oP7EvEoex1pNSdE7drd fApSjCw2+WkZBdUGdTPBoGASLPg+EpkvYGi9ZgB8WjacdpErVicll6EksBCeKIic3ry3 /XNw== X-Gm-Message-State: AOAM531sUrZvbHtPnpyqloPPFe4hobwp+nUQakQ8WeeSwzuUxiBu7i6q wcnU1M0RZTU5QCKwCS4sWOJdFxp9JSs= X-Google-Smtp-Source: ABdhPJw9KDexDxp9+4o284Qs4Y5brZAVdullNGOu0leUDGBwqXWHD7gOAOoghObzGnzt+e1mYx/hfw== X-Received: by 2002:a62:79c2:0:b029:3a3:8e69:ca97 with SMTP id u185-20020a6279c20000b02903a38e69ca97mr4325194pfc.55.1627464925432; Wed, 28 Jul 2021 02:35:25 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v10sm5312560pjd.29.2021.07.28.02.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 02:35:25 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v6 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fails Date: Wed, 28 Jul 2021 17:35:10 +0800 Message-Id: <19469d95c33169d6e4dd553394ab4466756ff001.1627464017.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang When a bad checksum is detected, set the send_mp_fail flag to send out the MP_FAIL option. Add a new function mptcp_has_another_subflow() to check whether there's only a single subflow. When multiple subflows are in use, close the affected subflow with a RST that includes an MP_FAIL option and discard the data with the bad checksum. Set the sk_state of the subsocket to TCP_CLOSE, then the flag MPTCP_WORK_CLOSE_SUBFLOW will be set in subflow_sched_work_if_closed, and the subflow will be closed. When a single subfow is in use, send back an MP_FAIL option on the subflow-level ACK. And the receiver of this MP_FAIL respond with an MP_FAIL in the reverse direction. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 14 ++++++++++++++ net/mptcp/protocol.h | 14 ++++++++++++++ net/mptcp/subflow.c | 17 +++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 6ab386ff3294..c2df5cc28ba1 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -251,7 +251,21 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup) void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq) { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + pr_debug("fail_seq=%llu", fail_seq); + + if (!mptcp_has_another_subflow(sk)) { + if (!subflow->mp_fail_expect_echo) { + subflow->send_mp_fail = 1; + } else { + subflow->mp_fail_expect_echo = 0; + /* TODO the single-subflow case is temporarily + * handled by reset. + */ + mptcp_subflow_reset(sk); + } + } } /* path manager helpers */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 09d0e9406ea9..c46011318f65 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -434,6 +434,7 @@ struct mptcp_subflow_context { backup : 1, send_mp_prio : 1, send_mp_fail : 1, + mp_fail_expect_echo : 1, rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */ @@ -615,6 +616,19 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk, inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops; } +static inline bool mptcp_has_another_subflow(struct sock *ssk) +{ + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk), *tmp; + struct mptcp_sock *msk = mptcp_sk(subflow->conn); + + mptcp_for_each_subflow(msk, tmp) { + if (tmp != subflow) + return true; + } + + return false; +} + void __init mptcp_proto_init(void); #if IS_ENABLED(CONFIG_MPTCP_IPV6) int __init mptcp_proto_v6_init(void); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 1151926d335b..a69839520472 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -910,6 +910,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff * csum = csum_partial(&header, sizeof(header), subflow->map_data_csum); if (unlikely(csum_fold(csum))) { MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR); + subflow->send_mp_fail = 1; return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; } @@ -1157,6 +1158,22 @@ static bool subflow_check_data_avail(struct sock *ssk) fallback: /* RFC 8684 section 3.7. */ + if (subflow->send_mp_fail) { + if (mptcp_has_another_subflow(ssk)) { + ssk->sk_err = EBADMSG; + tcp_set_state(ssk, TCP_CLOSE); + subflow->reset_transient = 0; + subflow->reset_reason = MPTCP_RST_EMIDDLEBOX; + tcp_send_active_reset(ssk, GFP_ATOMIC); + while ((skb = skb_peek(&ssk->sk_receive_queue))) + sk_eat_skb(ssk, skb); + } else { + subflow->mp_fail_expect_echo = 1; + } + WRITE_ONCE(subflow->data_avail, 0); + return true; + } + if (subflow->mp_join || subflow->fully_established) { /* fatal protocol error, close the socket. * subflow_error_report() will introduce the appropriate barriers From patchwork Wed Jul 28 09:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12405299 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EADDB72 for ; Wed, 28 Jul 2021 09:35:27 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id e21so1964479pla.5 for ; Wed, 28 Jul 2021 02:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2nVFnjdFvmVEM5H0eEhKIqD0Xax0jELBSHPIrjXwpTI=; b=TTRWOUnnPzPEVqxkviGSaf5XeT8L0dotqaKxzSc6pl5mlV8xIFB3T/3e+2jjXoeEsl HMW6yuFvukcFqJHXcJyQmfjKfmTV1cGtbffpSaKMD8jau86/7BvnE2Gsi9OEJcDUnZiF FmWtmIneJGJ9dFTeHyD+W+rRftPsrkeK0McjpYjPQGMXOCXD5iCOyjfY8zbGAzjoXvJP +uSbQ8QBzGBtF1CpmbSmhxTVBprkS50MueYa8pAlf86M+oI9qBv2CXwSanPpbXhuIEcP VUxKPzn8FypIGnmpwPm0fB88BKh4KgibUxXyVBrDKrYC4M5FdZnm+fXL5+kWWmrmyxW4 JZFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2nVFnjdFvmVEM5H0eEhKIqD0Xax0jELBSHPIrjXwpTI=; b=D4hYrUqA4G7prMSUmMmRbd8+ht480K9jrICyL+gxeUl3Bpq1K98XT5fDDTggAM17mz tixp9/U6k3HquCGrfoaeNiph0wVhT3aTfZEbxBdZmEMeAij699SmNu4+YmS5zQ7/lb5a +1dpdP1kdTzXGb7TLn4kWhwuFJY8J4AtkVgUj5rP1jCow3oqGSCwApuJ6WIjIVt82aGv ie0YVCiC4AkhAhHkFLHLCAkn+XuwK930kudvKEkp6+aK/12fEZlWfgsLVwpJjQ0hTVU3 PoDvxP6yGB1Fv7kEYRnAjx82k0nKK8EZqt7v9PeT36Y2lDZBXZfd2pXeWP3+r7vXI7vx 2bbQ== X-Gm-Message-State: AOAM530xiY+ATGy2EgpIgFLHCBaUyE/ip/vnPKDmUxyjpS7YjJP5WjsO wtngOdJJSSGCgiehQ9jm2YbaDlcPSi0= X-Google-Smtp-Source: ABdhPJxl7Tj0K5ItCJ5LfFvgsBkfNhF6m3XMp+s3MsBGXe7HqRxY9sr1ve2iT+RnPaINv40LNLw1Ew== X-Received: by 2002:a17:90b:38ca:: with SMTP id nn10mr7140307pjb.3.1627464927064; Wed, 28 Jul 2021 02:35:27 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v10sm5312560pjd.29.2021.07.28.02.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 02:35:26 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v6 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Date: Wed, 28 Jul 2021 17:35:11 +0800 Message-Id: <0e7f6c209ba05ef9e5b7300f490f8b6db4df3334.1627464017.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <19469d95c33169d6e4dd553394ab4466756ff001.1627464017.git.geliangtang@xiaomi.com> References: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> <19469d95c33169d6e4dd553394ab4466756ff001.1627464017.git.geliangtang@xiaomi.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch added the mibs for MP_FAIL: MPTCP_MIB_MPFAILTX and MPTCP_MIB_MPFAILRX. Signed-off-by: Geliang Tang --- net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/options.c | 1 + net/mptcp/pm.c | 1 + net/mptcp/subflow.c | 1 + 5 files changed, 7 insertions(+) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index 3a7c4e7b2d79..b21ff9be04c6 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -44,6 +44,8 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW), SNMP_MIB_ITEM("MPPrioTx", MPTCP_MIB_MPPRIOTX), SNMP_MIB_ITEM("MPPrioRx", MPTCP_MIB_MPPRIORX), + SNMP_MIB_ITEM("MPFailTx", MPTCP_MIB_MPFAILTX), + SNMP_MIB_ITEM("MPFailRx", MPTCP_MIB_MPFAILRX), SNMP_MIB_ITEM("RcvPruned", MPTCP_MIB_RCVPRUNED), SNMP_MIB_ITEM("SubflowStale", MPTCP_MIB_SUBFLOWSTALE), SNMP_MIB_ITEM("SubflowRecover", MPTCP_MIB_SUBFLOWRECOVER), diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 8ec16c991aac..ecd3d8b117e0 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -37,6 +37,8 @@ enum linux_mptcp_mib_field { MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */ MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */ MPTCP_MIB_MPPRIORX, /* Received a MP_PRIO */ + MPTCP_MIB_MPFAILTX, /* Transmit a MP_FAIL */ + MPTCP_MIB_MPFAILRX, /* Received a MP_FAIL */ MPTCP_MIB_RCVPRUNED, /* Incoming packet dropped due to memory limit */ MPTCP_MIB_SUBFLOWSTALE, /* Subflows entered 'stale' status */ MPTCP_MIB_SUBFLOWRECOVER, /* Subflows returned to active status after being stale */ diff --git a/net/mptcp/options.c b/net/mptcp/options.c index cd9ec4acf127..8b899c308b83 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1160,6 +1160,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) if (mp_opt.mp_fail) { mptcp_pm_mp_fail_received(sk, mp_opt.fail_seq); + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFAILRX); mp_opt.mp_fail = 0; } diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index c2df5cc28ba1..43530d3a78e9 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -258,6 +258,7 @@ void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq) if (!mptcp_has_another_subflow(sk)) { if (!subflow->mp_fail_expect_echo) { subflow->send_mp_fail = 1; + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFAILTX); } else { subflow->mp_fail_expect_echo = 0; /* TODO the single-subflow case is temporarily diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a69839520472..c25b1d961206 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -911,6 +911,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff * if (unlikely(csum_fold(csum))) { MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR); subflow->send_mp_fail = 1; + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPFAILTX); return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; } From patchwork Wed Jul 28 09:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12405301 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41CF272 for ; Wed, 28 Jul 2021 09:35:29 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id d1so1985913pll.1 for ; Wed, 28 Jul 2021 02:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Acflo4de9oIkKoAYozy+e+mNa2LCU3k7qVc76MLFU5A=; b=RE3nYr0Q9GtxbSGYMjfD03KhuWWuQp58Hwo5cdk9bY4xW0tBuDsBBc4/tv0OsVrR3F wN0zdx7PLcIuz9uCVJdKn5Fz9MuZ7J/YMf36XSmCM5CeiN9CB1HdFbvOwP73kZUEtx1H w105IniVGkAZYRwSuIWW2TXdVcAYsLW48ynZIDC5GoLKFsK7ETf9mjoETZSRHflXYW4Q B15piQyOdgANyDb8zdg2m7t/dVvS+yZ0zqn+OzeJJwSM9HCpeba85F23+TQ85K5omE+I pBWcZpLlvOLYnRJXXl8+BdQP9OBlh5T5dJYWYgt3/kvh6CrJJSt+ObjEc8LT44d4yTCD r3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Acflo4de9oIkKoAYozy+e+mNa2LCU3k7qVc76MLFU5A=; b=GCWxUwNsgbWR0eUBJwMR3gHDfr2GKSJ49timYjg7ysiIvHftKKDNEJJnEVmuEHpCT8 YXGlwUJxb8bnKHgKIu5eDTU5yFzcmYJBGVbf81PRfNYqJOjoSk89s8ty4sul3zpDqPfv v5T0pE8ec2FN1xbkPthiKySwJNFuN0zhE0+FcOq7L5qXJnzw4qp+XB+UENEcsIZkSURS Q9V/q5cE7BnGcJdlTz2wRzpk0aYhWkMlYl/mg7K4LIBa8ypPr9xj5P2uA6pHcmN4td2a EkruVwwPicsnzp5Dg/ps9smOxKo99uloLtMaHaGAUC9Ow9bbq8j7VbvlA4nqhD54Ohgh 75hw== X-Gm-Message-State: AOAM531732uGd2N67plVowkH/WAK5ItkVMqtC3/Bwl6g8hhkaqIpWb4B oZCL+KyMikqcoMj3bhX9Saa82mKlf6s= X-Google-Smtp-Source: ABdhPJyvjy+ddv02twGhCERhW8BPS0qKBDrkskWHac06lYIqQWp8pqPpcHlxU+Tq8oKm1KpYNwJczQ== X-Received: by 2002:a17:90a:5a4c:: with SMTP id m12mr8958434pji.15.1627464928804; Wed, 28 Jul 2021 02:35:28 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v10sm5312560pjd.29.2021.07.28.02.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 02:35:28 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v6 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check Date: Wed, 28 Jul 2021 17:35:12 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: <0e7f6c209ba05ef9e5b7300f490f8b6db4df3334.1627464017.git.geliangtang@xiaomi.com> References: <277ac1e6d1fde4c180eba3f1bb1846ea58679915.1627464017.git.geliangtang@xiaomi.com> <19469d95c33169d6e4dd553394ab4466756ff001.1627464017.git.geliangtang@xiaomi.com> <0e7f6c209ba05ef9e5b7300f490f8b6db4df3334.1627464017.git.geliangtang@xiaomi.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch added a function chk_fail_nr to check the mibs for MP_FAIL. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 937e861e9490..551fcce7c2f2 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -566,6 +566,43 @@ chk_csum_nr() fi } +chk_fail_nr() +{ + local mp_fail_nr_tx=$1 + local mp_fail_nr_rx=$2 + local count + local dump_stats + + printf "%-39s %s" " " "ftx" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_fail_nr_tx" ]; then + echo "[fail] got $count MP_FAIL[s] TX expected $mp_fail_nr_tx" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - frx " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_fail_nr_rx" ]; then + echo "[fail] got $count MP_FAIL[s] RX expected $mp_fail_nr_rx" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi +} + chk_join_nr() { local msg="$1" @@ -615,6 +652,7 @@ chk_join_nr() fi if [ $checksum -eq 1 ]; then chk_csum_nr + chk_fail_nr 0 0 fi }