Commit d5824847 authored by Paolo Abeni's avatar Paolo Abeni Committed by Jakub Kicinski

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.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/91
Fixes: f296234c ("mptcp: Add handling of incoming MP_JOIN requests")
Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 16cb3653
...@@ -626,6 +626,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, ...@@ -626,6 +626,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
if (unlikely(mptcp_check_fallback(sk))) if (unlikely(mptcp_check_fallback(sk)))
return false; 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)) if (mptcp_established_options_mp(sk, skb, &opt_size, remaining, opts))
ret = true; ret = true;
else if (mptcp_established_options_dss(sk, skb, &opt_size, remaining, else if (mptcp_established_options_dss(sk, skb, &opt_size, remaining,
...@@ -676,7 +682,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size, ...@@ -676,7 +682,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
return false; 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 mptcp_subflow_context *subflow,
struct sk_buff *skb, struct sk_buff *skb,
struct mptcp_options_received *mp_opt) struct mptcp_options_received *mp_opt)
...@@ -693,15 +699,20 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, ...@@ -693,15 +699,20 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk,
TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq && TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq &&
subflow->mp_join && mp_opt->mp_join && subflow->mp_join && mp_opt->mp_join &&
READ_ONCE(msk->pm.server_side)) READ_ONCE(msk->pm.server_side))
tcp_send_ack(sk); tcp_send_ack(ssk);
goto fully_established; goto fully_established;
} }
/* we should process OoO packets before the first subflow is fully /* we must process OoO packets before the first subflow is fully
* established, but not expected for MP_JOIN subflows * 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; return subflow->mp_capable;
}
if (mp_opt->dss && mp_opt->use_ack) { if (mp_opt->dss && mp_opt->use_ack) {
/* subflows are fully established as soon as we get any /* subflows are fully established as soon as we get any
...@@ -713,9 +724,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, ...@@ -713,9 +724,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk,
} }
/* If the first established packet does not contain MP_CAPABLE + data /* 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 (!mp_opt->mp_capable) {
if (subflow->mp_join)
goto reset;
subflow->mp_capable = 0; subflow->mp_capable = 0;
pr_fallback(msk); pr_fallback(msk);
__mptcp_do_fallback(msk); __mptcp_do_fallback(msk);
...@@ -732,12 +746,16 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk, ...@@ -732,12 +746,16 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *sk,
subflow->pm_notified = 1; subflow->pm_notified = 1;
if (subflow->mp_join) { if (subflow->mp_join) {
clear_3rdack_retransmission(sk); clear_3rdack_retransmission(ssk);
mptcp_pm_subflow_established(msk, subflow); mptcp_pm_subflow_established(msk, subflow);
} else { } else {
mptcp_pm_fully_established(msk); mptcp_pm_fully_established(msk);
} }
return true; return true;
reset:
mptcp_subflow_reset(ssk);
return false;
} }
static u64 expand_ack(u64 old_ack, u64 cur_ack, bool use_64bit) static u64 expand_ack(u64 old_ack, u64 cur_ack, bool use_64bit)
......
...@@ -348,6 +348,7 @@ void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, ...@@ -348,6 +348,7 @@ void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow,
struct mptcp_options_received *mp_opt); struct mptcp_options_received *mp_opt);
bool mptcp_subflow_data_available(struct sock *sk); bool mptcp_subflow_data_available(struct sock *sk);
void __init mptcp_subflow_init(void); void __init mptcp_subflow_init(void);
void mptcp_subflow_reset(struct sock *ssk);
/* called with sk socket lock held */ /* called with sk socket lock held */
int __mptcp_subflow_connect(struct sock *sk, int ifindex, int __mptcp_subflow_connect(struct sock *sk, int ifindex,
......
...@@ -270,6 +270,13 @@ static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow) ...@@ -270,6 +270,13 @@ static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow)
return thmac == subflow->thmac; 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) static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
{ {
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
...@@ -342,8 +349,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) ...@@ -342,8 +349,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
return; return;
do_reset: do_reset:
tcp_send_active_reset(sk, GFP_ATOMIC); mptcp_subflow_reset(sk);
tcp_done(sk);
} }
struct request_sock_ops mptcp_subflow_request_sock_ops; struct request_sock_ops mptcp_subflow_request_sock_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment