From 991ee414fcaf64852afee33f803413bbf0e61445 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:23 +0200 Subject: [PATCH 01/65] tg create t/mptcp-add-csum_enabled-in-mptcp_sock base --- .topdeps | 1 - .topmsg | 15 --------------- 2 files changed, 16 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 7e1d545608e1f..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-support-SYSCTL-only-if-enabled diff --git a/.topmsg b/.topmsg deleted file mode 100644 index b44397c9749ee..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,15 +0,0 @@ -From: Matthieu Baerts -Subject: [PATCH] mptcp: restrict values of 'enabled' sysctl - -To avoid confusions, it seems better to parse this sysctl parameter as a -boolean. We use it as a boolean, no need to parse an integer and bring -confusions if we see a value different from 0 and 1, especially with -this parameter name: enabled. - -It seems fine to do this modification because the default value is 1 -(enabled). Then the only other interesting value to set is 0 (disabled). -All other values would not have changed the default behaviour. - -Suggested-by: Florian Westphal -Acked-by: Florian Westphal -Signed-off-by: Matthieu Baerts From c229361c6103ced5a345dc3c1721479ce4cbf473 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:23 +0200 Subject: [PATCH 02/65] tg create t/mptcp-add-csum_enabled-in-mptcp_sock --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..c71c578531c31 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-restrict-values-of-enabled-sysctl diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..30dfb7659696d --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-csum_enabled-in-mptcp_sock + +Signed-off-by: Matthieu Baerts From c339f983c20bfb16a60f23c4f583f8af22456eb1 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:24 +0200 Subject: [PATCH 03/65] tg import create t/mptcp-add-csum_enabled-in-mptcp_sock --- .topmsg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 30dfb7659696d..9eaced7e73224 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,12 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-csum_enabled-in-mptcp_sock +From: Geliang Tang +Subject: [PATCH] mptcp: add csum_enabled in mptcp_sock -Signed-off-by: Matthieu Baerts +This patch added a new member named csum_enabled in struct mptcp_sock, +used a dummy mptcp_is_checksum_enabled() helper to initialize it. + +Also added a new member named mptcpi_csum_enabled in struct mptcp_info +to expose the csum_enabled flag. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 9e37234f4af0954400d4135b1467028ca8ea4e9c Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:49 +0200 Subject: [PATCH 04/65] mptcp: add csum_enabled in mptcp_sock This patch added a new member named csum_enabled in struct mptcp_sock, used a dummy mptcp_is_checksum_enabled() helper to initialize it. Also added a new member named mptcpi_csum_enabled in struct mptcp_info to expose the csum_enabled flag. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- include/uapi/linux/mptcp.h | 1 + net/mptcp/mptcp_diag.c | 1 + net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 2 ++ 4 files changed, 5 insertions(+) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 8eb3c0844bfff..7b05f7102321a 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -105,6 +105,7 @@ struct mptcp_info { __u64 mptcpi_rcv_nxt; __u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_max; + __u8 mptcpi_csum_enabled; }; /* diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c index f16d9b5ee978e..8f88ddeab6a2e 100644 --- a/net/mptcp/mptcp_diag.c +++ b/net/mptcp/mptcp_diag.c @@ -144,6 +144,7 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, info->mptcpi_write_seq = READ_ONCE(msk->write_seq); info->mptcpi_snd_una = READ_ONCE(msk->snd_una); info->mptcpi_rcv_nxt = READ_ONCE(msk->ack_seq); + info->mptcpi_csum_enabled = READ_ONCE(msk->csum_enabled); unlock_sock_fast(sk, slow); } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 29a2d690d8d59..b6f75ad596a86 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2411,6 +2411,7 @@ static int __mptcp_init_sock(struct sock *sk) msk->ack_hint = NULL; msk->first = NULL; inet_csk(sk)->icsk_sync_mss = mptcp_sync_mss; + WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); mptcp_pm_data_init(msk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d230a75af6313..6cbbe74034023 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -234,6 +234,7 @@ struct mptcp_sock { bool snd_data_fin_enable; bool rcv_fastclose; bool use_64bit_ack; /* Set when we received a 64-bit DSN */ + bool csum_enabled; spinlock_t join_list_lock; struct sock *ack_hint; struct work_struct work; @@ -524,6 +525,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *su int mptcp_is_enabled(struct net *net); unsigned int mptcp_get_add_addr_timeout(struct net *net); +static inline int mptcp_is_checksum_enabled(struct net *net) { return false; } void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, struct mptcp_options_received *mp_opt); bool mptcp_subflow_data_available(struct sock *sk); From 35f63240eced334c9a1b6efe090c756ab72b2ee8 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:27 +0200 Subject: [PATCH 05/65] tg create t/mptcp-generate-the-data-checksum base --- .topdeps | 1 - .topmsg | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index c71c578531c31..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-restrict-values-of-enabled-sysctl diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 9eaced7e73224..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,12 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add csum_enabled in mptcp_sock - -This patch added a new member named csum_enabled in struct mptcp_sock, -used a dummy mptcp_is_checksum_enabled() helper to initialize it. - -Also added a new member named mptcpi_csum_enabled in struct mptcp_info -to expose the csum_enabled flag. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 6ef6cb3d1d5680464de6fc3e1d5e8cd65d03df5c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:27 +0200 Subject: [PATCH 06/65] tg create t/mptcp-generate-the-data-checksum --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..3923ee988a313 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-csum_enabled-in-mptcp_sock diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..21accc4081ec6 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-generate-the-data-checksum + +Signed-off-by: Matthieu Baerts From f0d6ce5bce7c411056ed850461b474c9e15ab698 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:28 +0200 Subject: [PATCH 07/65] tg import create t/mptcp-generate-the-data-checksum --- .topmsg | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 21accc4081ec6..ece53d33a834d 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,20 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-generate-the-data-checksum +From: Geliang Tang +Subject: [PATCH] mptcp: generate the data checksum -Signed-off-by: Matthieu Baerts +This patch added a new member named csum in struct mptcp_ext, implemented +a new function named mptcp_generate_data_checksum(). + +Generate the data checksum in mptcp_sendmsg_frag, save it in mpext->csum. + +Note that we must generate the csum for zero window probe, too. + +Do the csum update incrementally, to avoid multiple csum computation +when the data is appended to existing skb. + +Note that in a later patch we will skip unneeded csum related operation. +Changes not included here to keep the delta small. + +Co-developed-by: Paolo Abeni +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 8e5a007a6f4909ef0193903022c218ff80a0f891 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:50 +0200 Subject: [PATCH 08/65] mptcp: generate the data checksum This patch added a new member named csum in struct mptcp_ext, implemented a new function named mptcp_generate_data_checksum(). Generate the data checksum in mptcp_sendmsg_frag, save it in mpext->csum. Note that we must generate the csum for zero window probe, too. Do the csum update incrementally, to avoid multiple csum computation when the data is appended to existing skb. Note that in a later patch we will skip unneeded csum related operation. Changes not included here to keep the delta small. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/options.c | 3 +++ net/mptcp/protocol.c | 18 +++++++++++++++++- net/mptcp/protocol.h | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 83f23774b9084..23bbd439e1152 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -23,6 +23,7 @@ struct mptcp_ext { u64 data_seq; u32 subflow_seq; u16 data_len; + __sum16 csum; u8 use_map:1, dsn64:1, data_fin:1, diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 99fc21406168b..beac01f58cbae 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -519,6 +519,9 @@ static void mptcp_write_data_fin(struct mptcp_subflow_context *subflow, */ ext->data_fin = 1; ext->data_len++; + + /* the pseudo header has changed, update the csum accordingly */ + csum_replace2(&ext->csum, htons(ext->data_len - 1), htons(ext->data_len)); } } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b6f75ad596a86..a1a4dcc9cf157 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1279,6 +1279,18 @@ static bool mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk) return __mptcp_alloc_tx_skb(sk, ssk, sk->sk_allocation); } +/* note: this always recompute the csum on the whole skb, even + * if we just appended a single frag. More status info needed + */ +static void mptcp_update_data_checksum(struct sk_buff *skb, int added) +{ + struct mptcp_ext *mpext = mptcp_get_ext(skb); + __wsum csum = csum_unfold(mpext->csum); + int offset = skb->len - added; + + mpext->csum = csum_fold(csum_block_add(csum, skb_checksum(skb, offset, added, 0), offset)); +} + static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, struct mptcp_data_frag *dfrag, struct mptcp_sendmsg_info *info) @@ -1373,10 +1385,14 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, if (zero_window_probe) { mptcp_subflow_ctx(ssk)->rel_write_seq += ret; mpext->frozen = 1; - ret = 0; + if (READ_ONCE(msk->csum_enabled)) + mptcp_update_data_checksum(tail, ret); tcp_push_pending_frames(ssk); + return 0; } out: + if (READ_ONCE(msk->csum_enabled)) + mptcp_update_data_checksum(tail, ret); mptcp_subflow_ctx(ssk)->rel_write_seq += ret; return ret; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6cbbe74034023..236782702bfbb 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -335,6 +335,13 @@ static inline struct mptcp_data_frag *mptcp_rtx_head(const struct sock *sk) return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list); } +struct csum_pseudo_header { + __be64 data_seq; + __be32 subflow_seq; + __be16 data_len; + __sum16 csum; +}; + struct mptcp_subflow_request_sock { struct tcp_request_sock sk; u16 mp_capable : 1, From 4f2b96476a999b8b90e08bf7dca5771d6c4787c9 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:30 +0200 Subject: [PATCH 09/65] tg create t/mptcp-add-csum_reqd-in-mptcp_out_options base --- .topdeps | 1 - .topmsg | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 3923ee988a313..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-csum_enabled-in-mptcp_sock diff --git a/.topmsg b/.topmsg deleted file mode 100644 index ece53d33a834d..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,20 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: generate the data checksum - -This patch added a new member named csum in struct mptcp_ext, implemented -a new function named mptcp_generate_data_checksum(). - -Generate the data checksum in mptcp_sendmsg_frag, save it in mpext->csum. - -Note that we must generate the csum for zero window probe, too. - -Do the csum update incrementally, to avoid multiple csum computation -when the data is appended to existing skb. - -Note that in a later patch we will skip unneeded csum related operation. -Changes not included here to keep the delta small. - -Co-developed-by: Paolo Abeni -Signed-off-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 92231b5e32bce4685d7312bc74df7c9286f63e22 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:31 +0200 Subject: [PATCH 10/65] tg create t/mptcp-add-csum_reqd-in-mptcp_out_options --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..b2e5630b20068 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-generate-the-data-checksum diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..952c66681ec9b --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-csum_reqd-in-mptcp_out_options + +Signed-off-by: Matthieu Baerts From 8aebbca897267b7fdf1764c48bca94716b443d16 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:32 +0200 Subject: [PATCH 11/65] tg import create t/mptcp-add-csum_reqd-in-mptcp_out_options --- .topmsg | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 952c66681ec9b..759ef6e385c9d 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,13 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-csum_reqd-in-mptcp_out_options +From: Geliang Tang +Subject: [PATCH] mptcp: add csum_reqd in mptcp_out_options -Signed-off-by: Matthieu Baerts +This patch added a new member csum_reqd in struct mptcp_out_options and +struct mptcp_subflow_request_sock. Initialized it with the helper +function mptcp_is_checksum_enabled(). + +In mptcp_write_options, if this field is enabled, send out the MP_CAPABLE +suboption with the MPTCP_CAP_CHECKSUM_REQD flag. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 65d5dab352545de73edc976ab87d0b5f1ea4127d Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:52 +0200 Subject: [PATCH 12/65] mptcp: add csum_reqd in mptcp_out_options This patch added a new member csum_reqd in struct mptcp_out_options and struct mptcp_subflow_request_sock. Initialized it with the helper function mptcp_is_checksum_enabled(). In mptcp_write_options, if this field is enabled, send out the MP_CAPABLE suboption with the MPTCP_CAP_CHECKSUM_REQD flag. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 ++- net/mptcp/options.c | 11 +++++++++-- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 23bbd439e1152..8f86c05ddbfd6 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -65,7 +65,8 @@ struct mptcp_out_options { u8 join_id; u8 backup; u8 reset_reason:4; - u8 reset_transient:1; + u8 reset_transient:1, + csum_reqd:1; u32 nonce; u64 thmac; u32 token; diff --git a/net/mptcp/options.c b/net/mptcp/options.c index beac01f58cbae..389d489780044 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -381,6 +381,7 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, subflow->snd_isn = TCP_SKB_CB(skb)->end_seq; if (subflow->request_mptcp) { opts->suboptions = OPTION_MPTCP_MPC_SYN; + opts->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk)); *size = TCPOLEN_MPTCP_MPC_SYN; return true; } else if (subflow->request_join) { @@ -436,6 +437,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, struct mptcp_out_options *opts) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct mptcp_ext *mpext; unsigned int data_len; @@ -466,6 +468,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, opts->suboptions = OPTION_MPTCP_MPC_ACK; opts->sndr_key = subflow->local_key; opts->rcvr_key = subflow->remote_key; + opts->csum_reqd = READ_ONCE(msk->csum_enabled); /* Section 3.1. * The MP_CAPABLE option is carried on the SYN, SYN/ACK, and ACK @@ -793,6 +796,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size, if (subflow_req->mp_capable) { opts->suboptions = OPTION_MPTCP_MPC_SYNACK; opts->sndr_key = subflow_req->local_key; + opts->csum_reqd = subflow_req->csum_reqd; *size = TCPOLEN_MPTCP_MPC_SYNACK; pr_debug("subflow_req=%p, local_key=%llu", subflow_req, subflow_req->local_key); @@ -1127,7 +1131,7 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, { if ((OPTION_MPTCP_MPC_SYN | OPTION_MPTCP_MPC_SYNACK | OPTION_MPTCP_MPC_ACK) & opts->suboptions) { - u8 len; + u8 len, flag = MPTCP_CAP_HMAC_SHA256; if (OPTION_MPTCP_MPC_SYN & opts->suboptions) len = TCPOLEN_MPTCP_MPC_SYN; @@ -1138,9 +1142,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, else len = TCPOLEN_MPTCP_MPC_ACK; + if (opts->csum_reqd) + flag |= MPTCP_CAP_CHECKSUM_REQD; + *ptr++ = mptcp_option(MPTCPOPT_MP_CAPABLE, len, MPTCP_SUPPORTED_VERSION, - MPTCP_CAP_HMAC_SHA256); + flag); if (!((OPTION_MPTCP_MPC_SYNACK | OPTION_MPTCP_MPC_ACK) & opts->suboptions)) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 236782702bfbb..141317aa6c52e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -346,7 +346,8 @@ struct mptcp_subflow_request_sock { struct tcp_request_sock sk; u16 mp_capable : 1, mp_join : 1, - backup : 1; + backup : 1, + csum_reqd : 1; u8 local_id; u8 remote_id; u64 local_key; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 01f30f8ea7108..53237018c1ca8 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -108,6 +108,7 @@ static void subflow_init_req(struct request_sock *req, const struct sock *sk_lis subflow_req->mp_capable = 0; subflow_req->mp_join = 0; + subflow_req->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk_listener)); subflow_req->msk = NULL; mptcp_token_init_request(req); } From 90a8ec868a4c251cc8ba2c57ae328e947796a076 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:34 +0200 Subject: [PATCH 13/65] tg create t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data base --- .topdeps | 1 - .topmsg | 13 ------------- 2 files changed, 14 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index b2e5630b20068..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-generate-the-data-checksum diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 759ef6e385c9d..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,13 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add csum_reqd in mptcp_out_options - -This patch added a new member csum_reqd in struct mptcp_out_options and -struct mptcp_subflow_request_sock. Initialized it with the helper -function mptcp_is_checksum_enabled(). - -In mptcp_write_options, if this field is enabled, send out the MP_CAPABLE -suboption with the MPTCP_CAP_CHECKSUM_REQD flag. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From af0f8dbc37478c156fb556ec5d4f8630ba9a6833 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:35 +0200 Subject: [PATCH 14/65] tg create t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..e46115adb731d --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-csum_reqd-in-mptcp_out_options diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..62e679ac9b4c6 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data + +Signed-off-by: Matthieu Baerts From 70f1bc14362099982df559d3d5d4ad26b1f078e3 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:36 +0200 Subject: [PATCH 15/65] tg import create t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data --- .topmsg | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 62e679ac9b4c6..ae66fb664c5f5 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,14 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data +From: Geliang Tang +Subject: [PATCH] mptcp: send out checksum for MP_CAPABLE with data -Signed-off-by: Matthieu Baerts +If the checksum is enabled, send out the data checksum with the +MP_CAPABLE suboption with data. + +In mptcp_established_options_mp, save the data checksum in +opts->ext_copy.csum. In mptcp_write_options, adjust the option length and +send it out with the MP_CAPABLE suboption. + +Co-developed-by: Paolo Abeni +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From fa7ac4af5f35cb24dbaf6c12bbb537e7f777206d Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:53 +0200 Subject: [PATCH 16/65] mptcp: send out checksum for MP_CAPABLE with data If the checksum is enabled, send out the data checksum with the MP_CAPABLE suboption with data. In mptcp_established_options_mp, save the data checksum in opts->ext_copy.csum. In mptcp_write_options, adjust the option length and send it out with the MP_CAPABLE suboption. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 52 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 389d489780044..d18a686aab7d1 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -440,6 +440,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct mptcp_ext *mpext; unsigned int data_len; + u8 len; /* When skb is not available, we better over-estimate the emitted * options len. A full DSS option (28 bytes) is longer than @@ -475,10 +476,16 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, * packets that start the first subflow of an MPTCP connection, * as well as the first packet that carries data */ - if (data_len > 0) - *size = ALIGN(TCPOLEN_MPTCP_MPC_ACK_DATA, 4); - else + if (data_len > 0) { + len = TCPOLEN_MPTCP_MPC_ACK_DATA; + if (opts->csum_reqd) { + opts->ext_copy.csum = mpext->csum; + len += TCPOLEN_MPTCP_DSS_CHECKSUM; + } + *size = ALIGN(len, 4); + } else { *size = TCPOLEN_MPTCP_MPC_ACK; + } pr_debug("subflow=%p, local_key=%llu, remote_key=%llu map_len=%d", subflow, subflow->local_key, subflow->remote_key, @@ -1126,6 +1133,25 @@ static void mptcp_set_rwin(const struct tcp_sock *tp) WRITE_ONCE(msk->rcv_wnd_sent, ack_seq); } +static u16 mptcp_make_csum(const struct mptcp_ext *mpext) +{ + struct csum_pseudo_header header; + __wsum csum; + + /* cfr RFC 8684 3.3.1.: + * the data sequence number used in the pseudo-header is + * always the 64-bit value, irrespective of what length is used in the + * DSS option itself. + */ + header.data_seq = cpu_to_be64(mpext->data_seq); + header.subflow_seq = htonl(mpext->subflow_seq); + header.data_len = htons(mpext->data_len); + header.csum = 0; + + csum = csum_partial(&header, sizeof(header), ~csum_unfold(mpext->csum)); + return (__force u16)csum_fold(csum); +} + void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, struct mptcp_out_options *opts) { @@ -1133,14 +1159,17 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, OPTION_MPTCP_MPC_ACK) & opts->suboptions) { u8 len, flag = MPTCP_CAP_HMAC_SHA256; - if (OPTION_MPTCP_MPC_SYN & opts->suboptions) + if (OPTION_MPTCP_MPC_SYN & opts->suboptions) { len = TCPOLEN_MPTCP_MPC_SYN; - else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions) + } else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions) { len = TCPOLEN_MPTCP_MPC_SYNACK; - else if (opts->ext_copy.data_len) + } else if (opts->ext_copy.data_len) { len = TCPOLEN_MPTCP_MPC_ACK_DATA; - else + if (opts->csum_reqd) + len += TCPOLEN_MPTCP_DSS_CHECKSUM; + } else { len = TCPOLEN_MPTCP_MPC_ACK; + } if (opts->csum_reqd) flag |= MPTCP_CAP_CHECKSUM_REQD; @@ -1163,8 +1192,13 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, if (!opts->ext_copy.data_len) goto mp_capable_done; - put_unaligned_be32(opts->ext_copy.data_len << 16 | - TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); + if (opts->csum_reqd) { + put_unaligned_be32(opts->ext_copy.data_len << 16 | + mptcp_make_csum(&opts->ext_copy), ptr); + } else { + put_unaligned_be32(opts->ext_copy.data_len << 16 | + TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); + } ptr += 1; } From 25ed198cd38fd90da1f1f17f60a61d4265ac9a6a Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:38 +0200 Subject: [PATCH 17/65] tg create t/mptcp-send-out-checksum-for-DSS base --- .topdeps | 1 - .topmsg | 14 -------------- 2 files changed, 15 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index e46115adb731d..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-csum_reqd-in-mptcp_out_options diff --git a/.topmsg b/.topmsg deleted file mode 100644 index ae66fb664c5f5..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,14 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: send out checksum for MP_CAPABLE with data - -If the checksum is enabled, send out the data checksum with the -MP_CAPABLE suboption with data. - -In mptcp_established_options_mp, save the data checksum in -opts->ext_copy.csum. In mptcp_write_options, adjust the option length and -send it out with the MP_CAPABLE suboption. - -Co-developed-by: Paolo Abeni -Signed-off-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From ea8a27750fe692143a4973de1900130ffbe1aa61 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:39 +0200 Subject: [PATCH 18/65] tg create t/mptcp-send-out-checksum-for-DSS --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..979ed983c1edc --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..668b75608c160 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-send-out-checksum-for-DSS + +Signed-off-by: Matthieu Baerts From c227599662996fc923dfaa699be13a03847d97c9 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:40 +0200 Subject: [PATCH 19/65] tg import create t/mptcp-send-out-checksum-for-DSS --- .topmsg | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 668b75608c160..488487eaeba88 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,10 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-send-out-checksum-for-DSS +From: Geliang Tang +Subject: [PATCH] mptcp: send out checksum for DSS -Signed-off-by: Matthieu Baerts +In mptcp_write_options, if the checksum is enabled, adjust the option +length and send out the data checksum with DSS suboption. + +Co-developed-by: Paolo Abeni +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 020aa2793d7a718af4b5e42ffc388d51d0ed8798 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:55 +0200 Subject: [PATCH 20/65] mptcp: send out checksum for DSS In mptcp_write_options, if the checksum is enabled, adjust the option length and send out the data checksum with DSS suboption. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index d18a686aab7d1..ef951cb2aff30 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -479,6 +479,9 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, if (data_len > 0) { len = TCPOLEN_MPTCP_MPC_ACK_DATA; if (opts->csum_reqd) { + /* we need to propagate more info to csum the pseudo hdr */ + opts->ext_copy.data_seq = mpext->data_seq; + opts->ext_copy.subflow_seq = mpext->subflow_seq; opts->ext_copy.csum = mpext->csum; len += TCPOLEN_MPTCP_DSS_CHECKSUM; } @@ -549,18 +552,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, bool ret = false; u64 ack_seq; + opts->csum_reqd = READ_ONCE(msk->csum_enabled); mpext = skb ? mptcp_get_ext(skb) : NULL; if (!skb || (mpext && mpext->use_map) || snd_data_fin_enable) { - unsigned int map_size; + unsigned int map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64; - map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64; + if (mpext) { + if (opts->csum_reqd) + map_size += TCPOLEN_MPTCP_DSS_CHECKSUM; - remaining -= map_size; - dss_size = map_size; - if (mpext) opts->ext_copy = *mpext; + } + remaining -= map_size; + dss_size = map_size; if (skb && snd_data_fin_enable) mptcp_write_data_fin(subflow, skb, &opts->ext_copy); ret = true; @@ -1350,6 +1356,9 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, flags |= MPTCP_DSS_HAS_MAP | MPTCP_DSS_DSN64; if (mpext->data_fin) flags |= MPTCP_DSS_DATA_FIN; + + if (opts->csum_reqd) + len += TCPOLEN_MPTCP_DSS_CHECKSUM; } *ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags); @@ -1369,8 +1378,13 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, ptr += 2; put_unaligned_be32(mpext->subflow_seq, ptr); ptr += 1; - put_unaligned_be32(mpext->data_len << 16 | - TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); + if (opts->csum_reqd) { + put_unaligned_be32(mpext->data_len << 16 | + mptcp_make_csum(mpext), ptr); + } else { + put_unaligned_be32(mpext->data_len << 16 | + TCPOPT_NOP << 8 | TCPOPT_NOP, ptr); + } } } From 3ad13a22d8017789e18bd41be83707ec2c5a0a49 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:42 +0200 Subject: [PATCH 21/65] tg create t/mptcp-add-sk-parameter-for-mptcp_parse_option base --- .topdeps | 1 - .topmsg | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 979ed983c1edc..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-send-out-checksum-for-MP_CAPABLE-with-data diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 488487eaeba88..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,10 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: send out checksum for DSS - -In mptcp_write_options, if the checksum is enabled, adjust the option -length and send out the data checksum with DSS suboption. - -Co-developed-by: Paolo Abeni -Signed-off-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 440a4a88b9460a0ba51847bdc7c3b018e84b8806 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:43 +0200 Subject: [PATCH 22/65] tg create t/mptcp-add-sk-parameter-for-mptcp_parse_option --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..d231ece17e599 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-send-out-checksum-for-DSS diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..450bae5885f84 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-sk-parameter-for-mptcp_parse_option + +Signed-off-by: Matthieu Baerts From 1a99353817c26fadc9942d2acde5bb38cefdb762 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:44 +0200 Subject: [PATCH 23/65] tg import create t/mptcp-add-sk-parameter-for-mptcp_parse_option --- .topmsg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 450bae5885f84..7a365ab2fada0 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,9 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-sk-parameter-for-mptcp_parse_option +From: Geliang Tang +Subject: [PATCH] mptcp: add sk parameter for mptcp_parse_option -Signed-off-by: Matthieu Baerts +This patch added a new parameter name sk in mptcp_parse_option() and +mptcp_get_options(). + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From f343075f84d85839fde8372c981ebccb6e7396ae Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:57 +0200 Subject: [PATCH 24/65] mptcp: add sk parameter for mptcp_parse_option This patch added a new parameter name sk in mptcp_parse_option() and mptcp_get_options(). Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 10 ++++++---- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index ef951cb2aff30..8f768c517586f 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -20,7 +20,8 @@ static bool mptcp_cap_flag_sha256(u8 flags) return (flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA256; } -static void mptcp_parse_option(const struct sk_buff *skb, +static void mptcp_parse_option(const struct sock *sk, + const struct sk_buff *skb, const unsigned char *ptr, int opsize, struct mptcp_options_received *mp_opt) { @@ -324,7 +325,8 @@ static void mptcp_parse_option(const struct sk_buff *skb, } } -void mptcp_get_options(const struct sk_buff *skb, +void mptcp_get_options(const struct sock *sk, + const struct sk_buff *skb, struct mptcp_options_received *mp_opt) { const struct tcphdr *th = tcp_hdr(skb); @@ -363,7 +365,7 @@ void mptcp_get_options(const struct sk_buff *skb, if (opsize > length) return; /* don't parse partial options */ if (opcode == TCPOPT_MPTCP) - mptcp_parse_option(skb, ptr, opsize, mp_opt); + mptcp_parse_option(sk, skb, ptr, opsize, mp_opt); ptr += opsize - 2; length -= opsize; } @@ -1028,7 +1030,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) return; } - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk, skb, &mp_opt); if (!check_fully_established(msk, sk, subflow, skb, &mp_opt)) return; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 141317aa6c52e..a1def094899cb 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -585,7 +585,8 @@ int __init mptcp_proto_v6_init(void); struct sock *mptcp_sk_clone(const struct sock *sk, const struct mptcp_options_received *mp_opt, struct request_sock *req); -void mptcp_get_options(const struct sk_buff *skb, +void mptcp_get_options(const struct sock *sk, + const struct sk_buff *skb, struct mptcp_options_received *mp_opt); void mptcp_finish_connect(struct sock *sk); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 53237018c1ca8..2577dfc9ff12e 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -151,7 +151,7 @@ static int subflow_check_req(struct request_sock *req, return -EINVAL; #endif - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk_listener, skb, &mp_opt); if (mp_opt.mp_capable) { SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE); @@ -248,7 +248,7 @@ int mptcp_subflow_init_cookie_req(struct request_sock *req, int err; subflow_init_req(req, sk_listener); - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk_listener, skb, &mp_opt); if (mp_opt.mp_capable && mp_opt.mp_join) return -EINVAL; @@ -395,7 +395,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->ssn_offset = TCP_SKB_CB(skb)->seq; pr_debug("subflow=%p synack seq=%x", subflow, subflow->ssn_offset); - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk, skb, &mp_opt); if (subflow->request_mptcp) { if (!mp_opt.mp_capable) { MPTCP_INC_STATS(sock_net(sk), @@ -639,7 +639,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, goto create_msk; } - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk, skb, &mp_opt); if (!mp_opt.mp_capable) { fallback = true; goto create_child; @@ -650,7 +650,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, if (!new_msk) fallback = true; } else if (subflow_req->mp_join) { - mptcp_get_options(skb, &mp_opt); + mptcp_get_options(sk, skb, &mp_opt); if (!mp_opt.mp_join || !subflow_hmac_valid(req, &mp_opt) || !mptcp_can_accept_new_subflow(subflow_req->msk)) { SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC); From 893036e74c8f42e756c040f69b56a1a124f7ccf2 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:46 +0200 Subject: [PATCH 25/65] tg create t/mptcp-add-csum_reqd-in-mptcp_options_received base --- .topdeps | 1 - .topmsg | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index d231ece17e599..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-send-out-checksum-for-DSS diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 7a365ab2fada0..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,9 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add sk parameter for mptcp_parse_option - -This patch added a new parameter name sk in mptcp_parse_option() and -mptcp_get_options(). - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 71105ab4ff06d575e1d34d0af7572c5118736f5d Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:46 +0200 Subject: [PATCH 26/65] tg create t/mptcp-add-csum_reqd-in-mptcp_options_received --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..311b869123945 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-sk-parameter-for-mptcp_parse_option diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..f21d1ff547bc6 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-csum_reqd-in-mptcp_options_received + +Signed-off-by: Matthieu Baerts From 155f5a362fc6db416ffcd4f23741336d61e50848 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:48 +0200 Subject: [PATCH 27/65] tg import create t/mptcp-add-csum_reqd-in-mptcp_options_received --- .topmsg | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index f21d1ff547bc6..c9ffb12bdb2f3 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,13 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-csum_reqd-in-mptcp_options_received +From: Geliang Tang +Subject: [PATCH] mptcp: add csum_reqd in mptcp_options_received -Signed-off-by: Matthieu Baerts +This patch added a new flag csum_reqd in struct mptcp_options_received, if +the flag MPTCP_CAP_CHECKSUM_REQD is set in the receiving MP_CAPABLE +suboption, set this flag. + +In mptcp_sk_clone and subflow_finish_connect, if the csum_reqd flag is set, +enable the msk->csum_enabled flag. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 36175fd83775f30e3e9e8081b94e8b57ce3d3172 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:58 +0200 Subject: [PATCH 28/65] mptcp: add csum_reqd in mptcp_options_received This patch added a new flag csum_reqd in struct mptcp_options_received, if the flag MPTCP_CAP_CHECKSUM_REQD is set in the receiving MP_CAPABLE suboption, set this flag. In mptcp_sk_clone and subflow_finish_connect, if the csum_reqd flag is set, enable the msk->csum_enabled flag. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 8 +++++--- net/mptcp/protocol.c | 2 ++ net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8f768c517586f..b86777b2b505f 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -25,6 +25,8 @@ static void mptcp_parse_option(const struct sock *sk, const unsigned char *ptr, int opsize, struct mptcp_options_received *mp_opt) { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + struct mptcp_sock *msk = mptcp_sk(subflow->conn); u8 subtype = *ptr >> 4; int expected_opsize; u8 version; @@ -72,11 +74,10 @@ static void mptcp_parse_option(const struct sock *sk, * "If a checksum is not present when its use has been * negotiated, the receiver MUST close the subflow with a RST as * it is considered broken." - * - * We don't implement DSS checksum - fall back to TCP. */ + mp_opt->csum_reqd = READ_ONCE(msk->csum_enabled); if (flags & MPTCP_CAP_CHECKSUM_REQD) - break; + mp_opt->csum_reqd = 1; mp_opt->mp_capable = 1; if (opsize >= TCPOLEN_MPTCP_MPC_SYNACK) { @@ -344,6 +345,7 @@ void mptcp_get_options(const struct sock *sk, mp_opt->dss = 0; mp_opt->mp_prio = 0; mp_opt->reset = 0; + mp_opt->csum_reqd = 0; length = (th->doff * 4) - sizeof(struct tcphdr); ptr = (const unsigned char *)(th + 1); diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a1a4dcc9cf157..a164f56e6a9d6 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2760,6 +2760,8 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->token = subflow_req->token; msk->subflow = NULL; WRITE_ONCE(msk->fully_established, false); + if (mp_opt->csum_reqd) + WRITE_ONCE(msk->csum_enabled, true); msk->write_seq = subflow_req->idsn + 1; msk->snd_nxt = msk->write_seq; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a1def094899cb..b1d360a498a0e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -133,6 +133,7 @@ struct mptcp_options_received { rm_addr : 1, mp_prio : 1, echo : 1, + csum_reqd : 1, backup : 1; u32 token; u32 nonce; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 2577dfc9ff12e..dd2668ffc7615 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -405,6 +405,8 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) goto fallback; } + if (mp_opt.csum_reqd) + WRITE_ONCE(mptcp_sk(parent)->csum_enabled, true); subflow->mp_capable = 1; subflow->can_ack = 1; subflow->remote_key = mp_opt.sndr_key; From c6060a2118b2b97afc7fce9a641a23c55151c9ae Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:50 +0200 Subject: [PATCH 29/65] tg create t/mptcp-receive-checksum-for-MP_CAPABLE-with-data base --- .topdeps | 1 - .topmsg | 13 ------------- 2 files changed, 14 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 311b869123945..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-sk-parameter-for-mptcp_parse_option diff --git a/.topmsg b/.topmsg deleted file mode 100644 index c9ffb12bdb2f3..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,13 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add csum_reqd in mptcp_options_received - -This patch added a new flag csum_reqd in struct mptcp_options_received, if -the flag MPTCP_CAP_CHECKSUM_REQD is set in the receiving MP_CAPABLE -suboption, set this flag. - -In mptcp_sk_clone and subflow_finish_connect, if the csum_reqd flag is set, -enable the msk->csum_enabled flag. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 5cff85c31a4d4f3142c185f819fb8d5deeb2e604 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:51 +0200 Subject: [PATCH 30/65] tg create t/mptcp-receive-checksum-for-MP_CAPABLE-with-data --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..4706950657349 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-csum_reqd-in-mptcp_options_received diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..c9eba5bc1c275 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-receive-checksum-for-MP_CAPABLE-with-data + +Signed-off-by: Matthieu Baerts From f8cf50d6bed4b26939f5c42d37061447c7bb2924 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:52 +0200 Subject: [PATCH 31/65] tg import create t/mptcp-receive-checksum-for-MP_CAPABLE-with-data --- .topmsg | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index c9eba5bc1c275..a9554080e9657 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,21 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-receive-checksum-for-MP_CAPABLE-with-data +From: Geliang Tang +Subject: [PATCH] mptcp: receive checksum for MP_CAPABLE with data -Signed-off-by: Matthieu Baerts +This patch added a new member named csum in struct mptcp_options_received. + +When parsing the MP_CAPABLE with data, if the checksum is enabled, +adjust the expected_opsize. If the receiving option length matches the +length with the data checksum, get the checksum value and save it in +mp_opt->csum. And in mptcp_incoming_options, pass it to mpext->csum. + +We always parse any csum/nocsum combination and delay the presence check +to later code, to allow reset if missing. + +Additionally, in the TX path, use the newly introduce ext field to avoid +MPTCP csum recomputation on TCP retransmission and unneeded csum update +on when setting the data fin_flag. + +Co-developed-by: Paolo Abeni +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From f9b610c1e999a2ca9e7a5f8220972226b7e81031 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:41:59 +0200 Subject: [PATCH 32/65] mptcp: receive checksum for MP_CAPABLE with data This patch added a new member named csum in struct mptcp_options_received. When parsing the MP_CAPABLE with data, if the checksum is enabled, adjust the expected_opsize. If the receiving option length matches the length with the data checksum, get the checksum value and save it in mp_opt->csum. And in mptcp_incoming_options, pass it to mpext->csum. We always parse any csum/nocsum combination and delay the presence check to later code, to allow reset if missing. Additionally, in the TX path, use the newly introduce ext field to avoid MPTCP csum recomputation on TCP retransmission and unneeded csum update on when setting the data fin_flag. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 ++- net/mptcp/options.c | 44 ++++++++++++++++++++++++++++++++------------ net/mptcp/protocol.h | 3 +++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 8f86c05ddbfd6..bd272c34b53c0 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -32,7 +32,8 @@ struct mptcp_ext { mpc_map:1, frozen:1, reset_transient:1; - u8 reset_reason:4; + u8 reset_reason:4, + csum_reqd:1; }; #define MPTCP_RM_IDS_MAX 8 diff --git a/net/mptcp/options.c b/net/mptcp/options.c index b86777b2b505f..1f267b34d78ed 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -37,17 +37,31 @@ static void mptcp_parse_option(const struct sock *sk, case MPTCPOPT_MP_CAPABLE: /* strict size checking */ if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) { - if (skb->len > tcp_hdr(skb)->doff << 2) + if (skb->len > tcp_hdr(skb)->doff << 2) { expected_opsize = TCPOLEN_MPTCP_MPC_ACK_DATA; - else + } else { expected_opsize = TCPOLEN_MPTCP_MPC_ACK; + } } else { if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) expected_opsize = TCPOLEN_MPTCP_MPC_SYNACK; else expected_opsize = TCPOLEN_MPTCP_MPC_SYN; } - if (opsize != expected_opsize) + + /* Cfr RFC 8684 Section 3.3.0: + * If a checksum is present but its use had + * not been negotiated in the MP_CAPABLE handshake, the receiver MUST + * close the subflow with a RST, as it is not behaving as negotiated. + * If a checksum is not present when its use has been negotiated, the + * receiver MUST close the subflow with a RST, as it is considered + * broken + * We parse even option with mismatching csum presence, so that + * later in subflow_data_ready we can trigger the reset. + */ + if (opsize != expected_opsize && + (expected_opsize != TCPOLEN_MPTCP_MPC_ACK_DATA || + opsize != TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM)) break; /* try to be gentle vs future versions on the initial syn */ @@ -69,11 +83,6 @@ static void mptcp_parse_option(const struct sock *sk, * host requires the use of checksums, checksums MUST be used. * In other words, the only way for checksums not to be used * is if both hosts in their SYNs set A=0." - * - * Section 3.3.0: - * "If a checksum is not present when its use has been - * negotiated, the receiver MUST close the subflow with a RST as - * it is considered broken." */ mp_opt->csum_reqd = READ_ONCE(msk->csum_enabled); if (flags & MPTCP_CAP_CHECKSUM_REQD) @@ -88,7 +97,7 @@ static void mptcp_parse_option(const struct sock *sk, mp_opt->rcvr_key = get_unaligned_be64(ptr); ptr += 8; } - if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA) { + if (opsize >= TCPOLEN_MPTCP_MPC_ACK_DATA) { /* Section 3.1.: * "the data parameters in a MP_CAPABLE are semantically * equivalent to those in a DSS option and can be used @@ -100,9 +109,14 @@ static void mptcp_parse_option(const struct sock *sk, mp_opt->data_len = get_unaligned_be16(ptr); ptr += 2; } - pr_debug("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d", + if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM) { + mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr); + mp_opt->csum_reqd = 1; + ptr += 2; + } + pr_debug("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u", version, flags, opsize, mp_opt->sndr_key, - mp_opt->rcvr_key, mp_opt->data_len); + mp_opt->rcvr_key, mp_opt->data_len, mp_opt->csum); break; case MPTCPOPT_MP_JOIN: @@ -538,7 +552,9 @@ static void mptcp_write_data_fin(struct mptcp_subflow_context *subflow, ext->data_len++; /* the pseudo header has changed, update the csum accordingly */ - csum_replace2(&ext->csum, htons(ext->data_len - 1), htons(ext->data_len)); + if (ext->csum_reqd) + csum_replace2(&ext->csum, htons(ext->data_len - 1), + htons(ext->data_len)); } } @@ -1124,6 +1140,10 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) } mpext->data_len = mp_opt.data_len; mpext->use_map = 1; + mpext->csum_reqd = mp_opt.csum_reqd; + + if (mpext->csum_reqd) + mpext->csum = mp_opt.csum; } } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b1d360a498a0e..c7cc9382bf779 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -68,6 +68,8 @@ #define TCPOLEN_MPTCP_FASTCLOSE 12 #define TCPOLEN_MPTCP_RST 4 +#define TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM (TCPOLEN_MPTCP_DSS_CHECKSUM + TCPOLEN_MPTCP_MPC_ACK_DATA) + /* MPTCP MP_JOIN flags */ #define MPTCPOPT_BACKUP BIT(0) #define MPTCPOPT_HMAC_LEN 20 @@ -124,6 +126,7 @@ struct mptcp_options_received { u64 data_seq; u32 subflow_seq; u16 data_len; + __sum16 csum; u16 mp_capable : 1, mp_join : 1, fastclose : 1, From 8888587ed3b82ffe453452ff1a27b589daee505a Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:54 +0200 Subject: [PATCH 33/65] tg create t/mptcp-receive-checksum-for-DSS base --- .topdeps | 1 - .topmsg | 21 --------------------- 2 files changed, 22 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 4706950657349..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-csum_reqd-in-mptcp_options_received diff --git a/.topmsg b/.topmsg deleted file mode 100644 index a9554080e9657..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,21 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: receive checksum for MP_CAPABLE with data - -This patch added a new member named csum in struct mptcp_options_received. - -When parsing the MP_CAPABLE with data, if the checksum is enabled, -adjust the expected_opsize. If the receiving option length matches the -length with the data checksum, get the checksum value and save it in -mp_opt->csum. And in mptcp_incoming_options, pass it to mpext->csum. - -We always parse any csum/nocsum combination and delay the presence check -to later code, to allow reset if missing. - -Additionally, in the TX path, use the newly introduce ext field to avoid -MPTCP csum recomputation on TCP retransmission and unneeded csum update -on when setting the data fin_flag. - -Co-developed-by: Paolo Abeni -Signed-off-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From dc1c79f376e6550082bfa344e44f6ec7d7c870ee Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:55 +0200 Subject: [PATCH 34/65] tg create t/mptcp-receive-checksum-for-DSS --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..3854ac57e65f1 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-receive-checksum-for-MP_CAPABLE-with-data diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..2aae9efc86ace --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-receive-checksum-for-DSS + +Signed-off-by: Matthieu Baerts From bfffbe5b56b4b9fa3b5601b4bc8265146352592d Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:56 +0200 Subject: [PATCH 35/65] tg import create t/mptcp-receive-checksum-for-DSS --- .topmsg | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 2aae9efc86ace..e79d1984c0f95 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,11 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-receive-checksum-for-DSS +From: Geliang Tang +Subject: [PATCH] mptcp: receive checksum for DSS -Signed-off-by: Matthieu Baerts +In mptcp_parse_option, adjust the expected_opsize, and always parse the +data checksum value from the receiving DSS regardless of csum presence. +Then save it in mp_opt->csum. + +Co-developed-by: Paolo Abeni +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From dcf392ee537c7aaabfcb8a96acfa7e5c6b52fe95 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:42:01 +0200 Subject: [PATCH 36/65] mptcp: receive checksum for DSS In mptcp_parse_option, adjust the expected_opsize, and always parse the data checksum value from the receiving DSS regardless of csum presence. Then save it in mp_opt->csum. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 1f267b34d78ed..3428c163299b4 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -37,11 +37,10 @@ static void mptcp_parse_option(const struct sock *sk, case MPTCPOPT_MP_CAPABLE: /* strict size checking */ if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) { - if (skb->len > tcp_hdr(skb)->doff << 2) { + if (skb->len > tcp_hdr(skb)->doff << 2) expected_opsize = TCPOLEN_MPTCP_MPC_ACK_DATA; - } else { + else expected_opsize = TCPOLEN_MPTCP_MPC_ACK; - } } else { if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) expected_opsize = TCPOLEN_MPTCP_MPC_SYNACK; @@ -188,10 +187,8 @@ static void mptcp_parse_option(const struct sock *sk, expected_opsize += TCPOLEN_MPTCP_DSS_MAP32; } - /* RFC 6824, Section 3.3: - * If a checksum is present, but its use had - * not been negotiated in the MP_CAPABLE handshake, - * the checksum field MUST be ignored. + /* Always parse any csum presence combination, we will enforce + * RFC 8684 Section 3.3.0 checks later in subflow_data_ready */ if (opsize != expected_opsize && opsize != expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) @@ -226,9 +223,15 @@ static void mptcp_parse_option(const struct sock *sk, mp_opt->data_len = get_unaligned_be16(ptr); ptr += 2; - pr_debug("data_seq=%llu subflow_seq=%u data_len=%u", + if (opsize == expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) { + mp_opt->csum_reqd = 1; + mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr); + ptr += 2; + } + + pr_debug("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u", mp_opt->data_seq, mp_opt->subflow_seq, - mp_opt->data_len); + mp_opt->data_len, mp_opt->csum_reqd, mp_opt->csum); } break; From ff73938272f1de98030e63f1a0ff7392b6695e3b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:58 +0200 Subject: [PATCH 37/65] tg create t/mptcp-validate-the-data-checksum base --- .topdeps | 1 - .topmsg | 11 ----------- 2 files changed, 12 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 3854ac57e65f1..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-receive-checksum-for-MP_CAPABLE-with-data diff --git a/.topmsg b/.topmsg deleted file mode 100644 index e79d1984c0f95..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,11 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: receive checksum for DSS - -In mptcp_parse_option, adjust the expected_opsize, and always parse the -data checksum value from the receiving DSS regardless of csum presence. -Then save it in mp_opt->csum. - -Co-developed-by: Paolo Abeni -Signed-off-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 3264595d950848bb81f38857488e467d45631dfb Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:58 +0200 Subject: [PATCH 38/65] tg create t/mptcp-validate-the-data-checksum --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..cc7a90dc7daf7 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-receive-checksum-for-DSS diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..3b5272c98558e --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-validate-the-data-checksum + +Signed-off-by: Matthieu Baerts From 9f6f1f40477630aec445f1ba2c2caef7c5beb566 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:57:59 +0200 Subject: [PATCH 39/65] tg import create t/mptcp-validate-the-data-checksum --- .topmsg | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 3b5272c98558e..b532509128725 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,31 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-validate-the-data-checksum +From: Paolo Abeni +Subject: [PATCH] mptcp: validate the data checksum -Signed-off-by: Matthieu Baerts +This patch added three new members named data_csum, csum_len and +map_csum in struct mptcp_subflow_context, implemented a new function +named mptcp_validate_data_checksum(). + +If the current mapping is valid and csum is enabled traverse the later +pending skbs and compute csum incrementally till the whole mapping has +been covered. If not enough data is available in the rx queue, return +MAPPING_EMPTY - that is, no data. + +Next subflow_data_ready invocation will trigger again csum computation. + +When the full DSS is available, validate the csum and return to the +caller an appropriate error code, to trigger subflow reset of fallback +as required by the RFC. + +Additionally: +- if the csum prevence in the DSS don't match the negotiated value e.g. + csum present, but not requested, return invalid mapping to trigger + subflow reset. +- keep some csum state, to avoid re-compute the csum on the same data + when multiple rx queue traversal are required. +- clean-up the uncompleted mapping from the receive queue on close, to + allow proper subflow disposal + +Co-developed-by: Geliang Tang +Signed-off-by: Geliang Tang +Reviewed-by: Mat Martineau +Signed-off-by: Paolo Abeni From ff6ab779b4900bd800bba7c9418ce209400e68cb Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Tue, 4 May 2021 23:42:03 +0200 Subject: [PATCH 40/65] mptcp: validate the data checksum This patch added three new members named data_csum, csum_len and map_csum in struct mptcp_subflow_context, implemented a new function named mptcp_validate_data_checksum(). If the current mapping is valid and csum is enabled traverse the later pending skbs and compute csum incrementally till the whole mapping has been covered. If not enough data is available in the rx queue, return MAPPING_EMPTY - that is, no data. Next subflow_data_ready invocation will trigger again csum computation. When the full DSS is available, validate the csum and return to the caller an appropriate error code, to trigger subflow reset of fallback as required by the RFC. Additionally: - if the csum prevence in the DSS don't match the negotiated value e.g. csum present, but not requested, return invalid mapping to trigger subflow reset. - keep some csum state, to avoid re-compute the csum on the same data when multiple rx queue traversal are required. - clean-up the uncompleted mapping from the receive queue on close, to allow proper subflow disposal Co-developed-by: Geliang Tang Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 4 ++ net/mptcp/subflow.c | 105 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 104 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a164f56e6a9d6..b35f473677b83 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1285,7 +1285,7 @@ static bool mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk) static void mptcp_update_data_checksum(struct sk_buff *skb, int added) { struct mptcp_ext *mpext = mptcp_get_ext(skb); - __wsum csum = csum_unfold(mpext->csum); + __wsum csum = ~csum_unfold(mpext->csum); int offset = skb->len - added; mpext->csum = csum_fold(csum_block_add(csum, skb_checksum(skb, offset, added, 0), offset)); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c7cc9382bf779..39ba2efc60e93 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -399,6 +399,8 @@ struct mptcp_subflow_context { u32 map_subflow_seq; u32 ssn_offset; u32 map_data_len; + __wsum map_data_csum; + u32 map_csum_len; u32 request_mptcp : 1, /* send MP_CAPABLE */ request_join : 1, /* send MP_JOIN */ request_bkup : 1, @@ -408,6 +410,8 @@ struct mptcp_subflow_context { pm_notified : 1, /* PM hook called for established status */ conn_finished : 1, map_valid : 1, + map_csum_reqd : 1, + map_data_fin : 1, mpc_map : 1, backup : 1, send_mp_prio : 1, diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index dd2668ffc7615..bdf461caa4f2d 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -828,10 +828,90 @@ static bool validate_mapping(struct sock *ssk, struct sk_buff *skb) return true; } +static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *skb, + bool csum_reqd) +{ + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); + struct csum_pseudo_header header; + u32 offset, seq, delta; + __wsum csum; + int len; + + if (!csum_reqd) + return MAPPING_OK; + + /* mapping already validated on previous traversal */ + if (subflow->map_csum_len == subflow->map_data_len) + return MAPPING_OK; + + /* traverse the receive queue, ensuring it contains a full + * DSS mapping and accumulating the related csum. + * Preserve the accoumlate csum across multiple calls, to compute + * the csum only once + */ + delta = subflow->map_data_len - subflow->map_csum_len; + for (;;) { + seq = tcp_sk(ssk)->copied_seq + subflow->map_csum_len; + offset = seq - TCP_SKB_CB(skb)->seq; + + /* if the current skb has not been accounted yet, csum its contents + * up to the amount covered by the current DSS + */ + if (offset < skb->len) { + __wsum csum; + + len = min(skb->len - offset, delta); + csum = skb_checksum(skb, offset, len, 0); + subflow->map_data_csum = csum_block_add(subflow->map_data_csum, csum, + subflow->map_csum_len); + + delta -= len; + subflow->map_csum_len += len; + } + if (delta == 0) + break; + + if (skb_queue_is_last(&ssk->sk_receive_queue, skb)) { + /* if this subflow is closed, the partial mapping + * will be never completed; flush the pending skbs, so + * that subflow_sched_work_if_closed() can kick in + */ + if (unlikely(ssk->sk_state == TCP_CLOSE)) + while ((skb = skb_peek(&ssk->sk_receive_queue))) + sk_eat_skb(ssk, skb); + + /* not enough data to validate the csum */ + return MAPPING_EMPTY; + } + + /* the DSS mapping for next skbs will be validated later, + * when a get_mapping_status call will process such skb + */ + skb = skb->next; + } + + /* note that 'map_data_len' accounts only for the carried data, does + * not include the eventual seq increment due to the data fin, + * while the pseudo header requires the original DSS data len, + * including that + */ + header.data_seq = cpu_to_be64(subflow->map_seq); + header.subflow_seq = htonl(subflow->map_subflow_seq); + header.data_len = htons(subflow->map_data_len + subflow->map_data_fin); + header.csum = 0; + + csum = csum_partial(&header, sizeof(header), subflow->map_data_csum); + if (unlikely(csum_fold(csum))) + return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; + + return MAPPING_OK; +} + static enum mapping_status get_mapping_status(struct sock *ssk, struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); + bool csum_reqd = READ_ONCE(msk->csum_enabled); struct mptcp_ext *mpext; struct sk_buff *skb; u16 data_len; @@ -925,9 +1005,10 @@ static enum mapping_status get_mapping_status(struct sock *ssk, /* Allow replacing only with an identical map */ if (subflow->map_seq == map_seq && subflow->map_subflow_seq == mpext->subflow_seq && - subflow->map_data_len == data_len) { + subflow->map_data_len == data_len && + subflow->map_csum_reqd == mpext->csum_reqd) { skb_ext_del(skb, SKB_EXT_MPTCP); - return MAPPING_OK; + goto validate_csum; } /* If this skb data are fully covered by the current mapping, @@ -939,17 +1020,27 @@ static enum mapping_status get_mapping_status(struct sock *ssk, } /* will validate the next map after consuming the current one */ - return MAPPING_OK; + goto validate_csum; } subflow->map_seq = map_seq; subflow->map_subflow_seq = mpext->subflow_seq; subflow->map_data_len = data_len; subflow->map_valid = 1; + subflow->map_data_fin = mpext->data_fin; subflow->mpc_map = mpext->mpc_map; - pr_debug("new map seq=%llu subflow_seq=%u data_len=%u", + subflow->map_csum_reqd = mpext->csum_reqd; + subflow->map_csum_len = 0; + subflow->map_data_csum = csum_unfold(mpext->csum); + + /* Cfr RFC 8684 Section 3.3.0 */ + if (unlikely(subflow->map_csum_reqd != csum_reqd)) + return MAPPING_INVALID; + + pr_debug("new map seq=%llu subflow_seq=%u data_len=%u csum=%d:%u", subflow->map_seq, subflow->map_subflow_seq, - subflow->map_data_len); + subflow->map_data_len, subflow->map_csum_reqd, + subflow->map_data_csum); validate_seq: /* we revalidate valid mapping on new skb, because we must ensure @@ -959,7 +1050,9 @@ static enum mapping_status get_mapping_status(struct sock *ssk, return MAPPING_INVALID; skb_ext_del(skb, SKB_EXT_MPTCP); - return MAPPING_OK; + +validate_csum: + return validate_data_csum(ssk, skb, csum_reqd); } static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb, From d703fb7dc9c33a9ec3e8b973362d2e2978e88610 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:01 +0200 Subject: [PATCH 41/65] tg create t/mptcp-cleanup-error-path-in-subflow_check_data_avail base --- .topdeps | 1 - .topmsg | 31 ------------------------------- 2 files changed, 32 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index cc7a90dc7daf7..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-receive-checksum-for-DSS diff --git a/.topmsg b/.topmsg deleted file mode 100644 index b532509128725..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,31 +0,0 @@ -From: Paolo Abeni -Subject: [PATCH] mptcp: validate the data checksum - -This patch added three new members named data_csum, csum_len and -map_csum in struct mptcp_subflow_context, implemented a new function -named mptcp_validate_data_checksum(). - -If the current mapping is valid and csum is enabled traverse the later -pending skbs and compute csum incrementally till the whole mapping has -been covered. If not enough data is available in the rx queue, return -MAPPING_EMPTY - that is, no data. - -Next subflow_data_ready invocation will trigger again csum computation. - -When the full DSS is available, validate the csum and return to the -caller an appropriate error code, to trigger subflow reset of fallback -as required by the RFC. - -Additionally: -- if the csum prevence in the DSS don't match the negotiated value e.g. - csum present, but not requested, return invalid mapping to trigger - subflow reset. -- keep some csum state, to avoid re-compute the csum on the same data - when multiple rx queue traversal are required. -- clean-up the uncompleted mapping from the receive queue on close, to - allow proper subflow disposal - -Co-developed-by: Geliang Tang -Signed-off-by: Geliang Tang -Reviewed-by: Mat Martineau -Signed-off-by: Paolo Abeni From b4878ba766737e46b22cfc9db382fa2f20c36f1e Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:02 +0200 Subject: [PATCH 42/65] tg create t/mptcp-cleanup-error-path-in-subflow_check_data_avail --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..4a46c152c2583 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-validate-the-data-checksum diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..9522c2944f639 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-cleanup-error-path-in-subflow_check_data_avail + +Signed-off-by: Matthieu Baerts From 43ae18db2044ff606cb7cb520267b3c5f97e9334 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:03 +0200 Subject: [PATCH 43/65] tg import create t/mptcp-cleanup-error-path-in-subflow_check_data_avail --- .topmsg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 9522c2944f639..721fb255ec14d 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,8 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-cleanup-error-path-in-subflow_check_data_avail +From: Paolo Abeni +Subject: [PATCH] mptcp: cleanup error path in subflow_check_data_avail() -Signed-off-by: Matthieu Baerts +Move fallback code out of the main loop and adds some +branch prediction annotations. + +Reviewed-by: Mat Martineau +Signed-off-by: Paolo Abeni From c30f4b417683f141d03a20d17a6b172d1ea996cc Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Tue, 4 May 2021 23:42:05 +0200 Subject: [PATCH 44/65] mptcp: cleanup error path in subflow_check_data_avail() Move fallback code out of the main loop and adds some branch prediction annotations. Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- net/mptcp/subflow.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index bdf461caa4f2d..331a24ae6a6f0 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1109,21 +1109,12 @@ static bool subflow_check_data_avail(struct sock *ssk) status = get_mapping_status(ssk, msk); trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); - if (status == MAPPING_INVALID) { + if (unlikely(status == MAPPING_INVALID)) { ssk->sk_err = EBADMSG; goto fatal; } - if (status == MAPPING_DUMMY) { - __mptcp_do_fallback(msk); - skb = skb_peek(&ssk->sk_receive_queue); - subflow->map_valid = 1; - subflow->map_seq = READ_ONCE(msk->ack_seq); - subflow->map_data_len = skb->len; - subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - - subflow->ssn_offset; - subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; - return true; - } + if (unlikely(status == MAPPING_DUMMY)) + goto fallback; if (status != MAPPING_OK) goto no_data; @@ -1167,6 +1158,7 @@ static bool subflow_check_data_avail(struct sock *ssk) no_data: subflow_sched_work_if_closed(msk, ssk); return false; + fatal: /* fatal protocol error, close the socket */ /* This barrier is coupled with smp_rmb() in tcp_poll() */ @@ -1178,6 +1170,16 @@ static bool subflow_check_data_avail(struct sock *ssk) tcp_send_active_reset(ssk, GFP_ATOMIC); subflow->data_avail = 0; return false; + +fallback: + __mptcp_do_fallback(msk); + skb = skb_peek(&ssk->sk_receive_queue); + subflow->map_valid = 1; + subflow->map_seq = READ_ONCE(msk->ack_seq); + subflow->map_data_len = skb->len; + subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; + subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; + return true; } bool mptcp_subflow_data_available(struct sock *sk) From d1fcbb01215fb881e3cce404cd84d5a45f9b6e20 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:05 +0200 Subject: [PATCH 45/65] tg create t/mptcp-tune-re-injections-for-csum-enabled-mode base --- .topdeps | 1 - .topmsg | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 4a46c152c2583..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-validate-the-data-checksum diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 721fb255ec14d..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,8 +0,0 @@ -From: Paolo Abeni -Subject: [PATCH] mptcp: cleanup error path in subflow_check_data_avail() - -Move fallback code out of the main loop and adds some -branch prediction annotations. - -Reviewed-by: Mat Martineau -Signed-off-by: Paolo Abeni From b46b98f9c49cdddb7bb9bf734571c007eca7390e Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:06 +0200 Subject: [PATCH 46/65] tg create t/mptcp-tune-re-injections-for-csum-enabled-mode --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..9cfd0b1a29120 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-cleanup-error-path-in-subflow_check_data_avail diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..06e7549622db9 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-tune-re-injections-for-csum-enabled-mode + +Signed-off-by: Matthieu Baerts From ac7a5e6c86fe6393c7543c349317232dfc61c441 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:07 +0200 Subject: [PATCH 47/65] tg import create t/mptcp-tune-re-injections-for-csum-enabled-mode --- .topmsg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 06e7549622db9..4caa77db061df 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,9 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-tune-re-injections-for-csum-enabled-mode +From: Paolo Abeni +Subject: [PATCH] mptcp: tune re-injections for csum enabled mode -Signed-off-by: Matthieu Baerts +If the MPTCP-level checksum is enabled, on re-injections we +must spool a complete DSS, or the receive side will not be +able to compute the csum and process any data. + +Reviewed-by: Mat Martineau +Signed-off-by: Paolo Abeni From 7929c266db79bbe4a1e765ddb9843db502518efa Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Tue, 4 May 2021 23:42:06 +0200 Subject: [PATCH 48/65] mptcp: tune re-injections for csum enabled mode If the MPTCP-level checksum is enabled, on re-injections we must spool a complete DSS, or the receive side will not be able to compute the csum and process any data. Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b35f473677b83..4e9dd6beb3635 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2333,8 +2333,8 @@ static void __mptcp_retrans(struct sock *sk) /* limit retransmission to the bytes already sent on some subflows */ info.sent = 0; - info.limit = dfrag->already_sent; - while (info.sent < dfrag->already_sent) { + info.limit = READ_ONCE(msk->csum_enabled) ? dfrag->data_len : dfrag->already_sent; + while (info.sent < info.limit) { if (!mptcp_alloc_tx_skb(sk, ssk)) break; @@ -2346,9 +2346,11 @@ static void __mptcp_retrans(struct sock *sk) copied += ret; info.sent += ret; } - if (copied) + if (copied) { + dfrag->already_sent = max(dfrag->already_sent, info.sent); tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, info.size_goal); + } mptcp_set_timeout(sk, ssk); release_sock(ssk); From 5dda8cfad11073ec590b536bbd2b21e59d06ab44 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:09 +0200 Subject: [PATCH 49/65] tg create t/mptcp-add-the-mib-for-data-checksum base --- .topdeps | 1 - .topmsg | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 9cfd0b1a29120..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-cleanup-error-path-in-subflow_check_data_avail diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 4caa77db061df..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,9 +0,0 @@ -From: Paolo Abeni -Subject: [PATCH] mptcp: tune re-injections for csum enabled mode - -If the MPTCP-level checksum is enabled, on re-injections we -must spool a complete DSS, or the receive side will not be -able to compute the csum and process any data. - -Reviewed-by: Mat Martineau -Signed-off-by: Paolo Abeni From 9a2987b12270147e23d02045b5a1a511f32f8afd Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:09 +0200 Subject: [PATCH 50/65] tg create t/mptcp-add-the-mib-for-data-checksum --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..245ffdf945c17 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-tune-re-injections-for-csum-enabled-mode diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..20cd163a7bd26 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-the-mib-for-data-checksum + +Signed-off-by: Matthieu Baerts From 83ee9f7dfa3390630d561c7e73f0ad9231e11974 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:10 +0200 Subject: [PATCH 51/65] tg import create t/mptcp-add-the-mib-for-data-checksum --- .topmsg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 20cd163a7bd26..4d1312ffab03f 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,8 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-the-mib-for-data-checksum +From: Geliang Tang +Subject: [PATCH] mptcp: add the mib for data checksum -Signed-off-by: Matthieu Baerts +This patch added the mib for the data checksum, MPTCP_MIB_DSSCSUMERR. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From b5cfe0de99249b04cc27e5f4f9fd4a520eaffb09 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:42:07 +0200 Subject: [PATCH 52/65] mptcp: add the mib for data checksum This patch added the mib for the data checksum, MPTCP_MIB_DSSCSUMERR. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/subflow.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index eb2dc6dbe212b..c7042e3317b52 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -25,6 +25,7 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC), SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH), SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX), + SNMP_MIB_ITEM("DSSCsumErr", MPTCP_MIB_DSSCSUMERR), SNMP_MIB_ITEM("OFOQueueTail", MPTCP_MIB_OFOQUEUETAIL), SNMP_MIB_ITEM("OFOQueue", MPTCP_MIB_OFOQUEUE), SNMP_MIB_ITEM("OFOMerge", MPTCP_MIB_OFOMERGE), diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index f0da4f060fe1a..c407358eced82 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -18,6 +18,7 @@ enum linux_mptcp_mib_field { MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */ MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */ MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */ + MPTCP_MIB_DSSCSUMERR, /* The DSS checksum fail */ MPTCP_MIB_OFOQUEUETAIL, /* Segments inserted into OoO queue tail */ MPTCP_MIB_OFOQUEUE, /* Segments inserted into OoO queue */ MPTCP_MIB_OFOMERGE, /* Segments merged in OoO queue */ diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 331a24ae6a6f0..f60a2fe1a2cf3 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -901,8 +901,10 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff * header.csum = 0; csum = csum_partial(&header, sizeof(header), subflow->map_data_csum); - if (unlikely(csum_fold(csum))) + if (unlikely(csum_fold(csum))) { + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSCSUMERR); return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY; + } return MAPPING_OK; } From d7f57c6398f982b033b492b767af2331c5b640ec Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:12 +0200 Subject: [PATCH 53/65] tg create t/mptcp-add-a-new-sysctl-checksum_enabled base --- .topdeps | 1 - .topmsg | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 245ffdf945c17..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-tune-re-injections-for-csum-enabled-mode diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 4d1312ffab03f..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,8 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add the mib for data checksum - -This patch added the mib for the data checksum, MPTCP_MIB_DSSCSUMERR. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From d36d16a95895f716ef2086794ffa59448e0bbbba Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:13 +0200 Subject: [PATCH 54/65] tg create t/mptcp-add-a-new-sysctl-checksum_enabled --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..05f93c9fb110b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-the-mib-for-data-checksum diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..20f05f495fb2a --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-a-new-sysctl-checksum_enabled + +Signed-off-by: Matthieu Baerts From 72dbd97fb353941fb5a3932ade38226069954cd0 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:14 +0200 Subject: [PATCH 55/65] tg import create t/mptcp-add-a-new-sysctl-checksum_enabled --- .topmsg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 20f05f495fb2a..f5538b21f9290 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,9 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-a-new-sysctl-checksum_enabled +From: Geliang Tang +Subject: [PATCH] mptcp: add a new sysctl checksum_enabled -Signed-off-by: Matthieu Baerts +This patch added a new sysctl, named checksum_enabled, to control +whether DSS checksum can be enabled. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From caf02cd7505b783c85026422fa56a35b773ba494 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:42:08 +0200 Subject: [PATCH 56/65] mptcp: add a new sysctl checksum_enabled This patch added a new sysctl, named checksum_enabled, to control whether DSS checksum can be enabled. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- Documentation/networking/mptcp-sysctl.rst | 8 ++++++++ net/mptcp/ctrl.c | 14 ++++++++++++++ net/mptcp/protocol.h | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst index 3b352e5f6300c..901fa3e4650f2 100644 --- a/Documentation/networking/mptcp-sysctl.rst +++ b/Documentation/networking/mptcp-sysctl.rst @@ -24,3 +24,11 @@ add_addr_timeout - INTEGER (seconds) sysctl. Default: 120 + +checksum_enabled - INTEGER + Control whether DSS checksum can be enabled. + + DSS checksum can be enabled if the value is nonzero. This is a + per-namespace sysctl. + + Default: 0 diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 1ec4d36a39f05..014752c481d00 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -23,6 +23,7 @@ struct mptcp_pernet { u8 mptcp_enabled; unsigned int add_addr_timeout; + int checksum_enabled; }; static struct mptcp_pernet *mptcp_get_pernet(struct net *net) @@ -44,9 +45,15 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) { pernet->mptcp_enabled = 1; pernet->add_addr_timeout = TCP_RTO_MAX; + pernet->checksum_enabled = 0; } #ifdef CONFIG_SYSCTL +int mptcp_is_checksum_enabled(struct net *net) +{ + return mptcp_get_pernet(net)->checksum_enabled; +} + static struct ctl_table mptcp_sysctl_table[] = { { .procname = "enabled", @@ -65,6 +72,12 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, + { + .procname = "checksum_enabled", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, {} }; @@ -82,6 +95,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[0].data = &pernet->mptcp_enabled; table[1].data = &pernet->add_addr_timeout; + table[2].data = &pernet->checksum_enabled; hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table); if (!hdr) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 39ba2efc60e93..98c735f237b46 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -541,7 +541,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *su int mptcp_is_enabled(struct net *net); unsigned int mptcp_get_add_addr_timeout(struct net *net); -static inline int mptcp_is_checksum_enabled(struct net *net) { return false; } +int mptcp_is_checksum_enabled(struct net *net); void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, struct mptcp_options_received *mp_opt); bool mptcp_subflow_data_available(struct sock *sk); From db5affd1c5718eb4c20d4a57425c46ac55235176 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:16 +0200 Subject: [PATCH 57/65] tg create t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh base --- .topdeps | 1 - .topmsg | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 05f93c9fb110b..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-the-mib-for-data-checksum diff --git a/.topmsg b/.topmsg deleted file mode 100644 index f5538b21f9290..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,9 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add a new sysctl checksum_enabled - -This patch added a new sysctl, named checksum_enabled, to control -whether DSS checksum can be enabled. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From da53590c52d8716a3610c8e2dd382428710a8721 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:16 +0200 Subject: [PATCH 58/65] tg create t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..4c1156ec90312 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-a-new-sysctl-checksum_enabled diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..490a701d32315 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh + +Signed-off-by: Matthieu Baerts From 20db3564983665e0c1b1575d3d5f121572be6524 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:18 +0200 Subject: [PATCH 59/65] tg import create t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh --- .topmsg | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 490a701d32315..951b5d95426d4 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,10 @@ -From: Matthieu Baerts -Subject: [PATCH] t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh +From: Geliang Tang +Subject: [PATCH] selftests: mptcp: enable checksum in mptcp_connect.sh -Signed-off-by: Matthieu Baerts +This patch added a new argument "-C" for the mptcp_connect.sh script to +set the sysctl checksum_enabled to 1 in ns1, ns2, ns3 and ns4 to enable +the data checksum. + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From c8a3478e7ecbdb658512385a50a478b2ca50715d Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:42:09 +0200 Subject: [PATCH 60/65] selftests: mptcp: enable checksum in mptcp_connect.sh This patch added a new argument "-C" for the mptcp_connect.sh script to set the sysctl checksum_enabled to 1 in ns1, ns2, ns3 and ns4 to enable the data checksum. Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 9236609731b18..96cec8c2d9754 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -3,7 +3,7 @@ time_start=$(date +%s) -optstring="S:R:d:e:l:r:h4cm:f:t" +optstring="S:R:d:e:l:r:h4cm:f:tC" ret=0 sin="" sout="" @@ -22,6 +22,7 @@ sndbuf=0 rcvbuf=0 options_log=true do_tcp=0 +checksum=false filesize=0 if [ $tc_loss -eq 100 ];then @@ -47,6 +48,7 @@ usage() { echo -e "\t-R: set rcvbuf value (default: use kernel default)" echo -e "\t-m: test mode (poll, sendfile; default: poll)" echo -e "\t-t: also run tests with TCP (use twice to non-fallback tcp)" + echo -e "\t-C: enable the MPTCP data checksum" } while getopts "$optstring" option;do @@ -104,6 +106,9 @@ while getopts "$optstring" option;do "t") do_tcp=$((do_tcp+1)) ;; + "C") + checksum=true + ;; "?") usage $0 exit 1 @@ -200,6 +205,12 @@ ip -net "$ns4" route add default via dead:beef:3::2 # use TCP syn cookies, even if no flooding was detected. ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2 +if $checksum; then + for i in "$ns1" "$ns2" "$ns3" "$ns4";do + ip netns exec $i sysctl -q net.mptcp.checksum_enabled=1 + done +fi + set_ethtool_flags() { local ns="$1" local dev="$2" From 6d80ca02edcb93c869d4a18067c3d97fbb4b893b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:19 +0200 Subject: [PATCH 61/65] tg create t/selftests-mptcp-enable-checksum-in-mptcp_join.sh base --- .topdeps | 1 - .topmsg | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 4c1156ec90312..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-a-new-sysctl-checksum_enabled diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 951b5d95426d4..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,10 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] selftests: mptcp: enable checksum in mptcp_connect.sh - -This patch added a new argument "-C" for the mptcp_connect.sh script to -set the sysctl checksum_enabled to 1 in ns1, ns2, ns3 and ns4 to enable -the data checksum. - -Acked-by: Paolo Abeni -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From df83fd404e300b090f0297ee35620e8baca2a91c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:20 +0200 Subject: [PATCH 62/65] tg create t/selftests-mptcp-enable-checksum-in-mptcp_join.sh --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..09afcaca8c5c9 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/selftests-mptcp-enable-checksum-in-mptcp_connect.sh diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..f720aa2e95187 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/selftests-mptcp-enable-checksum-in-mptcp_join.sh + +Signed-off-by: Matthieu Baerts From d4ddde4dee05a591dfd16160ac80f0cf455e57a7 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:21 +0200 Subject: [PATCH 63/65] tg import create t/selftests-mptcp-enable-checksum-in-mptcp_join.sh --- .topmsg | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index f720aa2e95187..b23977aa14e95 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,31 @@ -From: Matthieu Baerts -Subject: [PATCH] t/selftests-mptcp-enable-checksum-in-mptcp_join.sh +From: Geliang Tang +Subject: [PATCH] selftests: mptcp: enable checksum in mptcp_join.sh -Signed-off-by: Matthieu Baerts +This patch added a new argument "-C" for the mptcp_join.sh script to set +the sysctl checksum_enabled to 1 in ns1 and ns2 to enable the data +checksum. + +In chk_join_nr, check the counter of the mib for the data checksum. + +Also added a new argument "-S" for the mptcp_join.sh script to start the +test cases that verify the checksum handshake: + + * Sender and listener both have checksums off + * Sender and listener both have checksums on + * Sender checksums off, listener checksums on + * Sender checksums on, listener checksums off + +The output looks like this: + + 01 checksum test 0 0 sum[ ok ] - csum [ ok ] + 02 checksum test 1 1 sum[ ok ] - csum [ ok ] + 03 checksum test 0 1 sum[ ok ] - csum [ ok ] + 04 checksum test 1 0 sum[ ok ] - csum [ ok ] + 05 no JOIN syn[ ok ] - synack[ ok ] - ack[ ok ] + sum[ ok ] - csum [ ok ] + 06 single subflow, limited by client syn[ ok ] - synack[ ok ] - ack[ ok ] + sum[ ok ] - csum [ ok ] + +Acked-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From ed46f07923ab982e717497c1d40fece465181118 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 4 May 2021 23:42:10 +0200 Subject: [PATCH 64/65] selftests: mptcp: enable checksum in mptcp_join.sh This patch added a new argument "-C" for the mptcp_join.sh script to set the sysctl checksum_enabled to 1 in ns1 and ns2 to enable the data checksum. In chk_join_nr, check the counter of the mib for the data checksum. Also added a new argument "-S" for the mptcp_join.sh script to start the test cases that verify the checksum handshake: * Sender and listener both have checksums off * Sender and listener both have checksums on * Sender checksums off, listener checksums on * Sender checksums on, listener checksums off The output looks like this: 01 checksum test 0 0 sum[ ok ] - csum [ ok ] 02 checksum test 1 1 sum[ ok ] - csum [ ok ] 03 checksum test 0 1 sum[ ok ] - csum [ ok ] 04 checksum test 1 0 sum[ ok ] - csum [ ok ] 05 no JOIN syn[ ok ] - synack[ ok ] - ack[ ok ] sum[ ok ] - csum [ ok ] 06 single subflow, limited by client syn[ ok ] - synack[ ok ] - ack[ ok ] sum[ ok ] - csum [ ok ] Acked-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 107 +++++++++++++++++- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index fd99485cf2a4a..ef8341c851f78 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -12,6 +12,7 @@ timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) mptcp_connect="" capture=0 +checksum=0 do_all_tests=1 TEST_COUNT=0 @@ -49,6 +50,9 @@ init() ip netns exec $netns sysctl -q net.mptcp.enabled=1 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 + if [ $checksum -eq 1 ]; then + ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 + fi done # ns1 ns2 @@ -124,6 +128,17 @@ reset_with_add_addr_timeout() -j DROP } +reset_with_checksum() +{ + local ns1_enable=$1 + local ns2_enable=$2 + + reset + + ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable + ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable +} + ip -Version > /dev/null 2>&1 if [ $? -ne 0 ];then echo "SKIP: Could not run test without ip tool" @@ -476,6 +491,45 @@ run_tests() fi } +chk_csum_nr() +{ + local msg=${1:-""} + local count + local dump_stats + + if [ ! -z "$msg" ]; then + printf "%02u" "$TEST_COUNT" + else + echo -n " " + fi + printf " %-36s %s" "$msg" "sum" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtDSSCsumErr | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != 0 ]; then + echo "[fail] got $count data checksum error[s] expected 0" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + echo -n " - csum " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtDSSCsumErr | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != 0 ]; then + echo "[fail] got $count data checksum error[s] expected 0" + 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" @@ -523,6 +577,9 @@ chk_join_nr() echo Client ns stats ip netns exec $ns2 nstat -as | grep MPTcp fi + if [ $checksum -eq 1 ]; then + chk_csum_nr + fi } chk_add_nr() @@ -1374,6 +1431,37 @@ syncookies_tests() chk_add_nr 1 1 } +checksum_tests() +{ + # checksum test 0 0 + reset_with_checksum 0 0 + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + run_tests $ns1 $ns2 10.0.1.1 + chk_csum_nr "checksum test 0 0" + + # checksum test 1 1 + reset_with_checksum 1 1 + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + run_tests $ns1 $ns2 10.0.1.1 + chk_csum_nr "checksum test 1 1" + + # checksum test 0 1 + reset_with_checksum 0 1 + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + run_tests $ns1 $ns2 10.0.1.1 + chk_csum_nr "checksum test 0 1" + + # checksum test 1 0 + reset_with_checksum 1 0 + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns2 ./pm_nl_ctl limits 0 1 + run_tests $ns1 $ns2 10.0.1.1 + chk_csum_nr "checksum test 1 0" +} + all_tests() { subflows_tests @@ -1387,6 +1475,7 @@ all_tests() backup_tests add_addr_ports_tests syncookies_tests + checksum_tests } usage() @@ -1403,7 +1492,9 @@ usage() echo " -b backup_tests" echo " -p add_addr_ports_tests" echo " -k syncookies_tests" + echo " -S checksum_tests" echo " -c capture pcap files" + echo " -C enable data checksum" echo " -h help" } @@ -1418,13 +1509,16 @@ make_file "$sin" "server" 1 trap cleanup EXIT for arg in "$@"; do - # check for "capture" arg before launching tests + # check for "capture/checksum" args before launching tests if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"c"[0-9a-zA-Z]*$ ]]; then capture=1 fi + if [[ "${arg}" =~ ^"-"[0-9a-zA-Z]*"C"[0-9a-zA-Z]*$ ]]; then + checksum=1 + fi - # exception for the capture option, the rest means: a part of the tests - if [ "${arg}" != "-c" ]; then + # exception for the capture/checksum options, the rest means: a part of the tests + if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ]; then do_all_tests=0 fi done @@ -1434,7 +1528,7 @@ if [ $do_all_tests -eq 1 ]; then exit $ret fi -while getopts 'fsltra64bpkch' opt; do +while getopts 'fsltra64bpkchCS' opt; do case $opt in f) subflows_tests @@ -1469,8 +1563,13 @@ while getopts 'fsltra64bpkch' opt; do k) syncookies_tests ;; + S) + checksum_tests + ;; c) ;; + C) + ;; h | *) usage ;; From 9eb3a63833fc5a43b7c7b0eaa904919bce7debee Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Thu, 6 May 2021 08:58:23 +0200 Subject: [PATCH 65/65] tg: switch to t/selftests-mptcp-enable-checksum-in-mptcp_join.sh Signed-off-by: Matthieu Baerts --- .topdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.topdeps b/.topdeps index c71c578531c31..c70c7f6259fc3 100644 --- a/.topdeps +++ b/.topdeps @@ -1 +1 @@ -t/mptcp-restrict-values-of-enabled-sysctl +t/selftests-mptcp-enable-checksum-in-mptcp_join.sh