From patchwork Mon Jul 26 06:45: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: 12398567 X-Patchwork-Delegate: mat@martineau.name Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 0915070 for ; Mon, 26 Jul 2021 06:45:23 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so12870521pjh.3 for ; Sun, 25 Jul 2021 23:45: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=PtUAG3IAgWzSngLGBF4+uY7YKRDIkxHqIh1hfjsiBhg=; b=YWr0084xRBL8f4PRB8zPNwjg1YAzyIgLYzVb+3kXJ5nvCp0YnZOtTuy3kZ7wKng89I c/nZdyaE46cl4v7G20QyvPLD2BHjDpfEweXwm4K59YZ0u3AIJg1RAudVDBzEfxNSgAb6 17b/N2fsiMak/oZsZcyu1OlUS0Zr5DePLJiCY7sLqeY1wzZFZYtqj7qHQqGhA4sIGSzy p7d7v1S0tUP9LV1St1m8doh5dIsH4JUdRk5N69LgkUKdoW1xfCb2/RATqGmA5nUdNq8Z vg0tRrN0jK/FMn9ktwmcCYvPCfLurqTMVQV82vklp7K2JnjNDjQLaRr5vProufOJbTvV KvLA== 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=PtUAG3IAgWzSngLGBF4+uY7YKRDIkxHqIh1hfjsiBhg=; b=L3UiKIuxSbpp9eciU4jHmRUIpGvIQUlaqUjAzxoZQmL+ylUaQSjsR+6DjNpemLoGPN 5RlD7BvvdSYjiE9QvASfaTOa6J9tBA+GMSlNIaLGVtkUsa0UWS17F61aVFi/LU9KLGxt wD0iVXplvHJkjlP7BxvndyO8ep+z7YuRzJU1KjzfQamKsNlTB1Ydb+T2tJCuoDnZwkL1 GtiLj5wufk7/QRS/Dtj7GYxxzd39ecNjR9b+ZjkPjX4diqb1qDraj9R7Bwqek+lKers0 tsDK8e631T0kkreU8Mw2WdNqGjh9QoQ0j+L/RofB14j8iAHAXBt4t3kcAM+yGJMdKR38 jmiw== X-Gm-Message-State: AOAM532bliwgT+MyvOdXxKjY9rhjY26vY3kaonCAxn6RXuTdwbjL7gyZ OvBQnIBxAm7VoIDslPPqzktCPHn4gmxrRQ== X-Google-Smtp-Source: ABdhPJykWF+5Tqac+F2hHGPQoMh9HBtrLQJwqmNtJgII9kHqYy0BIyQAQSLznXUJ/QyGMKIDofEWug== X-Received: by 2002:a17:903:2445:b029:12b:9d0e:6b97 with SMTP id l5-20020a1709032445b029012b9d0e6b97mr13414974pls.84.1627281923447; Sun, 25 Jul 2021 23:45:23 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id k11sm10634697pgc.30.2021.07.25.23.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 23:45:23 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v5 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Date: Mon, 26 Jul 2021 14:45:11 +0800 Message-Id: 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 d0b9e4a7121f..6c8c8592153d 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -60,7 +60,10 @@ struct mptcp_out_options { u16 suboptions; u64 sndr_key; u64 rcvr_key; - u64 ahmac; + union { + u64 ahmac; + u64 fail_seq; + }; struct mptcp_addr_info local; struct mptcp_addr_info remote; struct mptcp_rm_list rm_list; diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 6803de5d4209..a7365379096d 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -754,7 +754,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) @@ -762,12 +762,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, @@ -786,15 +810,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 @@ -1343,6 +1382,20 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, opts->backup, TCPOPT_NOP); } + if (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; + } + if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN, TCPOLEN_MPTCP_MPJ_SYN, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 34ad1c4bc29f..ea4ab9b9d6db 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -26,6 +26,7 @@ #define OPTION_MPTCP_FASTCLOSE BIT(8) #define OPTION_MPTCP_PRIO BIT(9) #define OPTION_MPTCP_RST BIT(10) +#define OPTION_MPTCP_FAIL BIT(11) /* MPTCP option subtypes */ #define MPTCPOPT_MP_CAPABLE 0 @@ -67,6 +68,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) @@ -428,6 +430,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 Mon Jul 26 06:45: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: 12398569 X-Patchwork-Delegate: mat@martineau.name 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 E3D6070 for ; Mon, 26 Jul 2021 06:45:25 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id e21so5924227pla.5 for ; Sun, 25 Jul 2021 23:45: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=n0yRg0PxOP5a6TIi96nrHyjmG54dBWIEziwzaYMx2e0=; b=vg9uq6JJHU2iULDt2A4wMsAOmk0YOVw/aW2/EgZ3aKyIX6OvGHEscm8X/PdG80Tdh8 e1n4w+HLJs7D9vtNcOnIV+2Siec4H5VB5rfzg0lfTxYbN7q21B075V7xusx2D2VDicPZ RPeVgB7B0ekEbhbK/ELFveq1mS5z9fKxzBTJsc037R/LChCWnuizxIETzwZSS8JsYOdu WGKBKkl6i33rFRc/WhWNtydPJ5dfQ/dC1XZUc6l9ITHgiO1KWzcnirJUEMONL9lRPREn 7atTPnv/A+Y47BNTM7FTantBjYqgZ8x1S4YPfVNnhF1iixdROt1KWUxdn+GOMeRCMQf5 YRYQ== 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=n0yRg0PxOP5a6TIi96nrHyjmG54dBWIEziwzaYMx2e0=; b=bGZd4ybNaew37x51dybmQ4sv7KHrM505Mg4zBXdqgUDJoj2Yt2WI5+96sEbN+CKFuS w1iSJfYlSP0FYWF17fY8ihxHq0/BrIf1g/ooFAEwU69ZNv9LxDEN5g1M06L+xro57hEE sTOaKiVyKLUVi6IjgvFTlf1+Onwc3vA3hB42tRN+o2GwXhh/NliXqZ5yf9A2+FsvGqQ2 gD8nILJ2GHMebo9lq4N52GxpAo7iARwHlbxrnNU5WNinN/uPDhjXGmNlCn/ZNN+48A4v V8THnKg3uQNaeNquD2lJM4PLHyeUyiYyI1u1XbChK/5DrfGU/QGHJYMMHoRtfzSrHWpY JnxQ== X-Gm-Message-State: AOAM530X7id1yERl7czTD96rWtpt28y90lpellEJpKitQvOSE9ddQWQo 24qWz77M3PPbW3VuFDIUZou54oNHgYKRzg== X-Google-Smtp-Source: ABdhPJwMKpZxDIV/oysXVodOebwOLBkz/Fdk2FFBaQgNXh+yIexrZoy32iceN5UegDAp8C1t5CKUgA== X-Received: by 2002:aa7:947d:0:b029:32c:c2e7:5f38 with SMTP id t29-20020aa7947d0000b029032cc2e75f38mr16459909pfq.39.1627281925460; Sun, 25 Jul 2021 23:45:25 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id k11sm10634697pgc.30.2021.07.25.23.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 23:45:25 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v5 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Date: Mon, 26 Jul 2021 14:45:12 +0800 Message-Id: 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 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 a7365379096d..62085834782d 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); @@ -1138,6 +1149,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 692614c1f552..f37a014b4875 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 ea4ab9b9d6db..19533e5778a6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -139,6 +139,7 @@ struct mptcp_options_received { add_addr : 1, rm_addr : 1, mp_prio : 1, + mp_fail : 1, echo : 1, csum_reqd : 1, backup : 1, @@ -160,6 +161,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) @@ -726,6 +728,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 Mon Jul 26 06:45:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12398571 X-Patchwork-Delegate: mat@martineau.name Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 B45BE70 for ; Mon, 26 Jul 2021 06:45:27 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id d17so10374545plh.10 for ; Sun, 25 Jul 2021 23:45: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=WwD12pMoRNH4sYL2gKFke2Mm8ZkHcNXA8ANa39JdyLY=; b=YReVrg0hOfA5DiMdc/pQjYtBtHXDIEL3EvezRj6d+BJbtwfKc8/azbahoQlztjhSgD DZ7IfUXlUx4GjQn1M+UZa9LIp428k+3lH5O5Y6rqQlarTDU7rYPg6IByO7msgyG0QYT2 vlu03PAfC8zBpwhTPG40ezOyqT1p1fibe0SopsXhmluq/ndnSzHu5g6hGlqs8A46t8rZ QisW5zP2mJ8N/z1drB+uGBVuB43+qZpMm9/CFZYF6IPlppG5JKl/rN+YCMKpoyb7qBrF X+JkF2TwF6wDTnayTvzMRqm6XfzSQ9KAMulSmDICxGHe3+oPF4jcFCjvNTsclyRVLBfB m4tw== 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=WwD12pMoRNH4sYL2gKFke2Mm8ZkHcNXA8ANa39JdyLY=; b=GbcWJgUsuUUCfZXRxl5MmjsnSfx+ezdCGuM/8P3oHzITYcz/SrduWchAJ5LsSWuWL8 Lqvbn7E5h9iH/ea9/gdofYOPbymAN0PrK2ZsRTEljAentwGuhF3yVY/btW/JizEN8gDH En9JeH1TzgwilQAuBq3q/8FEohhaNxek24TyZ51GSfstlwCxVgMlzrDi6qsZyb79gWWC nyuFHf0r1JbyRGGtkiE8ttPwh3tGNhNeJdxvHoXMRRpr842Nhz/p0oMRnCAzcpVz4QL2 Rync8+94SJQ8KT+h1PmF5xKRzwUDqpfihvAAa7fLPoGtF8grwkyud9oIqFeHNCYncEKV rAVw== X-Gm-Message-State: AOAM532vVGtZbhFocd7XOXGA9mNVaSy28IAerl7BrXflByrsUYHz+kln Lp+cyiFniiRcCL1nLyBVQyT0hYMI03DtbQ== X-Google-Smtp-Source: ABdhPJy/aAZFPS0v6OGLZbOhrpIKkFYHMutYWplhnI43kxIIFP/yj+iwK6Ath2fcv7Ws2l93akPvig== X-Received: by 2002:a17:902:a513:b029:11a:9be6:f1b9 with SMTP id s19-20020a170902a513b029011a9be6f1b9mr13026459plq.55.1627281927214; Sun, 25 Jul 2021 23:45:27 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id k11sm10634697pgc.30.2021.07.25.23.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 23:45:27 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v5 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fails Date: Mon, 26 Jul 2021 14:45:13 +0800 Message-Id: <8bfbc479bd4513a51a96542b5174b6f75d33c656.1627281326.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 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 f37a014b4875..4a5cf1261ee0 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 19533e5778a6..1622d6434785 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -433,6 +433,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 */ @@ -614,6 +615,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 Mon Jul 26 06:45:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12398573 X-Patchwork-Delegate: mat@martineau.name Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 9941E70 for ; Mon, 26 Jul 2021 06:45:29 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id d1so3149254pll.1 for ; Sun, 25 Jul 2021 23:45: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=SNYxRzf8dxG7N1Zd4GP+t8eu9yILbz6jTE6Mg4KvkR0=; b=iBvwmmrIg12beLYssq+ATyIzZCU3y4FW9615v6OLWZOdRPbhqp/V0+pM9k0Cr3U1eW gaVmH48mJcxtUTX+A06NRHggC6ASd9HVuOTJ8w5DBDiGJ2So3+Klpwv4nhshvEx4Uolp XGnXsLHoaYTkJypOJdGNZxtQWC9FBtVTs1ChcQAlaUFHc61pnB4OFews/D5tLKG0DHUc DvXvvHVR9AgF7v6DpCLFTw5Ez96ak9iVDbNsImVsZvCEc9L+DnEHk3YbyrguNBmlvTkc KA96JXHgWQian0y8BkdaDfGMr2uwVOGifj1uQAJ0fndqKQmG6QjRNwtl+Lhtk/j7hSbp yw9Q== 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=SNYxRzf8dxG7N1Zd4GP+t8eu9yILbz6jTE6Mg4KvkR0=; b=aZmthkeYFGDxyNdkvthxSWkdu9bRGpAlJN1svJYZStu0pZyOEeQ5TRYS8cOw0VuOif AbQIU0NPOHYLCxIl8q67prFLwb+W5ZVUAqZndeae0sAfdtC5acXnPRLde/es5FwasZbd RhUumT3jtDRtWHmLp9w9d8FI9Re9hN18RzR+v92BRXen8og5DDP0nFAh988Yr42VkJ2N JM5JnFe8Sb6zcCiFhMKpJGiB2zCsoPT4KBTzSQ/kPMftAskEzHzGAMi8Pwk59GlyC8i6 E4LE+Vry3SQy/yXUkYLm4iM9VsqMAX3pcZFMufzeoMNnBt8dQhzKA0DUyjPpI+xGlI05 aNZA== X-Gm-Message-State: AOAM530fV0fnnO7xR3Q0ZTiergkiY1+hjcoIRCxfvPG/LrDEQaAUZIIS TUBNGkVutyx8wMk91EGKYCDheoPoHsVV3w== X-Google-Smtp-Source: ABdhPJyRm2O1BTsT6XGKX+5Bc4sU3uRhm8gUVpDgpz+eERRdQ0MTQ8R+Pdzz+CicITfadurTrfXurg== X-Received: by 2002:a17:90a:86:: with SMTP id a6mr24497598pja.133.1627281929152; Sun, 25 Jul 2021 23:45:29 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id k11sm10634697pgc.30.2021.07.25.23.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 23:45:28 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v5 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Date: Mon, 26 Jul 2021 14:45:14 +0800 Message-Id: <35c5e28e2846f7e2efc7c672d20dcafa3e70828e.1627281326.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <8bfbc479bd4513a51a96542b5174b6f75d33c656.1627281326.git.geliangtang@xiaomi.com> References: <8bfbc479bd4513a51a96542b5174b6f75d33c656.1627281326.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 62085834782d..c915cc144d75 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1151,6 +1151,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 4a5cf1261ee0..3509345774a5 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 Mon Jul 26 06:45:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 12398575 X-Patchwork-Delegate: mat@martineau.name Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 7657E70 for ; Mon, 26 Jul 2021 06:45:31 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id n10so2749499plc.2 for ; Sun, 25 Jul 2021 23:45:31 -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=gIO2f2fSTrdkZLZ4JIPdg06ZuuOY411jBgiABxFYkOEpf2r2rIJP8GGqK9XqgxAIEs /0T9kwtDpWLGQoXi8jegpUmiEhEHOhLBpJe44HmryoB02dHx5AdRmLAnWIdHinzDSafj 7Wtv5Kg1MoswCKdzfzJzGkB4Rhbb6kEdoIzgHs/airLjLzCGMeyuc/gNA77CPQx50OJ4 ye0/iYp9SGw+4H9t7tNTJkUbiW6chSfg93diIRkzjGp+zCWi/fbZ9nWZQcC9olcwrq0X dwJLaPttR84+hKaUY0jetMocbtXgsr7tq4ftUwPS5IU660EOCiqIDq+xeF+oxVnzs1BF 7yjw== 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=d7147sPttB0vIWVLV/i7OBvYBVLfXv7G/0+4iQeOyKQ/IJGa0s7Foi6iu5NbkQlbo2 BGviasAmdrjmSU3Apx3/CiZmKcxgUqS1FgV3hVyklF2IQo/M32i1TbOx5MGeE53renUO aLZT8dfc2v3zbYMbFTIWxEUtvl9hNUexOPCyVhWMT78Xi5iD5oTsbUPHkedXReigBXTY rziMQT2luxUA/buP9X205EEAB/eylc5Knl8tKqX+LVd270ellyhxGUMbT5rh85KQ+Jvb E6MhiHFHpnvGCP5dfGReJusWb7NbfpL0rY9ToOmYrnOBTGOTS0erLKIiMu62fKm6InqZ Y4xg== X-Gm-Message-State: AOAM530U9iIgflvcaZFX268DkrE24yEt8QBVYsWrNnISNOAV6R7e8KEA 936n46oYpVnijbhBz6uimEq9lubAVnPjWw== X-Google-Smtp-Source: ABdhPJyb2Dbi+FguLfWcwBBvZDUNnnxqxL5qTLHt/JZF+Hk4RQXw/NhbcGV6Z938W7LRdrezbgilBw== X-Received: by 2002:a62:8f0b:0:b029:356:ba53:a041 with SMTP id n11-20020a628f0b0000b0290356ba53a041mr16897216pfd.10.1627281930987; Sun, 25 Jul 2021 23:45:30 -0700 (PDT) Received: from MiBook.. ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id k11sm10634697pgc.30.2021.07.25.23.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 23:45:30 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v5 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check Date: Mon, 26 Jul 2021 14:45:15 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: <35c5e28e2846f7e2efc7c672d20dcafa3e70828e.1627281326.git.geliangtang@xiaomi.com> References: <8bfbc479bd4513a51a96542b5174b6f75d33c656.1627281326.git.geliangtang@xiaomi.com> <35c5e28e2846f7e2efc7c672d20dcafa3e70828e.1627281326.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 }