mptcp: Add DATA_FIN transmission and handling
Subsystems (2)
Mat Martineau
RFC PATCH 1/1 mptcp: Add DATA_FIN transmission and handling
Send and process received DATA_FIN options. This requires addition of a state machine to the MPTCP socket to handle the closing process.
This is still a work in progress, including these areas:
* DATA_FIN requires a special DSS mapping when sent without a regular data mapping. This is causing self test failures (as noted in mptcp_established_options_dss()).
* Need to finish handling of DSS_ACKs for the state machine.
* Need to double-check whether it's correct to bypass inet_shutdown as the current code does.
* A DATA_FIN that arrives on a packet without data payload (unless it's a TCP FIN) are discarded by tcp_data_queue() and not propagated to the MPTCP socket. This is detected in mptcp_incoming_options() but not yet handled. The skb with the DATA_FIN could be cloned and placed in the subflow error queue, or a workqueue could handle it.
--- net/mptcp/options.c | 45 +++++++++++++-- net/mptcp/protocol.c | 134 ++++++++++++++++++++++++++++++++++++------- net/mptcp/protocol.h | 4 +- 3 files changed, 156 insertions(+), 27 deletions(-)
net/mptcp/options.c +41 -4
@@ -388,13 +388,15 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,unsigned int remaining, struct mptcp_out_options *opts) { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);unsigned int dss_size =0 ;struct mptcp_ext *mpext;unsigned int ack_size; mpext = skb ?mptcp_get_ext (skb) :NULL ; -if (!skb || (mpext && mpext->use_map)) { +if (!skb || (mpext && mpext->use_map) || + (subflow->send_data_fin && subflow->conn)) {unsigned int map_size; map_size =TCPOLEN_MPTCP_DSS_BASE +TCPOLEN_MPTCP_DSS_MAP64 ;
@@ -404,6 +406,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, dss_size = map_size;if (mpext) opts->ext_copy = *mpext; + +/* This creates self test failures, still tracking +* down the root cause */ +if (subflow->send_data_fin && !opts->ext_copy.use_map && + subflow->conn) { +struct mptcp_sock *msk; + +/* Required for DATA_FIN without data payload */ + msk =mptcp_sk (subflow->conn); + opts->ext_copy.use_map =1 ; + opts->ext_copy.dsn64 =1 ; + opts->ext_copy.data_seq = msk->write_seq; + opts->ext_copy.subflow_seq =0 ; + opts->ext_copy.data_len =1 ; + } }else { opts->ext_copy.use_map =0 ;WARN_ONCE (1 ,"MPTCP: Map dropped" );
@@ -421,7 +438,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, dss_size += ack_size; - msk =mptcp_sk (mptcp_subflow_ctx (sk)->conn); + msk =mptcp_sk (subflow->conn);if (msk) { opts->ext_copy.data_ack = msk->ack_seq; }else {
@@ -440,6 +457,13 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,if (!dss_size)return false; +if (subflow->send_data_fin) { + opts->ext_copy.data_fin =1 ; +/* Only clear the flag if this affects a real skb */ +if (skb) + subflow->send_data_fin =0 ; + } + *size =ALIGN (dss_size,4 );return true; }
@@ -617,6 +641,18 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, mpext->data_fin = mp_opt->data_fin; +if (mp_opt->data_fin && +TCP_SKB_CB (skb)->seq ==TCP_SKB_CB (skb)->end_seq) { +/* The DATA_FIN is on a packet that will be discarded by +* tcp_data_queue() and will not get propagated to the MPTCP +* socket. +* +* Use workqueue or subflow error queue? +*/ +pr_warn ("Ignored DATA_FIN" ); + } + +if (msk)mptcp_pm_fully_established (msk); }
@@ -712,10 +748,11 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)* support for optional 32-bit mappings later. */ flags |=MPTCP_DSS_HAS_MAP |MPTCP_DSS_DSN64 ; -if (mpext->data_fin) - flags |=MPTCP_DSS_DATA_FIN ; } +if (mpext->data_fin) + flags |=MPTCP_DSS_DATA_FIN ; + *ptr++ =mptcp_option (MPTCPOPT_DSS , len,0 , flags);if (mpext->use_ack) {
net/mptcp/protocol.c +112 -22
252 lines not on this page · raw message
net/mptcp/protocol.h +3 -1
@@ -214,7 +214,9 @@ struct mptcp_subflow_context { fourth_ack : 1, /* send initial DSS */ conn_finished : 1, map_valid : 1, - backup : 1; + backup : 1, + incoming_data_fin : 1, + send_data_fin : 1;u32 remote_nonce;u64 thmac;u32 local_nonce;
Signature · 1 line
2.23.0
Paolo Abeni
Hi Mat,
While working on the recvmsg() refactor I noticed some bits/changes may overlap with and/or conflict with data_fin support, please have a look at patches I just posted!
Some comments on the code below...
Quoted 9 lines · Mat Martineau
net/mptcp/options.c +5
-0@@ -404,6 +406,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, dss_size = map_size;if (mpext) opts->ext_copy = *mpext; + +/* This creates self test failures, still tracking +* down the root cause */ +if (subflow->send_data_fin && !opts->ext_copy.use_map && + subflow->conn) {
net/mptcp/options.c static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, · line 423
Quoted 10 lines
net/mptcp/options.c +10
-0+struct mptcp_sock *msk; + +/* Required for DATA_FIN without data payload */ + msk =mptcp_sk (subflow->conn); + opts->ext_copy.use_map =1 ; + opts->ext_copy.dsn64 =1 ; + opts->ext_copy.data_seq = msk->write_seq; + opts->ext_copy.subflow_seq =0 ; + opts->ext_copy.data_len =1 ; + }
If I read the code correctly, this may end-up sending the data_fin too early. I [mis]understand that data_fin should be added if and only if no more data will follow, but I think there could be more data pending in the tx queue, so we will end-up with an MPTCP out-of-order on the rx side (later skbs can have a lower MPTCP seq number)
net/mptcp/protocol.c static int mptcp_shutdown(struct socket *sock, int how) · line 1505
Quoted 5 lines
net/mptcp/protocol.c +1
-0@@ -1413,6 +1502,7 @@ static int mptcp_shutdown(struct socket *sock, int how) tcp_socket =mptcp_subflow_tcp_socket (subflow);pr_debug ("conn_list->subflow=%p" , subflow); + subflow->send_data_fin =1 ;
I think here you could also record the current msk->write_seq, then in mptcp_established_options_dss you can set data_fin on the skb carring the specified seq, or any pure ack pkt send after the specified MPTCP seq number.
WDYT ?
Thanks,
Paolo
Christoph Paasch
Quoted 30 lines · Paolo Abeni
Hi Mat,
While working on the
recvmsg()refactor I noticed some bits/changes may overlap with and/or conflict withdata_finsupport, please have a look at patches I just posted!Some comments on the code below...
Quoted 17 lines · Mat Martineau
net/mptcp/options.c +13
-0@@ -404,6 +406,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, dss_size = map_size;if (mpext) opts->ext_copy = *mpext; + +/* This creates self test failures, still tracking +* down the root cause */ +if (subflow->send_data_fin && !opts->ext_copy.use_map && + subflow->conn) { +struct mptcp_sock *msk; + +/* Required for DATA_FIN without data payload */ + msk =mptcp_sk (subflow->conn); + opts->ext_copy.use_map =1 ; + opts->ext_copy.dsn64 =1 ; + opts->ext_copy.data_seq = msk->write_seq; + opts->ext_copy.subflow_seq =0 ;
Quoted 8 lines
net/mptcp/options.c static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, · line 423
Quoted 2 lines
net/mptcp/options.c +2
-0+ opts->ext_copy.data_len =1 ; + }If I read the code correctly, this may end-up sending the
data_fintoo early. I [mis]understand thatdata_finshould be added if and only if no more data will follow, but I think there could be more data pending in the tx queue, so we will end-up with an MPTCP out-of-order on the rx side (later skbs can have a lower MPTCP seq number)
In principle it is ok to send the DATA_FIN even when there is still data in the tx-queue. The segment with the DATA_FIN will simply end up in the out-of-order queue on the receiver and wait for all the other data to be transmitted.
That being said, I think it still makes sense to wait until all the data has been sent, just like TCP also doesn't send an out-of-order FIN when the connection is being closed.
Cheers,
Christoph
Quoted 20 lines
net/mptcp/protocol.c static int mptcp_shutdown(struct socket *sock, int how) · line 1505
Quoted 6 lines
net/mptcp/protocol.c +1
-0@@ -1413,6 +1502,7 @@ static int mptcp_shutdown(struct socket *sock, int how) tcp_socket =mptcp_subflow_tcp_socket (subflow);pr_debug ("conn_list->subflow=%p" , subflow); + subflow->send_data_fin =1 ;I think here you could also record the current
msk->write_seq, then inmptcp_established_options_dssyou can setdata_finon the skb carring the specified seq, or any pure ack pkt send after the specified MPTCP seq number.WDYT ?
Thanks,
Paolo
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org
Mat Martineau
Quoted 39 lines · Christoph Paasch
Quoted 30 lines · Paolo Abeni
Hi Mat,
While working on the
recvmsg()refactor I noticed some bits/changes may overlap with and/or conflict withdata_finsupport, please have a look at patches I just posted!Some comments on the code below...
Quoted 17 lines · Mat Martineau
net/mptcp/options.c +13
-0@@ -404,6 +406,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, dss_size = map_size;if (mpext) opts->ext_copy = *mpext; + +/* This creates self test failures, still tracking +* down the root cause */ +if (subflow->send_data_fin && !opts->ext_copy.use_map && + subflow->conn) { +struct mptcp_sock *msk; + +/* Required for DATA_FIN without data payload */ + msk =mptcp_sk (subflow->conn); + opts->ext_copy.use_map =1 ; + opts->ext_copy.dsn64 =1 ; + opts->ext_copy.data_seq = msk->write_seq; + opts->ext_copy.subflow_seq =0 ;Quoted 8 lines
net/mptcp/options.c static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, · line 423
Quoted 2 lines
net/mptcp/options.c +2
-0+ opts->ext_copy.data_len =1 ; + }If I read the code correctly, this may end-up sending the
data_fintoo early. I [mis]understand thatdata_finshould be added if and only if no more data will follow, but I think there could be more data pending in the tx queue, so we will end-up with an MPTCP out-of-order on the rx side (later skbs can have a lower MPTCP seq number)
Quoted 21 lines
In principle it is ok to send the
DATA_FINeven when there is still data in the tx-queue. The segment with theDATA_FINwill simply end up in the out-of-order queue on the receiver and wait for all the other data to be transmitted.That being said, I think it still makes sense to wait until all the data has been sent, just like TCP also doesn't send an out-of-order FIN when the connection is being closed.
Cheers,
ChristophQuoted 13 lines
net/mptcp/protocol.c static int mptcp_shutdown(struct socket *sock, int how) · line 1505
Quoted 6 lines
net/mptcp/protocol.c +1
-0@@ -1413,6 +1502,7 @@ static int mptcp_shutdown(struct socket *sock, int how) tcp_socket =mptcp_subflow_tcp_socket (subflow);pr_debug ("conn_list->subflow=%p" , subflow); + subflow->send_data_fin =1 ;I think here you could also record the current
msk->write_seq, then inmptcp_established_options_dssyou can setdata_finon the skb carring the specified seq, or any pure ack pkt send after the specified MPTCP seq number.WDYT ?
Thanks for the comments - I will make sure DATA_FIN does not get sent too soon.
--
Mat Martineau
Intel