From patchwork Thu Jul 29 08:40: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: 12408113 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 01A2C70 for ; Thu, 29 Jul 2021 08:40:20 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id j18-20020a17090aeb12b029017737e6c349so5195508pjz.0 for ; Thu, 29 Jul 2021 01:40:20 -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=Ae+Quuo3lACamn6Amu3Z9WGlEG/gt5BPFAu4zZZKGsM=; b=aVVxB4K9aqaKjMRd/lIWkTxGNeDdcpJA8erIpt/l2tcUjOgLoNKSTD6WfJ5HXejUG6 WuSAJyGLlfTKAqmiCnRUQtqhdBbcrTqU4eF1pxOe1g9zWYEcupd8m0oklvXhoPgswEfz bwnzSIyPDzkH/FnKBXq+z5A5tTVN3QwtT68SNHJ2YthUnUfkuHkyh1SCXSSCpR+yQFwu JalD8sBRPXt5FW8rI1OIQGZwf18zAFMMKgGG7MBI9I+FkVtfsCjUSm8Lzk1xKN7GzfTa veZcG8ML1ALIa/OrOI/M+iA9cdGWfg1YhQQj8YQ9eFnkzrm1kuh/YI+JVfYsID9hGnFj vapA== 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=Ae+Quuo3lACamn6Amu3Z9WGlEG/gt5BPFAu4zZZKGsM=; b=kF5lK1/0Yq3akPNFBbMN3E8GVhofvdvm1ablErrkNfVGijKGvbfSOMOgZFZf4JS1js EPr0mmUQW15ykq6jKxTn9mpJ+vSUaC0XqSS/9tQxx2JeD94Ad/KnqPFLqBJ5PM/sN7A0 VP52brFG4kMqkz7IQiMnDIqzNtKJhR0yq/RxOSS9DcmfpwxrS1tsyauitCS0YGocnRLl NPcU8QlO3uXZ291oPMZaHZDAFBRBMVZU17hR/FvwFs850E2mEkRe88RKCvk7xX39uTOj 4LMgRDGaYjRhOyemh/1ZwkGb/khF1PR910YE8l9tsSSmN7goljmq3tUv1H+NtFfLgkAs ZV3g== X-Gm-Message-State: AOAM532Tltn5PooNe0Lr8Kmzo+4cHpnlvEqUAoklgW8ZMtz6monn/m2r iqxLEzEumsqFOeNZfxT7igz5shRjZQI= X-Google-Smtp-Source: ABdhPJyWKxAn9Qk/aMPd+K/hDG80wo24i1yuwr482c+aT0TVMxFdKlvoCgnAJESTef7ePgH5Qd/gEQ== X-Received: by 2002:a62:ab0a:0:b029:33b:6d08:2a45 with SMTP id p10-20020a62ab0a0000b029033b6d082a45mr3818776pff.38.1627548020460; Thu, 29 Jul 2021 01:40:20 -0700 (PDT) Received: from MiBook.. ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id f5sm2401539pjo.23.2021.07.29.01.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:40:20 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang , Paolo Abeni Subject: [MPTCP][PATCH v7 mptcp-next 1/5] mptcp: MP_FAIL suboption sending Date: Thu, 29 Jul 2021 16:40:09 +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. Suggested-by: Paolo Abeni Signed-off-by: Geliang Tang --- include/net/mptcp.h | 5 +++- net/mptcp/options.c | 59 +++++++++++++++++++++++++++++++++++++++++--- net/mptcp/protocol.h | 3 +++ 3 files changed, 62 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..6db24cf72ac0 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 (likely(!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,28 @@ 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 (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 +1247,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 Thu Jul 29 08:40: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: 12408115 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 B25C270 for ; Thu, 29 Jul 2021 08:40:22 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id ds11-20020a17090b08cbb0290172f971883bso14523454pjb.1 for ; Thu, 29 Jul 2021 01:40:22 -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=4q7I7z/oOMo99KXe7zMmdvUE8phb4XS4IiEOWNdyuig=; b=Xh4aNxCYgOx9pHi5F1LNRVdwVem68Z4d6F6oG9gbbSeHAmKKYPlKSopFVEodvxwKHv Uv6pHZa+ZQL54ZIxKDBx2XT8MoAKKd+yieeOGkJ0xTXc8CX+iouLpJcU+Ba4xZcSNbaO U1NrTfa75g7R1+Cqr1vHBvenlG0bfLFFmGxEoYm/H4IzIlMaTKqhsKt7XVDEeCSkO6JA cKaGiOfC0wEHDCEzr83L8jJpeiy9eFJyPQGvY90dSNKsm0okQpI3T68NGv6zTdZqkQXb UoUnVTokZrfRAguOM1iQDYTzM/Vl6UP+2nNDngAqwHTXoXriWlnm8FoL4TQEZ/Pjhlya LuvA== 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=4q7I7z/oOMo99KXe7zMmdvUE8phb4XS4IiEOWNdyuig=; b=i7oD5nRWvtEbsFu97e0gI/3F0rZiOhv9XcgWVgziQCQOEVKVhaAS5Va393XUmXL0wE kVOsFedUWo8DOtgifRJ9WZniq0msG06YPe7xEGdHd0st6i8SHC70n9CVcejloMlrnMlB 1R2DNdTlj8oNN76AydQGwAIk2em63sYvDGxWx520WJwQ2rEwZFI3c+y2n6ckO2jq/8od pUaBjajRv7tnF3YCIkcDqdUmssVuGxYJrZ7Y/G+kBzZjXxqkTBaXaw8GcFArdmsL8Fe4 bH8bg6XkMeKJpRiHDoF0uO/5/JxkBfm0Tc0XRp0OAl2Ux/fh/oMoRGqXHIzgMzM0nb1a EWRg== X-Gm-Message-State: AOAM531uQydN/ODDqKIz2DaWdp4wv0Ws/Xq6EUX5oFuGCRM2ISFv0qpk Hf/CqMAxsURfEQ+FTo70GMrYhT6vYKQ= X-Google-Smtp-Source: ABdhPJwABKrzRMVqwLWzfUysxcAcT9xQP8981zkeVYIgToPJO5P144gmsHk0p4IdN262fMYl5zI9lw== X-Received: by 2002:a65:6a0b:: with SMTP id m11mr2855680pgu.380.1627548022195; Thu, 29 Jul 2021 01:40:22 -0700 (PDT) Received: from MiBook.. ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id f5sm2401539pjo.23.2021.07.29.01.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:40:21 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v7 mptcp-next 2/5] mptcp: MP_FAIL suboption receiving Date: Thu, 29 Jul 2021 16:40:10 +0800 Message-Id: <0c155f43f4bc75c90cf45283e07ea48432178d48.1627547666.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 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 6db24cf72ac0..ba7166daf6cb 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); @@ -1145,6 +1156,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 Thu Jul 29 08:40: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: 12408117 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 6377A70 for ; Thu, 29 Jul 2021 08:40:25 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id t21so6086369plr.13 for ; Thu, 29 Jul 2021 01:40: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=GN48nuQg3tB2z/fe244G9A21kEE0e2/ZY6GzA3HtgfQ=; b=fj6jZvjqQ2Mn8sHrdtR8ddBX5FLE792Gsgnx4tpAmhN5Y/6zFnasVOdD7toPEQ+DSp yuIcbapVgzgpEW73FgJI3vFVW8QlVsJGUI2Xohcd+4pH7hItFbfllCKhL5i8gaF5+Tyg 2QxznT3IZX/Bjiw81rrpqX2fSJ0ORe4lI3TVNghqKYFqOdNqJlMrod5uqO5CnfIG9anK 82zYAjTKTjGdrkOhGRilWfUbxvX3S/v2XAGUxsfulzdDm4vLR6CLEnHZJFwehrksdmzu dWK3ITZL7MXXCywYViuszaz5OaZJZBah/ySJZJwCkHFD1QNWgV2rfTDfful0TODwBZU1 R+Tg== 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=GN48nuQg3tB2z/fe244G9A21kEE0e2/ZY6GzA3HtgfQ=; b=GXqg+ZAmCp+XrWPTjDK1gXtaLlwWUAkcyN/kKzGiF0qfU5915BgrFXgPtTBvmubuEU nojEZbhZTtrUSNt94TTixahzv6YKFXgRJJCXBH1hjui1NXJ0JYbcwvozB6y/c5+AqrKZ A9dyQtT8b8AL7mKCmMWZz015nVTjPaKJpFY90wogdF8hrNVOCpv9FUc7XKZR+HDkr5H4 ffDCSs0g4+06CU/DCA/KxRZf1x94JgXyS2nArkL5nbaj3xE3XXmqSgCyLI8u2D64fl4q TcmNvVGB+rY45Vc0/I5O+ToEe4anIsSDMwehRDfjL2hK1tMC1cBVnklvMnSSN8vWH4Mb fHsg== X-Gm-Message-State: AOAM532fnezsSQSbVR7P3y0IcwKiabO7CJq9cbVVA3STdjkw4Y1XAuMx GCxzI1earit6IuIcBR6Qg1d5pah5IyU= X-Google-Smtp-Source: ABdhPJyJaXhhBzrVQYxd5w6PA0jyX9ybH8spvKFVbdKMqFvObmDRb9GnjtIukjNrMUdVfk19EIMnQw== X-Received: by 2002:a63:490e:: with SMTP id w14mr2926555pga.93.1627548024782; Thu, 29 Jul 2021 01:40:24 -0700 (PDT) Received: from MiBook.. ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id f5sm2401539pjo.23.2021.07.29.01.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:40:24 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v7 mptcp-next 3/5] mptcp: send out MP_FAIL when data checksum fails Date: Thu, 29 Jul 2021 16:40:11 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: <0c155f43f4bc75c90cf45283e07ea48432178d48.1627547666.git.geliangtang@xiaomi.com> References: <0c155f43f4bc75c90cf45283e07ea48432178d48.1627547666.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, temporarily handled by sending MP_FAIL with a RST too. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 13 +++++++++++++ net/mptcp/subflow.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 09d0e9406ea9..6888d2690e79 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -615,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..d405385d2e7f 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,20 @@ 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)) { + while ((skb = skb_peek(&ssk->sk_receive_queue))) + sk_eat_skb(ssk, skb); + } + 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); + 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 Thu Jul 29 08:40: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: 12408119 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 5EAB470 for ; Thu, 29 Jul 2021 08:40:27 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id ds11-20020a17090b08cbb0290172f971883bso14523738pjb.1 for ; Thu, 29 Jul 2021 01:40: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=DDgJAUP0S0b2EesBRAqbIppXvUW8pdYAC+LZOCoF3BI=; b=Dqz2D5AtBo4RGjg86q66i+r3Ox41D9EK61DQPXr1sZNptmQfZeP6HFJ8GQ92QvsHXp LT9HKQbUq66hw6e/i3UgOrAMi+PgGBEHujALwms0XW7KfEWWQ88AqO3o5fss5Z48b8js SZVBlv0cz0+GxJIfFNFEoca0SYIQM1wJeZ0t+URJdWR4JiWVhXNgXzRA0vk6NdcU62vu bQaLaDjrpq1+f31+wZmFWG8RCGTU47YQPc7sK3W9kukEiVx0RKiqTSgsW5buqJduqlsN g4Lkz0kU8wdtS+vWFDRKkYzUSdsbOPZXQH9PjI/VjbvlvzVdGGuz8L+4A1Ktlx8OeHoC vyWw== 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=DDgJAUP0S0b2EesBRAqbIppXvUW8pdYAC+LZOCoF3BI=; b=VUQJ7khzmLrP8W496IVjhWyGbMtVcUz/ObuWTxe4PmZliwGtNmG/AfZq/f47kzNDMc AVr54+s5+NSJvN8ab6x9nCRocrj3DEX5lGpi/VS52LgP7yKrh5+SwFoBEcnhP5Wjo1Gc 3cRmmOM5rBom9mVK1YlKH705CecI4HPMW3mmA7alHG9zkV/HSt+0DSUtAvxoQ6/YAfUt iOd24yliN0dU4iQJ3/V8Xlikl+AplOYyRFun10MNVZQhzH8uFZArGGfSfJXEpGk65KIj VWlwlGM7de8xbV4dm0qOxSMtJkq3x9+Sx8FB6uk56NQQgF/IurJzTx99XNxlhFSD5tPD JnCg== X-Gm-Message-State: AOAM533jri8gzyfaPmhEl+LLoIwTZa7UBrCrXmBwnLRo2urMQk3hy4w1 qCjkLPmF2E2TmjRcDiI0kpqwrDpxt/4= X-Google-Smtp-Source: ABdhPJzU/tDGLpiXRkRJq+TtSCBA9VxMPMruN748jn8KxPn3YKoTDFFNhvAB21yNxtUd5I3/BgEWHA== X-Received: by 2002:a17:90a:ca0f:: with SMTP id x15mr6254532pjt.78.1627548026896; Thu, 29 Jul 2021 01:40:26 -0700 (PDT) Received: from MiBook.. ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id f5sm2401539pjo.23.2021.07.29.01.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:40:26 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v7 mptcp-next 4/5] mptcp: add the mibs for MP_FAIL Date: Thu, 29 Jul 2021 16:40:12 +0800 Message-Id: <1ad053e0160d44c3bc998149aeef9a55306e3eb4.1627547666.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: <0c155f43f4bc75c90cf45283e07ea48432178d48.1627547666.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/subflow.c | 1 + 4 files changed, 6 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 ba7166daf6cb..eaee69df6635 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1158,6 +1158,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/subflow.c b/net/mptcp/subflow.c index d405385d2e7f..0f210d95133d 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 Thu Jul 29 08:40: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: 12408121 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 2A9C970 for ; Thu, 29 Jul 2021 08:40:29 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id f13so6165391plj.2 for ; Thu, 29 Jul 2021 01:40: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=FgZXEf4QrwOvtWU1JgkRPFg33D1whw8NcfRPEWcJdubqcvnI9bSdwBkQbZCyOfmrto 5HuVCPDyvOY9oxwPKbI8aZQAdZk5uAlLeo3OjFDVGyjC0257cag7f2CbW7zn08YAXtWY VvGbBjtU7k6IPjJQURlDs5IV2ARpItz6SAwsJXigUZIdNl9yHRhEbHEGQa7CX4frfp5K mWAbhVuAyJyPtzVD0a32j6aH8FjC5OUZrmQmhfrsASX8HWN9KnQKPEWKAkjVsz5EFFri Pr2TZNa4nEVy6jGFHta340YOL7MqhTeR7Yar6cxQV7jjU32BaslFqPgFjkBJAlUAi2DT r7Gw== 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=n9rCcTyIGGl3xbZCc45TPZfjGRQv1a9kZ29l9mJXakewFQeCWRLDgv0NAA9bMc34uW YmNJ4Tn1jW9O8F7CR9lq/Wnu7AHgdUXLBgcX3IAO1t2igAU4JkPGw8tMSh7LBNn3drXE Za3/1Dz+w8Cdm5euKEuUGIihKBltCYtGwA8V4AMf9FRaih+ijnXJ1lMa7SjAHTHOaSI5 bltL7KUmZxEY4uMyoJjFfxTJ88OKgt3G/Z5HclHclMwvEpgw5LkogrwkoDRfZFE/BW1U C3WUyoQEFMVo0mCKiyQe+j/NR1IMGCH8Gn9zGaiBDZJ7zoYcTXGpTvTmEXBItzXD0z5J WIFg== X-Gm-Message-State: AOAM531P00Xen6u7yoWZRPJcY/GnzaPfsAQylUdb3QCEqcZgnmNJ1G4H IvlmFDJQwA2vwfht1KiQVhitJAIQRrc= X-Google-Smtp-Source: ABdhPJy6vlARknTcNFn7KLrygUTP7qWrBCVDb2g+om3VKcgP42IRsP6Qgqn3hEpOVY9xRBze7sN7QQ== X-Received: by 2002:aa7:97bd:0:b029:32c:56cc:8fa9 with SMTP id d29-20020aa797bd0000b029032c56cc8fa9mr3822017pfq.65.1627548028660; Thu, 29 Jul 2021 01:40:28 -0700 (PDT) Received: from MiBook.. ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id f5sm2401539pjo.23.2021.07.29.01.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:40:28 -0700 (PDT) From: Geliang Tang To: mptcp@lists.linux.dev, geliangtang@gmail.com Cc: Geliang Tang Subject: [MPTCP][PATCH v7 mptcp-next 5/5] selftests: mptcp: add MP_FAIL mibs check Date: Thu, 29 Jul 2021 16:40:13 +0800 Message-Id: <5a7d1ff8e4b688095bb0c2675ea76f6e18fac950.1627547666.git.geliangtang@xiaomi.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <1ad053e0160d44c3bc998149aeef9a55306e3eb4.1627547666.git.geliangtang@xiaomi.com> References: <0c155f43f4bc75c90cf45283e07ea48432178d48.1627547666.git.geliangtang@xiaomi.com> <1ad053e0160d44c3bc998149aeef9a55306e3eb4.1627547666.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 }