diff mbox series

Handle subflow join failures

Message ID 20200114135705.4019-1-fw@strlen.de
State Accepted, archived
Delegated to: Matthieu Baerts
Headers show
Series Handle subflow join failures | expand

Commit Message

Florian Westphal Jan. 14, 2020, 1:57 p.m. UTC
squashto: mptcp: Add handling of outgoing MP_JOIN requests

When the join request fails we should send a reset and also
close the socket, we can't do anything useful with such a
connection.

Signed-off-by: Florian Westphal <fw@strlen.de>

---
 net/mptcp/subflow.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

Comments

Paolo Abeni Jan. 15, 2020, 8:41 a.m. UTC | #1
On Tue, 2020-01-14 at 14:57 +0100, Florian Westphal wrote:
> squashto: mptcp: Add handling of outgoing MP_JOIN requests
> 
> When the join request fails we should send a reset and also
> close the socket, we can't do anything useful with such a
> connection.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> 
> ---
>  net/mptcp/subflow.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index f69a75f6bd6e..03f4604e2cb7 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -187,10 +187,13 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
>  
>  	subflow->icsk_af_ops->sk_rx_dst_set(sk, skb);
>  
> -	if (!subflow->conn)
> +	if (subflow->conn_finished || !tcp_sk(sk)->is_mptcp)
>  		return;
>  
> -	if (subflow->mp_capable && !subflow->conn_finished) {
> +	if (!subflow->conn)
> +		goto do_reset;
> +
> +	if (subflow->mp_capable) {
>  		pr_debug("subflow=%p, remote_key=%llu", mptcp_subflow_ctx(sk),
>  			 subflow->remote_key);
>  		mptcp_finish_connect(sk);
> @@ -200,14 +203,13 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
>  			pr_debug("synack seq=%u", TCP_SKB_CB(skb)->seq);
>  			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
>  		}
> -	} else if (subflow->mp_join && !subflow->conn_finished) {
> +	} else if (subflow->mp_join) {
>  		pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u",
>  			 subflow, subflow->thmac,
>  			 subflow->remote_nonce);
>  		if (!subflow_thmac_valid(subflow)) {
>  			subflow->mp_join = 0;
> -			// @@ need to trigger RST
> -			return;
> +			goto do_reset;
>  		}
>  
>  		mptcp_crypto_hmac_sha(subflow->local_key, subflow->remote_key,
> 

> @@ -218,8 +220,14 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
>  		if (skb)
>  			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
>  
> -		if (mptcp_finish_join(sk))
> -			subflow->conn_finished = 1;
> +		if (!mptcp_finish_join(sk))
> +			goto do_reset;
> +
> +		subflow->conn_finished = 1;
> +	} else {
> +do_reset:
> +		tcp_send_active_reset(sk, GFP_ATOMIC);
> +		tcp_done(sk);
>  	}
>  }

LGTM! It's nice to remove that old todo ;)

Thank you!

Paolo
Matthieu Baerts Jan. 16, 2020, 4:43 p.m. UTC | #2
Hi Florian, Paolo,

On 15/01/2020 09:41, Paolo Abeni wrote:
> On Tue, 2020-01-14 at 14:57 +0100, Florian Westphal wrote:
>> squashto: mptcp: Add handling of outgoing MP_JOIN requests
>>
>> When the join request fails we should send a reset and also
>> close the socket, we can't do anything useful with such a
>> connection.

[...]

> LGTM! It's nice to remove that old todo ;)
Thank you for the patch and the review!

- cc94bbe4718f: "squashed" in "mptcp: Add handling of outgoing MP_JOIN 
requests"
- 704e4fa8a50c..4fe8bda1127e: result

Tests + export will be launched soon!

Cheers,
Matt
Peter Krystad Jan. 16, 2020, 6:52 p.m. UTC | #3
On Wed, 2020-01-15 at 09:41 +0100, Paolo Abeni wrote:
> On Tue, 2020-01-14 at 14:57 +0100, Florian Westphal wrote:
> > squashto: mptcp: Add handling of outgoing MP_JOIN requests
> > 
> > When the join request fails we should send a reset and also
> > close the socket, we can't do anything useful with such a
> > connection.
> > 
> > Signed-off-by: Florian Westphal <fw@strlen.de>
> > 
> > ---
> >  net/mptcp/subflow.c | 22 +++++++++++++++-------
> >  1 file changed, 15 insertions(+), 7 deletions(-)
> > 
> > diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> > index f69a75f6bd6e..03f4604e2cb7 100644
> > --- a/net/mptcp/subflow.c
> > +++ b/net/mptcp/subflow.c
> > @@ -187,10 +187,13 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
> >  
> >  	subflow->icsk_af_ops->sk_rx_dst_set(sk, skb);
> >  
> > -	if (!subflow->conn)
> > +	if (subflow->conn_finished || !tcp_sk(sk)->is_mptcp)
> >  		return;
> >  
> > -	if (subflow->mp_capable && !subflow->conn_finished) {
> > +	if (!subflow->conn)
> > +		goto do_reset;
> > +
> > +	if (subflow->mp_capable) {
> >  		pr_debug("subflow=%p, remote_key=%llu", mptcp_subflow_ctx(sk),
> >  			 subflow->remote_key);
> >  		mptcp_finish_connect(sk);
> > @@ -200,14 +203,13 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
> >  			pr_debug("synack seq=%u", TCP_SKB_CB(skb)->seq);
> >  			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
> >  		}
> > -	} else if (subflow->mp_join && !subflow->conn_finished) {
> > +	} else if (subflow->mp_join) {
> >  		pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u",
> >  			 subflow, subflow->thmac,
> >  			 subflow->remote_nonce);
> >  		if (!subflow_thmac_valid(subflow)) {
> >  			subflow->mp_join = 0;
> > -			// @@ need to trigger RST
> > -			return;
> > +			goto do_reset;
> >  		}
> >  
> >  		mptcp_crypto_hmac_sha(subflow->local_key, subflow->remote_key,
> > 
> > @@ -218,8 +220,14 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
> >  		if (skb)
> >  			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
> >  
> > -		if (mptcp_finish_join(sk))
> > -			subflow->conn_finished = 1;
> > +		if (!mptcp_finish_join(sk))
> > +			goto do_reset;
> > +
> > +		subflow->conn_finished = 1;
> > +	} else {
> > +do_reset:
> > +		tcp_send_active_reset(sk, GFP_ATOMIC);
> > +		tcp_done(sk);
> >  	}
> >  }
> 
> LGTM! It's nice to remove that old todo ;)

Ditto this, I put that there a long time ago. Thank-you!

Peter.

> Thank you!
> 
> Paolo
> _______________________________________________
> mptcp mailing list -- mptcp@lists.01.org
> To unsubscribe send an email to mptcp-leave@lists.01.org
diff mbox series

Patch

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f69a75f6bd6e..03f4604e2cb7 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -187,10 +187,13 @@  static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 
 	subflow->icsk_af_ops->sk_rx_dst_set(sk, skb);
 
-	if (!subflow->conn)
+	if (subflow->conn_finished || !tcp_sk(sk)->is_mptcp)
 		return;
 
-	if (subflow->mp_capable && !subflow->conn_finished) {
+	if (!subflow->conn)
+		goto do_reset;
+
+	if (subflow->mp_capable) {
 		pr_debug("subflow=%p, remote_key=%llu", mptcp_subflow_ctx(sk),
 			 subflow->remote_key);
 		mptcp_finish_connect(sk);
@@ -200,14 +203,13 @@  static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 			pr_debug("synack seq=%u", TCP_SKB_CB(skb)->seq);
 			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
 		}
-	} else if (subflow->mp_join && !subflow->conn_finished) {
+	} else if (subflow->mp_join) {
 		pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u",
 			 subflow, subflow->thmac,
 			 subflow->remote_nonce);
 		if (!subflow_thmac_valid(subflow)) {
 			subflow->mp_join = 0;
-			// @@ need to trigger RST
-			return;
+			goto do_reset;
 		}
 
 		mptcp_crypto_hmac_sha(subflow->local_key, subflow->remote_key,
@@ -218,8 +220,14 @@  static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 		if (skb)
 			subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
 
-		if (mptcp_finish_join(sk))
-			subflow->conn_finished = 1;
+		if (!mptcp_finish_join(sk))
+			goto do_reset;
+
+		subflow->conn_finished = 1;
+	} else {
+do_reset:
+		tcp_send_active_reset(sk, GFP_ATOMIC);
+		tcp_done(sk);
 	}
 }