The infinite mapping support
Subsystems (3)
v3 cover The infinite mapping support
v3:
- drop MPTCP_INFINITE_DONE flag
- drop MAPPING_INFINITE
- add mptcp_is_data_contiguous helper
- add the fallback check
- The u32 target testcase has not been completed yet.
v2:
- add MPTCP_INFINITE_DONE flag
- add MAPPING_INFINITE mapping status
- add start_seq in the msk
v1:
- add noncontiguous flag
- add the mibs check
- tag: export/20210904T080009
Geliang Tang (8):
mptcp: add mptcp_is_data_contiguous helper
mptcp: add start_seq in the msk
mptcp: infinite mapping sending
mptcp: add the fallback check
mptcp: infinite mapping receiving
mptcp: add mib for infinite map sending
selftests: mptcp: add infinite map mibs check
DO-NOT-MERGE: mptcp: mp_fail test
include/net/mptcp.h | 3 +- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/options.c | 6 +- net/mptcp/pm.c | 6 ++ net/mptcp/protocol.c | 35 ++++++++++++ net/mptcp/protocol.h | 19 +++++++ net/mptcp/subflow.c | 55 +++++++++--------- .../testing/selftests/net/mptcp/mptcp_join.sh | 56 +++++++++++++++++++ 9 files changed, 153 insertions(+), 29 deletions(-)
Signature · 1 line
2.31.1
PATCH v3 1/8 mptcp: add mptcp_is_data_contiguous helper
This patch added a new member last_retrans_seq in the msk to track the last retransmitting sequence number.
Add a new helper named mptcp_is_data_contiguous() to check whether the data is contiguous on a subflow.
When a bad checksum is detected and a single contiguous subflow is in use, don't send RST + MP_FAIL, send data_ack + MP_FAIL instead.
--- net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 6 ++++++ net/mptcp/subflow.c | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +3 -0
@@ -2464,6 +2464,7 @@ static void __mptcp_retrans(struct sock *sk) dfrag->already_sent =max (dfrag->already_sent, info.sent);tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, info.size_goal); + msk->last_retrans_seq = dfrag->data_seq; }release_sock (ssk);
@@ -2889,6 +2890,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->snd_una = msk->write_seq; msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq =mptcp_sk (sk)->setsockopt_seq; + msk->last_retrans_seq = subflow_req->idsn -1 ;if (mp_opt->suboptions &OPTIONS_MPTCP_MPC ) { msk->can_ack = true;
@@ -3145,6 +3147,7 @@ void mptcp_finish_connect(struct sock *ssk)WRITE_ONCE (msk->rcv_wnd_sent, ack_seq);WRITE_ONCE (msk->can_ack,1 );WRITE_ONCE (msk->snd_una, msk->write_seq); +WRITE_ONCE (msk->last_retrans_seq, subflow->idsn -1 );mptcp_pm_new_connection (msk, ssk,0 );
net/mptcp/protocol.h +6 -0
@@ -227,6 +227,7 @@ struct mptcp_sock {u64 ack_seq;u64 rcv_wnd_sent;u64 rcv_data_fin_seq; +u64 last_retrans_seq;int wmem_reserved;struct sock *last_snd;int snd_burst;
@@ -625,6 +626,11 @@ static inline bool mptcp_has_another_subflow(struct sock *ssk)return false; } +static inline bool mptcp_is_data_contiguous (struct mptcp_sock *msk) +{ +return before64 (msk->last_retrans_seq, msk->snd_una); +} +void __init mptcp_proto_init (void );#if IS_ENABLED (CONFIG_MPTCP_IPV6 )int __init mptcp_proto_v6_init (void );
net/mptcp/subflow.c +6 -6
@@ -1166,15 +1166,15 @@ static bool subflow_check_data_avail(struct sock *ssk) fallback:/* RFC 8684 section 3.7. */ if (subflow->send_mp_fail) { -if (mptcp_has_another_subflow (ssk)) { +if (mptcp_has_another_subflow (ssk) || !mptcp_is_data_contiguous (msk)) { + ssk->sk_err =EBADMSG ; +tcp_set_state (ssk,TCP_CLOSE ); + subflow->reset_transient =0 ; + subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; +tcp_send_active_reset (ssk,GFP_ATOMIC );while ((skb =skb_peek (&ssk->sk_receive_queue)))sk_eat_skb (ssk, skb); } - ssk->sk_err =EBADMSG ; -tcp_set_state (ssk,TCP_CLOSE ); - subflow->reset_transient =0 ; - subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; -tcp_send_active_reset (ssk,GFP_ATOMIC );WRITE_ONCE (subflow->data_avail,0 );return true; }
Signature · 1 line
2.31.1
Paolo Abeni
maintainerRe: [PATCH mptcp-next v3 1/8] mptcp: add mptcp_is_data_contiguous helper
Quoted 84 lines · Geliang Tang
This patch added a new member
last_retrans_seqin the msk to track the last retransmitting sequence number.Add a new helper named
mptcp_is_data_contiguous()to check whether the data is contiguous on a subflow.When a bad checksum is detected and a single contiguous subflow is in use, don't send RST +
MP_FAIL, senddata_ack+MP_FAILinstead.Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 6 ++++++ net/mptcp/subflow.c | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-)net/mptcp/protocol.c +3
-0@@ -2464,6 +2464,7 @@ static void __mptcp_retrans(struct sock *sk) dfrag->already_sent =max (dfrag->already_sent, info.sent);tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, info.size_goal); + msk-> = dfrag->data_seq; }release_sock (ssk);@@ -2889,6 +2890,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->snd_una = msk->write_seq; msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq =mptcp_sk (sk)->setsockopt_seq; + msk->last_retrans_seq = subflow_req->idsn -1 ;if (mp_opt->suboptions &OPTIONS_MPTCP_MPC ) { msk->can_ack = true;@@ -3145,6 +3147,7 @@ void mptcp_finish_connect(struct sock *ssk)WRITE_ONCE (msk->rcv_wnd_sent, ack_seq);WRITE_ONCE (msk->can_ack,1 );WRITE_ONCE (msk->snd_una, msk->write_seq); +WRITE_ONCE (msk->last_retrans_seq, subflow->idsn -1 );mptcp_pm_new_connection (msk, ssk,0 );net/mptcp/protocol.h +6
-0@@ -227,6 +227,7 @@ struct mptcp_sock {u64 ack_seq;u64 rcv_wnd_sent;u64 rcv_data_fin_seq; +u64 last_retrans_seq;int wmem_reserved;struct sock *last_snd;int snd_burst;@@ -625,6 +626,11 @@ static inline bool mptcp_has_another_subflow(struct sock *ssk)return false; } +static inline bool mptcp_is_data_contiguous (struct mptcp_sock *msk) +{ +return before64 (msk->last_retrans_seq, msk->snd_una); +} +void __init mptcp_proto_init (void );#if IS_ENABLED (CONFIG_MPTCP_IPV6 )int __init mptcp_proto_v6_init (void );net/mptcp/subflow.c +6
-1@@ -1166,15 +1166,15 @@ static bool subflow_check_data_avail(struct sock *ssk) fallback:/* RFC 8684 section 3.7. */ if (subflow->send_mp_fail) { -if (mptcp_has_another_subflow (ssk)) { +if (mptcp_has_another_subflow (ssk) || !mptcp_is_data_contiguous (msk)) { + ssk->sk_err =EBADMSG ; +tcp_set_state (ssk,TCP_CLOSE ); + subflow->reset_transient =0 ; + subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; +tcp_send_active_reset (ssk,GFP_ATOMIC );while ((skb =skb_peek (&ssk->sk_receive_queue)))
net/mptcp/subflow.c static bool subflow_check_data_avail(struct sock *ssk) · line 1180
Quoted 10 lines
net/mptcp/subflow.c +0
-5sk_eat_skb (ssk, skb); } - ssk->sk_err =EBADMSG ; -tcp_set_state (ssk,TCP_CLOSE ); - subflow->reset_transient =0 ; - subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; -tcp_send_active_reset (ssk,GFP_ATOMIC );WRITE_ONCE (subflow->data_avail,0 );return true; }
As noted by Mat, to avoid wrap-around on 'last_retrans_seq', we also need to updated it in mptcp_clean_una, something alike:
net/mptcp/protocol.c +0 -0
indexbb8a2a231479..cc3534052227 100644
--- a/net/mptcp/protocol.c
+++b/net/mptcp/protocol.c
@@ -1102,8 +1102,13 @@ static void__mptcp_clean_una(struct sock *sk)
msk->recovery =
false;
out:
- if (cleaned && tcp_under_memory_pressure(sk))
-
__mptcp_mem_reclaim_partial(sk);
+ if (cleaned) {
+
if (mptcp_is_data_contiguous(msk))
+ msk-
Quoted 1 line
last_retrans_seq=msk->snd_una- 1;
+
+ if
(tcp_under_memory_pressure(sk))
+ __mptcp_mem_reclaim_partial(sk);
+ }
if (snd_una == READ_ONCE(msk-
Quoted 1 line
snd_nxt) && !msk->recovery) {
/P
Re: [PATCH mptcp-next v3 1/8] mptcp: add mptcp_is_data_contiguous helper
Hi Geliang -
This patch changes more than the helper function, I suggest a subject like "mptcp: Track and update contiguous data status"
Quoted 17 lines · Paolo Abeni
Quoted 16 lines · Geliang Tang
This patch added a new member
last_retrans_seqin the msk to track the last retransmitting sequence number.Add a new helper named
mptcp_is_data_contiguous()to check whether the data is contiguous on a subflow.When a bad checksum is detected and a single contiguous subflow is in use, don't send RST +
MP_FAIL, senddata_ack+MP_FAILinstead.Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 6 ++++++ net/mptcp/subflow.c | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-)
Quoted 9 lines
net/mptcp/protocol.c static void __mptcp_retrans(struct sock *sk) · line 2467
Quoted 9 lines
net/mptcp/protocol.c +1
-0@@ -2464,6 +2464,7 @@ static void __mptcp_retrans(struct sock *sk) dfrag->already_sent =max (dfrag->already_sent, info.sent);tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, info.size_goal); + msk->last_retrans_seq = dfrag->data_seq;
If this last_retrans_seq technique is going to work with multiple retransmissions, I think the last_retrans_seq assignment would need to look like:
retrans_seq = dfrag->data_seq + info.set;
if (after64(retrans_seq, msk->last_retrans_seq))
msk->last_retrans_seq = retrans_seq;
This keeps track of the end of the retransmitted data.
As I think about what could happen with multiple retransmissions, I'm not sure it's enough to only track only a MPTCP-level sequence number to determine a subflow stream is contiguous. See below.
Quoted 35 lines
Quoted 35 lines
net/mptcp/protocol.c +2
-0}release_sock (ssk);@@ -2889,6 +2890,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->snd_una = msk->write_seq; msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq =mptcp_sk (sk)->setsockopt_seq; + msk->last_retrans_seq = subflow_req->idsn -1 ;if (mp_opt->suboptions &OPTIONS_MPTCP_MPC ) { msk->can_ack = true;@@ -3145,6 +3147,7 @@ void mptcp_finish_connect(struct sock *ssk)WRITE_ONCE (msk->rcv_wnd_sent, ack_seq);WRITE_ONCE (msk->can_ack,1 );WRITE_ONCE (msk->snd_una, msk->write_seq); +WRITE_ONCE (msk->last_retrans_seq, subflow->idsn -1 );mptcp_pm_new_connection (msk, ssk,0 );net/mptcp/protocol.h +1
-0@@ -227,6 +227,7 @@ struct mptcp_sock {u64 ack_seq;u64 rcv_wnd_sent;u64 rcv_data_fin_seq; +u64 last_retrans_seq;int wmem_reserved;struct sock *last_snd;int snd_burst;@@ -625,6 +626,11 @@ static inline bool mptcp_has_another_subflow(struct sock *ssk)return false; }
Quoted 4 lines
net/mptcp/protocol.h static inline bool mptcp_has_another_subflow(struct sock *ssk) · line 632
Quoted 4 lines
net/mptcp/protocol.h +4
-0+static inline bool mptcp_is_data_contiguous (struct mptcp_sock *msk) +{ +return before64 (msk->last_retrans_seq, msk->snd_una); +}
Paolo, do you think this holds true even when there are multiple retransmissions in flight?
Consider:
1. We have a connection with two active subflows, A & B
2. Data is sent on both subflows (say, with round robin scheduling)
3. Some data is sent on subflow A, but the subflow goes stale and that data does not get to the peer.
4. MPTCP-level timeout happens, data is retransmitted on subflow B.
5. Subflow A is closed, MPTCP connection is now single-subflow
6. Subflow B data is delayed (TCP retransmissions, maybe?), and MPTCP retransmits again with identical MPTCP-level sequence numbers.
7. Finally, an MPTCP DATA_ACK arrives on subflow B based on our first retransmission. snd_una has caught up to last_retrans_seq at the MPTCP level.
8. Then we get a checksum error and need to send MP_FAIL.
At this point, there is still retransmitted data in flight. If we send a TCP ACK with a DSS_ACK + MP_FAIL that could be processed by the peer before the in-flight retransmitted data, and out-of-sequence data could get in to the MPTCP-level stream.
While this is not going to happen frequently, it doesn't seem impossible (do correct me if I'm wrong!).
The earlier "track number of retransmissions in mptcp_data_frag" would catch this, but there are other alternatives. What about tracking the 32-bit TCP sequence number for the end of the last retransmission, using a field in each subflow context? While it is a few extra bytes of memory per subflow instead of per-MPTCP-connection, it's no more execution time to keep it updated.
WDYT?
Quoted 55 lines
Quoted 20 lines
net/mptcp/protocol.h +1
-0+void __init mptcp_proto_init (void );#if IS_ENABLED (CONFIG_MPTCP_IPV6 )int __init mptcp_proto_v6_init (void );net/mptcp/subflow.c +6
-1@@ -1166,15 +1166,15 @@ static bool subflow_check_data_avail(struct sock *ssk) fallback:/* RFC 8684 section 3.7. */ if (subflow->send_mp_fail) { -if (mptcp_has_another_subflow (ssk)) { +if (mptcp_has_another_subflow (ssk) || !mptcp_is_data_contiguous (msk)) { + ssk->sk_err =EBADMSG ; +tcp_set_state (ssk,TCP_CLOSE ); + subflow->reset_transient =0 ; + subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; +tcp_send_active_reset (ssk,GFP_ATOMIC );while ((skb =skb_peek (&ssk->sk_receive_queue)))net/mptcp/subflow.c static bool subflow_check_data_avail(struct sock *ssk) · line 1180
Quoted 10 lines
net/mptcp/subflow.c +0
-5sk_eat_skb (ssk, skb); } - ssk->sk_err =EBADMSG ; -tcp_set_state (ssk,TCP_CLOSE ); - subflow->reset_transient =0 ; - subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; -tcp_send_active_reset (ssk,GFP_ATOMIC );WRITE_ONCE (subflow->data_avail,0 );return true; }As noted by Mat, to avoid wrap-around on '
last_retrans_seq', we also need to updated it inmptcp_clean_una, something alike:net/mptcp/protocol.c +0
-0@@ -1102,8 +1102,13 @@ static void __mptcp_clean_una(struct sock *sk) msk->recovery = false;out:
net/mptcp/protocol.c +7
-2-if (cleaned &&tcp_under_memory_pressure (sk)) -__mptcp_mem_reclaim_partial (sk); +if (cleaned) { +if (mptcp_is_data_contiguous (msk)) + msk->last_retrans_seq = msk->snd_una -1 ; + +if (tcp_under_memory_pressure (sk)) +__mptcp_mem_reclaim_partial (sk); + }if (snd_una ==READ_ONCE (msk-> snd_nxt) && !msk->recovery) {
Quoted 1 line
/P
Paolo's diff got line-wrapped strangely on the mailing list, I tried to fix it up above.
--
Mat Martineau
Intel
PATCH v3 2/8 mptcp: add start_seq in the msk
In reply to Geliang TangThis patch added a new member named start_seq to the msk to keep track of the beginning of the last fully-acked data segment. This would be updated in __mptcp_clean_una.
--- net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 1 + 2 files changed, 4 insertions(+)
net/mptcp/protocol.c +3 -0
@@ -1071,6 +1071,7 @@ static void __mptcp_clean_una(struct sock *sk)WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); } + msk->start_seq = dfrag->data_seq;dfrag_clear (sk, dfrag); cleaned = true; }
@@ -2891,6 +2892,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq =mptcp_sk (sk)->setsockopt_seq; msk->last_retrans_seq = subflow_req->idsn -1 ; + msk->start_seq =0 ;if (mp_opt->suboptions &OPTIONS_MPTCP_MPC ) { msk->can_ack = true;
@@ -3148,6 +3150,7 @@ void mptcp_finish_connect(struct sock *ssk)WRITE_ONCE (msk->can_ack,1 );WRITE_ONCE (msk->snd_una, msk->write_seq);WRITE_ONCE (msk->last_retrans_seq, subflow->idsn -1 ); +WRITE_ONCE (msk->start_seq,0 );mptcp_pm_new_connection (msk, ssk,0 );
net/mptcp/protocol.h +1 -0
@@ -224,6 +224,7 @@ struct mptcp_sock {u64 remote_key;u64 write_seq;u64 snd_nxt; +u64 start_seq;u64 ack_seq;u64 rcv_wnd_sent;u64 rcv_data_fin_seq;
Signature · 1 line
2.31.1
Paolo Abeni
maintainerRe: [PATCH mptcp-next v3 2/8] mptcp: add start_seq in the msk
Quoted 23 lines · Geliang Tang
This patch added a new member named
start_seqto the msk to keep track of the beginning of the last fully-acked data segment. This would be updated in__mptcp_clean_una.Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 1 + 2 files changed, 4 insertions(+)net/mptcp/protocol.c +1
-0@@ -1071,6 +1071,7 @@ static void __mptcp_clean_una(struct sock *sk)WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); } + msk->start_seq = dfrag->data_seq;dfrag_clear (sk, dfrag); cleaned = true; }
net/mptcp/protocol.c struct sock *mptcp_sk_clone(const struct sock *sk, · line 2895
Quoted 4 lines
net/mptcp/protocol.c +1
-0@@ -2891,6 +2892,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq =mptcp_sk (sk)->setsockopt_seq; msk->last_retrans_seq = subflow_req->idsn -1 ; + msk->start_seq =0 ;
I think 'start_seq' should be initialized to 'subflow_req->idsn - 1'.
The field name itself is a bit unclear to me. Something like 'last_fully_acked_dss_start_seq' would be more expressive, but it would not be a better name at all ;) Any suggestion for a good alternative name more than welcome! (otherwise we could add some more verbose comment nearby the field definition)
/P
PATCH v3 3/8 mptcp: infinite mapping sending
In reply to Geliang TangThis patch added the infinite mapping sending logic.
Added a new flag send_infinite_map in struct mptcp_subflow_context. Set it true when a single contiguous subflow is in use in mptcp_pm_mp_fail_received.
In mptcp_sendmsg_frag, if this flag is true, call the new function mptcp_update_infinite_map to set the infinite mapping.
--- include/net/mptcp.h | 3 ++- net/mptcp/options.c | 6 ++++-- net/mptcp/pm.c | 6 ++++++ net/mptcp/protocol.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 12 ++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-)
include/net/mptcp.h +2 -1
@@ -35,7 +35,8 @@ struct mptcp_ext { frozen:1 , reset_transient:1; u8 reset_reason:4, - csum_reqd:1; + csum_reqd:1, + infinite_map:1; };#define MPTCP_RM_IDS_MAX 8
net/mptcp/options.c +4 -2
@@ -816,8 +816,10 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, opts->suboptions =0 ; -if (unlikely (__mptcp_check_fallback (msk))) -return false; +if (unlikely (__mptcp_check_fallback (msk))) { +if (!mptcp_check_infinite_map (skb)) +return false; + }if (unlikely (skb &&TCP_SKB_CB (skb)->tcp_flags &TCPHDR_RST )) {if (mptcp_established_options_mp_fail (sk, &opt_size, remaining, opts)) {
net/mptcp/pm.c +6 -0
@@ -251,7 +251,13 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)void mptcp_pm_mp_fail_received (struct sock *sk,u64 fail_seq) { +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn); +pr_debug ("fail_seq=%llu" , fail_seq); + +if (!mptcp_has_another_subflow (sk) &&mptcp_is_data_contiguous (msk)) + subflow->send_infinite_map =1 ; }/* path manager helpers */
net/mptcp/protocol.c +19 -0
@@ -1274,6 +1274,23 @@ static void mptcp_update_data_checksum(struct sk_buff *skb, int added) mpext->csum =csum_fold (csum_block_add (csum,skb_checksum (skb, offset, added,0 ), offset)); } +static void mptcp_update_infinite_map (struct mptcp_sock *msk,struct sock *ssk, +struct mptcp_ext *mpext) +{ +if (!mpext) +return ; + + mpext->infinite_map =1 ; + mpext->data_seq =READ_ONCE (msk->start_seq); + mpext->subflow_seq =0 ; + mpext->data_len =0 ; + mpext->csum =0 ; + +mptcp_subflow_ctx (ssk)->send_infinite_map =0 ; +pr_fallback (msk); +__mptcp_do_fallback (msk); +} +static int mptcp_sendmsg_frag (struct sock *sk,struct sock *ssk,struct mptcp_data_frag *dfrag,struct mptcp_sendmsg_info *info)
@@ -1406,6 +1423,8 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, out:if (READ_ONCE (msk->csum_enabled))mptcp_update_data_checksum (skb, copy); +if (mptcp_subflow_ctx (ssk)->send_infinite_map) +mptcp_update_infinite_map (msk, ssk, mpext);mptcp_subflow_ctx (ssk)->rel_write_seq += copy;return copy; }
net/mptcp/protocol.h +12 -0
@@ -433,6 +433,7 @@ struct mptcp_subflow_context { backup : 1, send_mp_prio : 1, send_mp_fail : 1, + send_infinite_map : 1, rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */
@@ -874,6 +875,17 @@ static inline void mptcp_do_fallback(struct sock *sk)#define pr_fallback (a) pr_debug("%s:fallback to TCP (msk=%p)", __func__, a) +static inline bool mptcp_check_infinite_map (struct sk_buff *skb) +{ +struct mptcp_ext *mpext; + + mpext = skb ?mptcp_get_ext (skb) :NULL ; +if (mpext && mpext->infinite_map) +return true; + +return false; +} +static inline bool subflow_simultaneous_connect (struct sock *sk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk);
Signature · 1 line
2.31.1
PATCH v3 4/8 mptcp: add the fallback check
In reply to Geliang TangThis patch added the fallback check in subflow_check_data_avail. Only do the fallback when the msk isn't fallen back yet.
--- net/mptcp/subflow.c | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
net/mptcp/subflow.c +24 -22
@@ -1164,35 +1164,37 @@ static bool subflow_check_data_avail(struct sock *ssk)return false; fallback: -/* RFC 8684 section 3.7. */ -if (subflow->send_mp_fail) { -if (mptcp_has_another_subflow (ssk) || !mptcp_is_data_contiguous (msk)) { +if (!__mptcp_check_fallback (msk)) { +/* RFC 8684 section 3.7. */ +if (subflow->send_mp_fail) { +if (mptcp_has_another_subflow (ssk) || !mptcp_is_data_contiguous (msk)) { + ssk->sk_err =EBADMSG ; +tcp_set_state (ssk,TCP_CLOSE ); + subflow->reset_transient =0 ; + subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; +tcp_send_active_reset (ssk,GFP_ATOMIC ); +while ((skb =skb_peek (&ssk->sk_receive_queue))) +sk_eat_skb (ssk, skb); + } +WRITE_ONCE (subflow->data_avail,0 ); +return true; + } + +if (subflow->mp_join || subflow->fully_established) { +/* fatal protocol error, close the socket. +* subflow_error_report() will introduce the appropriate barriers +*/ ssk->sk_err =EBADMSG ;tcp_set_state (ssk,TCP_CLOSE ); subflow->reset_transient =0 ; - subflow->reset_reason =MPTCP_RST_EMIDDLEBOX ; + subflow->reset_reason =MPTCP_RST_EMPTCP ;tcp_send_active_reset (ssk,GFP_ATOMIC ); -while ((skb =skb_peek (&ssk->sk_receive_queue))) -sk_eat_skb (ssk, skb); +WRITE_ONCE (subflow->data_avail,0 ); +return false; } -WRITE_ONCE (subflow->data_avail,0 ); -return true; - } -if (subflow->mp_join || subflow->fully_established) { -/* fatal protocol error, close the socket. -* subflow_error_report() will introduce the appropriate barriers -*/ - ssk->sk_err =EBADMSG ; -tcp_set_state (ssk,TCP_CLOSE ); - subflow->reset_transient =0 ; - subflow->reset_reason =MPTCP_RST_EMPTCP ; -tcp_send_active_reset (ssk,GFP_ATOMIC ); -WRITE_ONCE (subflow->data_avail,0 ); -return false; +__mptcp_do_fallback (msk); } - -__mptcp_do_fallback (msk); skb =skb_peek (&ssk->sk_receive_queue); subflow->map_valid =1 ; subflow->map_seq =READ_ONCE (msk->ack_seq);
Signature · 1 line
2.31.1
PATCH v3 5/8 mptcp: infinite mapping receiving
In reply to Geliang TangThis patch added the infinite mapping receiving logic. When the infinite mapping is received, set the map_data_len of the subflow to 0.
In subflow_check_data_avail, only reset the subflow when the map_data_len of the subflow is non-zero.
--- net/mptcp/subflow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/subflow.c +2 -1
@@ -968,6 +968,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk, data_len = mpext->data_len;if (data_len ==0 ) {MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_INFINITEMAPRX ); + subflow->map_data_len =0 ;return MAPPING_INVALID ; }
@@ -1180,7 +1181,7 @@ static bool subflow_check_data_avail(struct sock *ssk)return true; } -if (subflow->mp_join || subflow->fully_established) { +if ((subflow->mp_join || subflow->fully_established) && subflow->map_data_len) {/* fatal protocol error, close the socket. * subflow_error_report() will introduce the appropriate barriers */
Signature · 1 line
2.31.1
PATCH v3 6/8 mptcp: add mib for infinite map sending
In reply to Geliang TangThis patch added a new mib named MPTCP_MIB_INFINITEMAPTX, increase it when a infinite mapping has been sent out.
--- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/protocol.c | 1 + 3 files changed, 3 insertions(+)
net/mptcp/mib.c +1 -0
@@ -24,6 +24,7 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("MPJoinAckRx" ,MPTCP_MIB_JOINACKRX ),SNMP_MIB_ITEM ("MPJoinAckHMacFailure" ,MPTCP_MIB_JOINACKMAC ),SNMP_MIB_ITEM ("DSSNotMatching" ,MPTCP_MIB_DSSNOMATCH ), +SNMP_MIB_ITEM ("InfiniteMapTx" ,MPTCP_MIB_INFINITEMAPTX ),SNMP_MIB_ITEM ("InfiniteMapRx" ,MPTCP_MIB_INFINITEMAPRX ),SNMP_MIB_ITEM ("DSSNoMatchTCP" ,MPTCP_MIB_DSSTCPMISMATCH ), SNMP_MIB_ITEM("DataCsumErr", MPTCP_MIB_DATACSUMERR),
net/mptcp/mib.h +1 -0
@@ -17,6 +17,7 @@ enum linux_mptcp_mib_field {MPTCP_MIB_JOINACKRX ,/* Received an ACK + MP_JOIN */ 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_INFINITEMAPTX ,/* Sent an infinite mapping */ MPTCP_MIB_INFINITEMAPRX ,/* Received an infinite mapping */ MPTCP_MIB_DSSTCPMISMATCH ,/* DSS-mapping did not map with TCP's sequence numbers */ MPTCP_MIB_DATACSUMERR, /* The data checksum fail */
net/mptcp/protocol.c +1 -0
@@ -1286,6 +1286,7 @@ static void mptcp_update_infinite_map(struct mptcp_sock *msk, struct sock *ssk, mpext->data_len =0 ; mpext->csum =0 ; +MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_INFINITEMAPTX );mptcp_subflow_ctx (ssk)->send_infinite_map =0 ;pr_fallback (msk);__mptcp_do_fallback (msk);
Signature · 1 line
2.31.1
PATCH v3 7/8 selftests: mptcp: add infinite map mibs check
In reply to Geliang TangThis patch added a function chk_infi_nr to check the mibs for the infinite mapping.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +38 -0
@@ -615,6 +615,43 @@ chk_fail_nr() fi } +chk_infi_nr() +{ + local mp_infi_nr_tx=$1 + local mp_infi_nr_rx=$2 + local count + local dump_stats + + printf "%-39s %s" " " "itx" + count=`ip netns exec $ns1 nstat -as | grep InfiniteMapTx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_infi_nr_tx" ]; then + echo "[fail] got $count infinite map[s] TX expected $mp_infi_nr_tx" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - irx " + count=`ip netns exec $ns2 nstat -as | grep InfiniteMapRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_infi_nr_rx" ]; then + echo "[fail] got $count infinite map[s] RX expected $mp_infi_nr_rx" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi +} + chk_join_nr() { local msg="$1"
@@ -665,6 +702,7 @@ chk_join_nr() if [ $checksum -eq 1 ]; then chk_csum_nr chk_fail_nr 0 0 + chk_infi_nr 0 0 fi }
Signature · 1 line
2.31.1
PATCH v3 8/8 DO-NOT-MERGE: mptcp: mp_fail test
In reply to Geliang Tang./mptcp_join.sh -Cf
--- net/mptcp/protocol.c | 9 +++++++++ .../testing/selftests/net/mptcp/mptcp_join.sh | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+)
net/mptcp/protocol.c +9 -0
@@ -1292,6 +1292,8 @@ static void mptcp_update_infinite_map(struct mptcp_sock *msk, struct sock *ssk,__mptcp_do_fallback (msk); } +static int j; +static int mptcp_sendmsg_frag (struct sock *sk,struct sock *ssk,struct mptcp_data_frag *dfrag,struct mptcp_sendmsg_info *info)
@@ -1426,6 +1428,13 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,mptcp_update_data_checksum (skb, copy);if (mptcp_subflow_ctx (ssk)->send_infinite_map)mptcp_update_infinite_map (msk, ssk, mpext); + +pr_debug ("%s j=%d" , __func__, j++); +if (j ==20 ) + skb->data_len =1 ; +if (j >40 ) + j =0 ; +mptcp_subflow_ctx (ssk)->rel_write_seq += copy;return copy; }
tools/testing/selftests/net/mptcp/mptcp_join.sh +18 -0
@@ -977,6 +977,24 @@ chk_link_usage() subflows_tests() { + # 1 subflow + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl limits 0 2 + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr "1 subflow" 0 0 0 + + exit + + # multiple subflows + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl limits 0 2 + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr "multiple subflows" 2 2 2 + reset run_tests $ns1 $ns2 10.0.1.1 chk_join_nr "no JOIN" "0" "0" "0"
Signature · 1 line
2.31.1