mptcp: mp join fallback fixes.
Subsystems (2)
Paolo Abeni
cover mptcp: mp join fallback fixes.
This solves issues/91 for me at least. Targeting upstream -net. As such, patches based on the "bottom" of current export branch, so that should apply cleanly on current -net.
Note that rebasing on top of patch 2 "mptcp: refactor shutdown and close", we must change the value of the macro MPTCP_WORKER_RUNNING (5 -> 6)
The problem fixed by patch 2/2 already exist in the curren export/net branches - is quite rare, but is more visible after patch 1/2.
This iteration addresses the comment from Mat on patch 2/2
Paolo Abeni (2):
mptcp: fix fallback for MP_JOIN subflows
mptcp: subflows garbage collection
net/mptcp/options.c | 32 +++++++++++++++++++++++++------- net/mptcp/protocol.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 2 ++ net/mptcp/subflow.c | 16 ++++++++++++++-- 4 files changed, 59 insertions(+), 9 deletions(-)
Signature · 1 line
2.26.2
Paolo Abeni
PATCH 1/2 mptcp: fix fallback for MP_JOIN subflows
Additional/MP_JOIN subflows that do not pass some initial handshake tests currently causes fallback to TCP. That is an RFC violation:
we should instead reset the subflow and leave the the msk untouched.
--- net/mptcp/options.c | 32 +++++++++++++++++++++++++------- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 10 ++++++++-- 3 files changed, 34 insertions(+), 9 deletions(-)
net/mptcp/options.c +25 -7
@@ -657,6 +657,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,if (unlikely (mptcp_check_fallback (sk)))return false; +/* prevent adding of any MPTCP related options on reset packet +* until we support MP_TCPRST/MP_FASTCLOSE +*/ +if (unlikely (skb &&TCP_SKB_CB (skb)->tcp_flags &TCPHDR_RST )) +return false; +if (mptcp_established_options_mp (sk, skb, &opt_size, remaining, opts)) ret = true; else if (mptcp_established_options_dss(sk, skb, &opt_size, remaining,
@@ -711,7 +717,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,return false; } -static bool check_fully_established (struct mptcp_sock *msk,struct sock *sk, +static bool check_fully_established (struct mptcp_sock *msk,struct sock *ssk,struct mptcp_subflow_context *subflow,struct sk_buff *skb,struct mptcp_options_received *mp_opt)
@@ -728,15 +734,20 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq && subflow->mp_join && mp_opt->mp_join && READ_ONCE(msk->pm.server_side)) -tcp_send_ack (sk); +tcp_send_ack (ssk); goto fully_established; } -/* we should process OoO packets before the first subflow is fully -* established, but not expected for MP_JOIN subflows +/* we must process OoO packets before the first subflow is fully +* established. OoO packets are instead a protocol violation +* for MP_JOIN subflows as the peer must not send any data +* before receiving the forth ack - cfr. RFC 8684 section 3.2. */ -if (TCP_SKB_CB (skb)->seq != subflow->ssn_offset +1 ) +if (TCP_SKB_CB (skb)->seq != subflow->ssn_offset +1 ) { +if (subflow->mp_join) + goto reset;return subflow->mp_capable; + }if (mp_opt->dss && mp_opt->use_ack) {/* subflows are fully established as soon as we get any
@@ -748,9 +759,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, }/* If the first established packet does not contain MP_CAPABLE + data -* then fallback to TCP +* then fallback to TCP. Fallback scenarios requires a reset for +* MP_JOIN subflows. */ if (!mp_opt->mp_capable) { +if (subflow->mp_join) + goto reset; subflow->mp_capable =0 ;pr_fallback (msk);__mptcp_do_fallback (msk);
@@ -767,12 +781,16 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, subflow->pm_notified =1 ;if (subflow->mp_join) { -clear_3rdack_retransmission (sk); +clear_3rdack_retransmission (ssk);mptcp_pm_subflow_established (msk, subflow); }else {mptcp_pm_fully_established (msk); }return true; + +reset: +mptcp_subflow_reset (ssk); +return false; }static u64 expand_ack (u64 old_ack,u64 cur_ack,bool use_64bit)
net/mptcp/protocol.h +1 -0
@@ -369,6 +369,7 @@ void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how);void __mptcp_close_ssk (struct sock *sk,struct sock *ssk,struct mptcp_subflow_context *subflow,long timeout); +void mptcp_subflow_reset (struct sock *ssk);/* called with sk socket lock held */ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
net/mptcp/subflow.c +8 -2
@@ -271,6 +271,13 @@ static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow)return thmac == subflow->thmac; } +void mptcp_subflow_reset (struct sock *ssk) +{ +tcp_set_state (ssk,TCP_CLOSE ); +tcp_send_active_reset (ssk,GFP_ATOMIC ); +tcp_done (ssk); +} +static void subflow_finish_connect (struct sock *sk,const struct sk_buff *skb) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk);
@@ -343,8 +350,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)return ; do_reset: -tcp_send_active_reset (sk,GFP_ATOMIC ); -tcp_done (sk); +mptcp_subflow_reset (sk); }struct request_sock_ops mptcp_subflow_request_sock_ops;
Signature · 1 line
2.26.2
Mat Martineau
Reviewed-by on v1 1/2[MPTCP] Re: [PATCH net 1/2] mptcp: fix fallback for MP_JOIN subflows
Quoted 4 lines · Paolo Abeni
Additional/MP_JOIN subflows that do not pass some initial handshake tests currently causes fallback to TCP. That is an RFC violation:
we should instead reset the subflow and leave the the msk untouched.
Quoted 8 lines
Fixes f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests")Signed-off-by Paolo Abeni <pabeni(a)redhat.com>---
net/mptcp/options.c | 32 +++++++++++++++++++++++++------- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 10 ++++++++-- 3 files changed, 34 insertions(+), 9 deletions(-)
This doesn't apply cleanly to -net (trivial conflict in protocol.h), but here's the tag to help get this merged soon:
--
Mat Martineau
Intel
Paolo Abeni
PATCH 2/2 mptcp: subflows garbage collection
In reply to Paolo AbeniThe msk can close MP_JOIN subflows if the initial handshake fails. Currently such subflows are kept alive in the conn_list untill the msk itself is closed.
Beyond the wasted memory, we could end-up sending the DATA_FIN and the DATA_FIN ack on such socket, even after a reset.
--- net/mptcp/protocol.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 6 ++++++ 3 files changed, 25 insertions(+)
net/mptcp/protocol.c +18 -0
@@ -1701,6 +1701,20 @@ static void pm_work(struct mptcp_sock *msk)spin_unlock_bh (&msk->pm.lock); } +static void __mptcp_close_subflow (struct mptcp_sock *msk) +{ +struct mptcp_subflow_context *subflow, *tmp; + +list_for_each_entry_safe (subflow, tmp, &msk->conn_list, node) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); + +if (inet_sk_state_load (ssk) !=TCP_CLOSE ) +continue ; + +__mptcp_close_ssk ((struct sock *)msk, ssk, subflow,0 ); + } +} +static void mptcp_worker (struct work_struct *work) { struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
@@ -1718,11 +1732,15 @@ static void mptcp_worker(struct work_struct *work)mptcp_clean_una (sk);mptcp_check_data_fin_ack (sk);__mptcp_flush_join_list (msk); +if (test_and_clear_bit (MPTCP_WORK_CLOSE_SUBFLOW , &msk->flags)) +__mptcp_close_subflow (msk); +__mptcp_move_skbs (msk);if (msk->pm.status)pm_work (msk); +if (test_and_clear_bit (MPTCP_WORK_EOF , &msk->flags))mptcp_check_for_eof (msk);
net/mptcp/protocol.h +1 -0
@@ -90,6 +90,7 @@#define MPTCP_WORK_RTX 2#define MPTCP_WORK_EOF 3#define MPTCP_FALLBACK_DONE 4 +#define MPTCP_WORK_CLOSE_SUBFLOW 5struct mptcp_options_received {u64 sndr_key;
net/mptcp/subflow.c +6 -0
@@ -273,9 +273,15 @@ static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow)void mptcp_subflow_reset (struct sock *ssk) { +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk); +struct sock *sk = subflow->conn; +tcp_set_state (ssk,TCP_CLOSE );tcp_send_active_reset (ssk,GFP_ATOMIC );tcp_done (ssk); +if (!test_and_set_bit (MPTCP_WORK_CLOSE_SUBFLOW , &mptcp_sk (sk)->flags) && +schedule_work (&mptcp_sk (sk)->work)) +sock_hold (sk); }static void subflow_finish_connect (struct sock *sk,const struct sk_buff *skb)
Signature · 1 line
2.26.2
Mat Martineau
Reviewed-by on v1 2/2[MPTCP] Re: [PATCH net 2/2] mptcp: subflows garbage collection
Quoted 46 lines · Paolo Abeni
The msk can close
MP_JOINsubflows if the initial handshake fails. Currently such subflows are kept alive in theconn_listuntill the msk itself is closed.Beyond the wasted memory, we could end-up sending the
DATA_FINand theDATA_FINack on such socket, even after a reset.Fixes 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")Signed-off-by Paolo Abeni <pabeni(a)redhat.com>---
net/mptcp/protocol.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 6 ++++++ 3 files changed, 25 insertions(+)net/mptcp/protocol.c +15
-0@@ -1701,6 +1701,20 @@ static void pm_work(struct mptcp_sock *msk)spin_unlock_bh (&msk->pm.lock); } +static void __mptcp_close_subflow (struct mptcp_sock *msk) +{ +struct mptcp_subflow_context *subflow, *tmp; + +list_for_each_entry_safe (subflow, tmp, &msk->conn_list, node) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); + +if (inet_sk_state_load (ssk) !=TCP_CLOSE ) +continue ; + +__mptcp_close_ssk ((struct sock *)msk, ssk, subflow,0 ); + } +} +static void mptcp_worker (struct work_struct *work) { struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);@@ -1718,11 +1732,15 @@ static void mptcp_worker(struct work_struct *work)mptcp_clean_una (sk);mptcp_check_data_fin_ack (sk);__mptcp_flush_join_list (msk); +if (test_and_clear_bit (MPTCP_WORK_CLOSE_SUBFLOW , &msk->flags))
net/mptcp/protocol.c static void mptcp_worker(struct work_struct *work) · line 1745
Quoted 10 lines
net/mptcp/protocol.c +3
-0+__mptcp_close_subflow (msk); +__mptcp_move_skbs (msk);if (msk->pm.status)pm_work (msk); +if (test_and_clear_bit (MPTCP_WORK_EOF , &msk->flags))mptcp_check_for_eof (msk);
Still this extra whitespace, but looks good other than that:
I applied both (resolving conflict on patch 1) to net/master and the self tests look ok on my system. diag.sh has some failures, but those are the same with or without these patches.
--
Mat Martineau
Intel
Paolo Abeni
Quoted 16 lines · Paolo Abeni
This solves issues/91 for me at least. Targeting upstream -net. As such, patches based on the "bottom" of current export branch, so that should apply cleanly on current -net.
Note that rebasing on top of patch 2 "mptcp: refactor shutdown and close", we must change the value of the macro
MPTCP_WORKER_RUNNING(5 -> 6)The problem fixed by patch 2/2 already exist in the curren export/net branches - is quite rare, but is more visible after patch 1/2.
This iteration addresses the comment from Mat on patch 2/2
Paolo Abeni (2):
mptcp: fix fallback forMP_JOINsubflows
mptcp: subflows garbage collection
Quoted 5 lines
net/mptcp/options.c | 32 +++++++++++++++++++++++++------- net/mptcp/protocol.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 2 ++ net/mptcp/subflow.c | 16 ++++++++++++++-- 4 files changed, 59 insertions(+), 9 deletions(-)
whoops, I did not edit the subj, this is a v2 of:
https://lists.01.org/hyperkitty/list/mptcp(a)lists.01.org/thread/RVEZWTSUWCZZ2CIM3G23ODLNA4PPKGCP/
Matthieu Baerts
Hi Paolo, Mat,
Quoted 23 lines · Paolo Abeni
Quoted 16 lines · Paolo Abeni
This solves issues/91 for me at least. Targeting upstream -net. As such, patches based on the "bottom" of current export branch, so that should apply cleanly on current -net.
Note that rebasing on top of patch 2 "mptcp: refactor shutdown and close", we must change the value of the macro
MPTCP_WORKER_RUNNING(5 -> 6)The problem fixed by patch 2/2 already exist in the curren export/net branches - is quite rare, but is more visible after patch 1/2.
This iteration addresses the comment from Mat on patch 2/2
Paolo Abeni (2):
mptcp: fix fallback forMP_JOINsubflows
mptcp: subflows garbage collectionQuoted 5 lines
net/mptcp/options.c | 32 +++++++++++++++++++++++++------- net/mptcp/protocol.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 2 ++ net/mptcp/subflow.c | 16 ++++++++++++++-- 4 files changed, 59 insertions(+), 9 deletions(-)
Quoted 3 lines
whoops, I did not edit the subj, this is a v2 of:
https://lists.01.org/hyperkitty/list/mptcp(a)lists.01.org/thread/RVEZWTSUWCZZ2CIM3G23ODLNA4PPKGCP/
FYI, I just applied at the bottom of the "export" branch the version you sent upstream:
- db2de27c5906: mptcp: fix fallback for MP_JOIN subflows
- Note: I had to fix a simple conflict in protocol.h
- 7a314484c7f7: mptcp: subflows garbage collection
- 0b5ccff33117: conflict in t/mptcp-refactor-shutdown-and-close
- Results: 91d38a7ab17e..354a916e9e76
Tests + export are going to be started soon.
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net