Skip to contentSkip to conversation

fallback to TCP on ulp clone failure

PATCH In review Paolo Abeni 3 participants 15 messages Jan 9, 2020 – Jan 16, 2020

Subsystems (2)
lore
Share & tools
lore

Paolo Abeni

author
#0 lore raw

v2 cover fallback to TCP on ulp clone failure

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places, as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks, is simpler then other alternatives but waste some space inside the subflow struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

 options.c  |    7 ------
 protocol.c |   20 ++++++++---------
 protocol.h |   15 ++++++++++++-
 subflow.c  |   68 ++++++++++++++++++++++++++++++++++++++++---------------------
 4 files changed, 68 insertions(+), 42 deletions(-)
author
#1 lore raw

PATCH v2 1/7 Squash-to: "mptcp: Handle MP_CAPABLE options for outgoing connections"

After upstream feedback, I just noticed that we actually don't clear the is_mptcp field on clone allocation failure.

Do that and additionally don't allocate at all the subflow if MPC handshake failed.

Note: we need to update accordingly accept on later patch

v1 -> v2:
- use sk_is_mptcp() in __mptcp_tcp_fallback() (Mat)

RFC -> v1:
- avoid assign statement inside the if statement (Florian)
- avoid rendundant conn = NULL (Mat)
- clear ulp data on fallback, or to avoid double free at close time

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/protocol.c |  2 +-
 net/mptcp/subflow.c  | 33 +++++++++++++++++++++------------
 2 files changed, 22 insertions(+), 13 deletions(-)
net/mptcp/protocol.c +1 -1
index 8bb3ecf87ee5..9120f75659b5 100644
@@ -42,7 +42,7 @@ static struct socket *__mptcp_tcp_fallback(const struct mptcp_sock *msk)
 
 	sock_owned_by_me((const struct sock *)msk);
 
-	if (!ssock || tcp_sk(ssock->sk)->is_mptcp)
+	if (!ssock || sk_is_mptcp(ssock->sk))
 		return NULL;
 
 	return ssock;
net/mptcp/subflow.c +21 -12
index b9aca17b0b91..cf4c05a6cfac 100644
@@ -254,6 +254,15 @@ static void subflow_ulp_release(struct sock *sk)
 	kfree_rcu(ctx, rcu);
 }
 
+static void subflow_ulp_fallback(struct sock *sk)
+{
+	struct inet_connection_sock *icsk = inet_csk(sk);
+
+	icsk->icsk_ulp_ops = NULL;
+	rcu_assign_pointer(icsk->icsk_ulp_data, NULL);
+	tcp_sk(sk)->is_mptcp = 0;
+}
+
 static void subflow_ulp_clone(const struct request_sock *req,
 			      struct sock *newsk,
 			      const gfp_t priority)
@@ -262,23 +271,23 @@ static void subflow_ulp_clone(const struct request_sock *req,
 	struct mptcp_subflow_context *old_ctx = mptcp_subflow_ctx(newsk);
 	struct mptcp_subflow_context *new_ctx;
 
-	/* newsk->sk_socket is NULL at this point */
+	if (!subflow_req->mp_capable) {
+		subflow_ulp_fallback(newsk);
+		return;
+	}
+
 	new_ctx = subflow_create_ctx(newsk, priority);
-	if (!new_ctx)
+	if (new_ctx == NULL) {
+		subflow_ulp_fallback(newsk);
 		return;
+	}
 
-	new_ctx->conn = NULL;
 	new_ctx->conn_finished = 1;
 	new_ctx->icsk_af_ops = old_ctx->icsk_af_ops;
-
-	if (subflow_req->mp_capable) {
-		new_ctx->mp_capable = 1;
-		new_ctx->fourth_ack = 1;
-		new_ctx->remote_key = subflow_req->remote_key;
-		new_ctx->local_key = subflow_req->local_key;
-	} else {
-		tcp_sk(newsk)->is_mptcp = 0;
-	}
+	new_ctx->mp_capable = 1;
+	new_ctx->fourth_ack = 1;
+	new_ctx->remote_key = subflow_req->remote_key;
+	new_ctx->local_key = subflow_req->local_key;
 }
 
 static struct tcp_ulp_ops subflow_ulp_ops __read_mostly = {
Signature · 1 line
2.21.0
author
#4 lore raw

PATCH v2 2/7 Squash-to "mptcp: Create SUBFLOW socket for incoming connection"

In reply to Paolo Abeni

use is_mptcp instead of 'subflow->mp_capable'

v1 -> v2:
- use sk_is_mptcp() in mptcp_accept() - Mat

---
 net/mptcp/protocol.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +4 -6
index 88bfa4fedde5..ec792dbe0a5b 100644
@@ -243,7 +243,6 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
 				 bool kern)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
-	struct mptcp_subflow_context *subflow;
 	struct socket *listener;
 	struct sock *newsk;
 
@@ -258,13 +257,14 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
 	if (!newsk)
 		return NULL;
 
-	subflow = mptcp_subflow_ctx(newsk);
-	pr_debug("msk=%p, new subflow=%p, ", msk, subflow);
+	pr_debug("msk=%p, subflow is mptcp=%d", msk, sk_is_mptcp(newsk));
 
-	if (subflow->mp_capable) {
+	if (sk_is_mptcp(newsk)) {
+		struct mptcp_subflow_context *subflow;
 		struct sock *new_mptcp_sock;
 		struct sock *ssk = newsk;
 
+		subflow = mptcp_subflow_ctx(newsk);
 		lock_sock(sk);
 
 		local_bh_disable();
@@ -295,8 +295,6 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
 		bh_unlock_sock(new_mptcp_sock);
 		local_bh_enable();
 		release_sock(sk);
-	} else {
-		tcp_sk(newsk)->is_mptcp = 0;
 	}
 
 	return newsk;
Signature · 1 line
2.21.0
author
#5 lore raw

PATCH v2 3/7 Squash-to: "mptcp: Add key generation and token tree"

In reply to Paolo Abeni
---
 net/mptcp/subflow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/mptcp/subflow.c +4 -1
index 2dad612b48be..b8651367f6fe 100644
@@ -160,8 +160,11 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 	if (child && *own_req) {
 		struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(child);
 
+		/* we have null ctx on TCP fallback, not fatal on MPC
+		 * handshake
+		 */
 		if (!ctx)
-			goto close_child;
+			return child;
 
 		if (ctx->mp_capable) {
 			if (mptcp_token_new_accept(ctx->token))
Signature · 1 line
2.21.0
author
#6 lore raw

PATCH v2 4/7 Squash-to: "mptcp: Write MPTCP DSS headers to outgoing data packets"

In reply to Paolo Abeni

v1 -> v2:
- completely drop the check, as is_mptcp is already checked by the caller (Mat)

Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>
Signed-off-by Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/options.c | 3 ---
 1 file changed, 3 deletions(-)
net/mptcp/options.c +0 -3
index c9b5f37db63b..a78f368b189e 100644
@@ -303,9 +303,6 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 	unsigned int opt_size = 0;
 	bool ret = false;
 
-	if (!mptcp_subflow_ctx(sk)->mp_capable)
-		return false;
-
 	if (mptcp_established_options_mp(sk, &opt_size, remaining, opts))
 		ret = true;
 	else if (mptcp_established_options_dss(sk, skb, &opt_size, remaining,
Signature · 1 line
2.21.0
author
#7 lore raw

PATCH v2 5/7 Squash-to: "mptcp: Implement MPTCP receive path"

In reply to Paolo Abeni

deal with fallback: we must reset sk callback to the TCP one. Use the cached ptr in the old ctx.

RFC -> v1:
- since mptcp_incoming_options() callers check for is_mptcp and the latter is always cleared on fallback, we can drop any additional check in mptcp_incoming_options()

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/options.c  |  4 ----
 net/mptcp/protocol.h | 15 ++++++++++++++-
 net/mptcp/subflow.c  | 19 ++++++++++++-------
 3 files changed, 26 insertions(+), 12 deletions(-)
net/mptcp/options.c +0 -4
index 9341c3269676..db224e050666 100644
@@ -413,13 +413,9 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
 void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,
 			    struct tcp_options_received *opt_rx)
 {
-	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 	struct mptcp_options_received *mp_opt;
 	struct mptcp_ext *mpext;
 
-	if (!subflow->mp_capable)
-		return;
-
 	mp_opt = &opt_rx->mptcp;
 
 	if (!mp_opt->dss)
net/mptcp/protocol.h +14 -1
index e4fce9f0ad65..c6d8217e24d4 100644
@@ -121,7 +121,10 @@ struct mptcp_subflow_context {
 	struct	sock *tcp_sock;	    /* tcp sk backpointer */
 	struct	sock *conn;	    /* parent mptcp_sock */
 	const	struct inet_connection_sock_af_ops *icsk_af_ops;
-	void	(*tcp_sk_data_ready)(struct sock *sk);
+	void	(*tcp_data_ready)(struct sock *sk);
+	void	(*tcp_state_change)(struct sock *sk);
+	void	(*tcp_write_space)(struct sock *sk);
+
 	struct	rcu_head rcu;
 };
 
@@ -159,6 +162,16 @@ bool mptcp_subflow_data_available(struct sock *sk);
 void mptcp_subflow_init(void);
 int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock);
 
+static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
+					      struct mptcp_subflow_context *ctx)
+{
+	sk->sk_data_ready = ctx->tcp_data_ready;
+	sk->sk_state_change = ctx->tcp_state_change;
+	sk->sk_write_space = ctx->tcp_write_space;
+
+	inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
+}
+
 extern const struct inet_connection_sock_af_ops ipv4_specific;
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 extern const struct inet_connection_sock_af_ops ipv6_specific;
net/mptcp/subflow.c +12 -7
index 4e00348ce54e..a1be17926248 100644
@@ -507,7 +507,7 @@ static void subflow_data_ready(struct sock *sk)
 	struct sock *parent = subflow->conn;
 
 	if (!parent || !subflow->mp_capable) {
-		subflow->tcp_sk_data_ready(sk);
+		subflow->tcp_data_ready(sk);
 
 		if (parent)
 			parent->sk_data_ready(parent);
@@ -655,7 +655,9 @@ static int subflow_ulp_init(struct sock *sk)
 	if (sk->sk_family == AF_INET6)
 		icsk->icsk_af_ops = &subflow_v6_specific;
 #endif
-	ctx->tcp_sk_data_ready = sk->sk_data_ready;
+	ctx->tcp_data_ready = sk->sk_data_ready;
+	ctx->tcp_state_change = sk->sk_state_change;
+	ctx->tcp_write_space = sk->sk_write_space;
 	sk->sk_data_ready = subflow_data_ready;
 	sk->sk_write_space = subflow_write_space;
 	sk->sk_state_change = subflow_state_change;
@@ -676,10 +678,12 @@ static void subflow_ulp_release(struct sock *sk)
 	kfree_rcu(ctx, rcu);
 }
 
-static void subflow_ulp_fallback(struct sock *sk)
+static void subflow_ulp_fallback(struct sock *sk,
+				 struct mptcp_subflow_context *old_ctx)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
 
+	mptcp_subflow_tcp_fallback(sk, old_ctx);
 	icsk->icsk_ulp_ops = NULL;
 	rcu_assign_pointer(icsk->icsk_ulp_data, NULL);
 	tcp_sk(sk)->is_mptcp = 0;
@@ -694,20 +698,21 @@ static void subflow_ulp_clone(const struct request_sock *req,
 	struct mptcp_subflow_context *new_ctx;
 
 	if (!subflow_req->mp_capable) {
-		subflow_ulp_fallback(newsk);
+		subflow_ulp_fallback(newsk, old_ctx);
 		return;
 	}
 
 	new_ctx = subflow_create_ctx(newsk, priority);
 	if (new_ctx == NULL) {
-		subflow_ulp_fallback(newsk);
+		subflow_ulp_fallback(newsk, old_ctx);
 		return;
 	}
 
 	new_ctx->conn_finished = 1;
 	new_ctx->icsk_af_ops = old_ctx->icsk_af_ops;
-	new_ctx->tcp_sk_data_ready = old_ctx->tcp_sk_data_ready;
-
+	new_ctx->tcp_data_ready = old_ctx->tcp_data_ready;
+	new_ctx->tcp_state_change = old_ctx->tcp_state_change;
+	new_ctx->tcp_write_space = old_ctx->tcp_write_space;
 	new_ctx->mp_capable = 1;
 	new_ctx->fourth_ack = 1;
 	new_ctx->remote_key = subflow_req->remote_key;
Signature · 1 line
2.21.0
author
#8 lore raw

PATCH v2 6/7 Squash-to: "mptcp: cope with later TCP fallback"

In reply to Paolo Abeni

Now we can fully restore the subflow status on late tcp fallback

v1 -> v2:
- use sk_is_mptcp() in __mptcp_needs_tcp_fallback() (Mat)

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/protocol.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +4 -4
index 1d1f8e54068f..f6c6298857a4 100644
@@ -52,10 +52,10 @@ static struct socket *__mptcp_fallback_to_tcp(struct mptcp_sock *msk,
 	lock_sock(ssk);
 	sock_graft(ssk, sock);
 	if (subflow->conn) {
-		/* Clearing the 'conn' field will make the ULP-overriden
-		 * ops behaving like plain TCP ones.
-		 * Note: we can't release the ULP data on a live socket.
+		/* We can't release the ULP data on a live socket,
+		 * restore the tcp callback
 		 */
+		mptcp_subflow_tcp_fallback(ssk, subflow);
 		sock_put(subflow->conn);
 		subflow->conn = NULL;
 	}
@@ -83,7 +83,7 @@ static struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk)
 
 static bool __mptcp_needs_tcp_fallback(const struct mptcp_sock *msk)
 {
-	return msk->first && !tcp_sk(msk->first)->is_mptcp;
+	return msk->first && !sk_is_mptcp(msk->first);
 }
 
 /* if the mp_capable handshake has failed, it fallbacks msk to plain TCP,
Signature · 1 line
2.21.0
author
#9 lore raw

PATCH v2 7/7 Squash-to: "mptcp: Add handling of incoming MP_JOIN requests"

In reply to Paolo Abeni

ensure fallback is fatal for MP_JOIN, copying with changes introduced by previous squash-to patches

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/subflow.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
net/mptcp/subflow.c +8 -3
index 4e846b4e0b81..49d430479124 100644
@@ -256,6 +256,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 	struct mptcp_subflow_context *listener = mptcp_subflow_ctx(sk);
 	struct mptcp_subflow_request_sock *subflow_req;
 	struct tcp_options_received opt_rx;
+	bool fallback_is_fatal = false;
 	struct sock *child;
 
 	pr_debug("listener=%p, req=%p, conn=%p", listener, req, listener->conn);
@@ -280,6 +281,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 			subflow_req->mp_capable = 0;
 		}
 	} else if (subflow_req->mp_join) {
+		fallback_is_fatal = true;
 		opt_rx.mptcp.mp_join = 0;
 		mptcp_get_options(skb, &opt_rx);
 		if (!opt_rx.mptcp.mp_join ||
@@ -294,11 +296,14 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 	if (child && *own_req) {
 		struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(child);
 
-		/* we have null ctx on TCP fallback, not fatal on MPC
-		 * handshake
+		/* we have null ctx on TCP fallback, which is fatal on
+		 * MPJ handshake
 		 */
-		if (!ctx)
+		if (!ctx) {
+			if (fallback_is_fatal)
+				goto close_child;
 			return child;
+		}
 
 		if (ctx->mp_capable) {
 			if (mptcp_token_new_accept(ctx->token))
Signature · 1 line
2.21.0
#10 lore raw
In reply to Paolo Abeni
Quoted 24 lines · Paolo Abeni

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places, as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks, is simpler then other alternatives but waste some space inside the subflow struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

Quoted 5 lines
options.c  |    7 ------
protocol.c |   20 ++++++++---------
protocol.h |   15 ++++++++++++-
subflow.c  |   68 ++++++++++++++++++++++++++++++++++++++++---------------------
4 files changed, 68 insertions(+), 42 deletions(-)

Hi Paolo -

Thanks for the fixes from v1. Looks good to me.

--
Mat Martineau
Intel

#2 lore raw

[MPTCP] Re: [PATCH v2 1/7] Squash-to: "mptcp: Handle MP_CAPABLE options for outgoing connections"

In reply to Paolo Abeni
Quoted 57 lines · Paolo Abeni

After upstream feedback, I just noticed that we actually don't clear the is_mptcp field on clone allocation failure.

Do that and additionally don't allocate at all the subflow if MPC handshake failed.

Note: we need to update accordingly accept on later patch

v1 -> v2:
- use sk_is_mptcp() in __mptcp_tcp_fallback() (Mat)

RFC -> v1:
- avoid assign statement inside the if statement (Florian)
- avoid rendundant conn = NULL (Mat)
- clear ulp data on fallback, or to avoid double free at close time

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>

---
net/mptcp/protocol.c | 2 +-
net/mptcp/subflow.c | 33 +++++++++++++++++++++------------

2 files changed, 22 insertions(+), 13 deletions(-)
net/mptcp/protocol.c +1 -1
index 8bb3ecf87ee5..9120f75659b5 100644
@@ -42,7 +42,7 @@ static struct socket *__mptcp_tcp_fallback(const struct mptcp_sock *msk)
 
 	sock_owned_by_me((const struct sock *)msk);
 
-	if (!ssock || tcp_sk(ssock->sk)->is_mptcp)
+	if (!ssock || sk_is_mptcp(ssock->sk))
 		return NULL;
 
 	return ssock;
net/mptcp/subflow.c +9 -0
index b9aca17b0b91..cf4c05a6cfac 100644
@@ -254,6 +254,15 @@ static void subflow_ulp_release(struct sock *sk)
 	kfree_rcu(ctx, rcu);
 }
 
+static void subflow_ulp_fallback(struct sock *sk)
+{
+	struct inet_connection_sock *icsk = inet_csk(sk);
+
+	icsk->icsk_ulp_ops = NULL;
+	rcu_assign_pointer(icsk->icsk_ulp_data, NULL);
+	tcp_sk(sk)->is_mptcp = 0;
+}
+
 static void subflow_ulp_clone(const struct request_sock *req,
 			      struct sock *newsk,
 			      const gfp_t priority)

net/mptcp/subflow.c static void subflow_ulp_clone(const struct request_sock *req, · line 274

Quoted 5 lines
net/mptcp/subflow.c +1 -1
@@ -262,23 +271,23 @@ static void subflow_ulp_clone(const struct request_sock *req,
 	struct mptcp_subflow_context *old_ctx = mptcp_subflow_ctx(newsk);
 	struct mptcp_subflow_context *new_ctx;
 
-	/* newsk->sk_socket is NULL at this point */
+	if (!subflow_req->mp_capable) {

Does this logic need to be updated in patch 7 to allow mp_join? Matthieu ran in to a problem applying the series.

Mat

Quoted 32 lines
net/mptcp/subflow.c +11 -11
+		subflow_ulp_fallback(newsk);
+		return;
+	}
+
 	new_ctx = subflow_create_ctx(newsk, priority);
-	if (!new_ctx)
+	if (new_ctx == NULL) {
+		subflow_ulp_fallback(newsk);
 		return;
+	}
 
-	new_ctx->conn = NULL;
 	new_ctx->conn_finished = 1;
 	new_ctx->icsk_af_ops = old_ctx->icsk_af_ops;
-
-	if (subflow_req->mp_capable) {
-		new_ctx->mp_capable = 1;
-		new_ctx->fourth_ack = 1;
-		new_ctx->remote_key = subflow_req->remote_key;
-		new_ctx->local_key = subflow_req->local_key;
-	} else {
-		tcp_sk(newsk)->is_mptcp = 0;
-	}
+	new_ctx->mp_capable = 1;
+	new_ctx->fourth_ack = 1;
+	new_ctx->remote_key = subflow_req->remote_key;
+	new_ctx->local_key = subflow_req->local_key;
 }
 
 static struct tcp_ulp_ops subflow_ulp_ops __read_mostly = {
Signature · 1 line
2.21.0

--
Mat Martineau
Intel

author
#3 lore raw

[MPTCP] Re: [PATCH v2 1/7] Squash-to: "mptcp: Handle MP_CAPABLE options for outgoing connections"

Quoted 62 lines · Mat Martineau
Quoted 60 lines · Paolo Abeni

After upstream feedback, I just noticed that we actually don't clear the is_mptcp field on clone allocation failure.

Do that and additionally don't allocate at all the subflow if MPC handshake failed.

Note: we need to update accordingly accept on later patch

v1 -> v2:
- use sk_is_mptcp() in __mptcp_tcp_fallback() (Mat)

RFC -> v1:
- avoid assign statement inside the if statement (Florian)
- avoid rendundant conn = NULL (Mat)
- clear ulp data on fallback, or to avoid double free at close time

Signed-off-by Paolo Abeni <pabeni(a)redhat.com>

---
net/mptcp/protocol.c | 2 +-
net/mptcp/subflow.c | 33 +++++++++++++++++++++------------

2 files changed, 22 insertions(+), 13 deletions(-)
net/mptcp/protocol.c +1 -1
index 8bb3ecf87ee5..9120f75659b5 100644
@@ -42,7 +42,7 @@ static struct socket *__mptcp_tcp_fallback(const struct mptcp_sock *msk)
 
 	sock_owned_by_me((const struct sock *)msk);
 
-	if (!ssock || tcp_sk(ssock->sk)->is_mptcp)
+	if (!ssock || sk_is_mptcp(ssock->sk))
 		return NULL;
 
 	return ssock;
net/mptcp/subflow.c +9 -0
index b9aca17b0b91..cf4c05a6cfac 100644
@@ -254,6 +254,15 @@ static void subflow_ulp_release(struct sock *sk)
 	kfree_rcu(ctx, rcu);
 }
 
+static void subflow_ulp_fallback(struct sock *sk)
+{
+	struct inet_connection_sock *icsk = inet_csk(sk);
+
+	icsk->icsk_ulp_ops = NULL;
+	rcu_assign_pointer(icsk->icsk_ulp_data, NULL);
+	tcp_sk(sk)->is_mptcp = 0;
+}
+
 static void subflow_ulp_clone(const struct request_sock *req,
 			      struct sock *newsk,
 			      const gfp_t priority)
@@ -262,23 +271,23 @@ static void subflow_ulp_clone(const struct request_sock *req,
 	struct mptcp_subflow_context *old_ctx = mptcp_subflow_ctx(newsk);
 	struct mptcp_subflow_context *new_ctx;
 
Quoted 5 lines

net/mptcp/subflow.c static void subflow_ulp_clone(const struct request_sock *req, · line 274

Quoted 2 lines
net/mptcp/subflow.c +1 -1
-	/* newsk->sk_socket is NULL at this point */
+	if (!subflow_req->mp_capable) {

Does this logic need to be updated in patch 7 to allow mp_join? Matthieu ran in to a problem applying the series.

Yes, indeed! Thank you for catching this - I actually missed that while rebasing - and lack of MP_JOIN self-tests did not help :(

It should become:

	if (!subflow_req->mp_capable && !subflow_req->mp_join) {
		// ...

Thanks

Paolo

#11 lore raw
In reply to Mat Martineau

Hi Paolo, Mat,

Quoted 38 lines · Mat Martineau
Quoted 28 lines · Paolo Abeni

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places,
as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks,
is simpler then other alternatives but waste some space inside the subflow
struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

Quoted 6 lines

options.c  |    7 ------
protocol.c |   20 ++++++++---------
protocol.h |   15 ++++++++++++-
subflow.c  |   68
++++++++++++++++++++++++++++++++++++++++---------------------

4 files changed, 68 insertions(+), 42 deletions(-)
Quoted 3 lines

Hi Paolo -

Thanks for the fixes from v1. Looks good to me.

Thank you for the patches and the reviews!

Please check the "/!\" below

- e0350744cafc: "squashed" patch 1/7 in "mptcp: Handle MP_CAPABLE options for outgoing connections"
- 65850c198790: conflict in t/mptcp-Add-key-generation-and-token-tree
- 7a3cef638c7b: conflict in t/mptcp-Implement-MPTCP-receive-path
- fba261bbcdd9: conflict in t/mptcp-process-MP_CAPABLE-data-option /!\ comment is re-added below
- af9296ffbeec: conflict in t/mptcp-cope-with-later-TCP-fallback
- 55dbb555ec6c: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ I had to modify the first condition in subflow_ulp_clone()
- 7e25825cceea: mptcp:subflow: re-add removed comment in t/mptcp-process-MP_CAPABLE-data-option
- 5593f3432c76] Revert "mptcp:subflow: re-add removed comment" in t/mptcp-Add-handling-of-incoming-MP_JOIN-
- 5c6690820e0a..513c7bff2864: result

- df2d5cfd1573: "squashed" patch 2/7 in "mptcp: Create SUBFLOW socket for incoming connections"
- b146e9ab6e2a: conflict in t/mptcp-recvmsg-can-drain-data-from-multiple-subflows
- 6bc74228e82e: conflict in t/mptcp-increment-MIB-counters-in-a-few-places
- 513c7bff2864..dbf315c33403: result

- 3abec1c771df: "squashed" patch 3/7 in "mptcp: Add key generation and token tree"
- dbf315c33403..72aec0bc2ad9: result

- ecde144ffa56: "squashed" patch 4/7 in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- 006e52131d4f: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- b0ae53ced8cd: conflict in t/mptcp-Add-ADD_ADDR-handling
- d099fdd0460f: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 72aec0bc2ad9..1f5cf153a4b1: result

- 73afeb8aabbd: "squashed" patch 5/7 in "mptcp: Implement MPTCP receive path"
- 6259583be5a2: conflict in t/mptcp-Add-path-manager-interface
- 23f44e1993f4: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ tcp_state_change and tcp_write_space have been set for both like
in mptcp_net-next_export_v6.2
- 49007086b792: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 1f5cf153a4b1..803fb6ea75b0: result

- 5724921dc089: "squashed" patch 6/7 in "mptcp: cope with later TCP fallback"
/!\ the second part of the patch was already applied in a previous
conflict resolution
- 803fb6ea75b0..02e14c69386b: result

- aa031bb3cab2: "squashed" patch 7/7 in "mptcp: Add handling of incoming MP_JOIN requests"
- 6d39473b63da: "Signed-off-by" + "Co-developed-by"
- 02e14c69386b..f15fa3697153: result

Compilation is OK but tests are in progress.

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
#12 lore raw
Quoted 103 lines · Matthieu Baerts

Hi Paolo, Mat,

Quoted 39 lines · Mat Martineau
Quoted 29 lines · Paolo Abeni

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and
clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places,
as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks,
is simpler then other alternatives but waste some space inside the subflow
struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

Quoted 6 lines

options.c  |    7 ------
protocol.c |   20 ++++++++---------
protocol.h |   15 ++++++++++++-
subflow.c  |   68
++++++++++++++++++++++++++++++++++++++++---------------------

4 files changed, 68 insertions(+), 42 deletions(-)
Quoted 3 lines

Hi Paolo -

Thanks for the fixes from v1. Looks good to me.

Thank you for the patches and the reviews!

Please check the "/!\" below

- e0350744cafc: "squashed" patch 1/7 in "mptcp: Handle MP_CAPABLE options for outgoing connections"
- 65850c198790: conflict in t/mptcp-Add-key-generation-and-token-tree
- 7a3cef638c7b: conflict in t/mptcp-Implement-MPTCP-receive-path
- fba261bbcdd9: conflict in t/mptcp-process-MP_CAPABLE-data-option /!\ comment is re-added below
- af9296ffbeec: conflict in t/mptcp-cope-with-later-TCP-fallback
- 55dbb555ec6c: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
  /!\ I had to modify the first condition in subflow_ulp_clone()
- 7e25825cceea: mptcp:subflow: re-add removed comment in t/mptcp-process-MP_CAPABLE-data-option
- 5593f3432c76] Revert "mptcp:subflow: re-add removed comment" in t/mptcp-Add-handling-of-incoming-MP_JOIN-
- 5c6690820e0a..513c7bff2864: result

- df2d5cfd1573: "squashed" patch 2/7 in "mptcp: Create SUBFLOW socket for incoming connections"
- b146e9ab6e2a: conflict in t/mptcp-recvmsg-can-drain-data-from-multiple-subflows
- 6bc74228e82e: conflict in t/mptcp-increment-MIB-counters-in-a-few-places
- 513c7bff2864..dbf315c33403: result

- 3abec1c771df: "squashed" patch 3/7 in "mptcp: Add key generation and token tree"
- dbf315c33403..72aec0bc2ad9: result

- ecde144ffa56: "squashed" patch 4/7 in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- 006e52131d4f: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- b0ae53ced8cd: conflict in t/mptcp-Add-ADD_ADDR-handling
- d099fdd0460f: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 72aec0bc2ad9..1f5cf153a4b1: result

- 73afeb8aabbd: "squashed" patch 5/7 in "mptcp: Implement MPTCP receive path"
- 6259583be5a2: conflict in t/mptcp-Add-path-manager-interface
- 23f44e1993f4: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
  /!\ tcp_state_change and tcp_write_space have been set for both like
in mptcp_net-next_export_v6.2
- 49007086b792: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 1f5cf153a4b1..803fb6ea75b0: result

- 5724921dc089: "squashed" patch 6/7 in "mptcp: cope with later TCP fallback"
  /!\ the second part of the patch was already applied in a previous
conflict resolution
- 803fb6ea75b0..02e14c69386b: result

Quoted 6 lines

- aa031bb3cab2: "squashed" patch 7/7 in "mptcp: Add handling of incoming MP_JOIN requests"
- 6d39473b63da: "Signed-off-by" + "Co-developed-by"
- 02e14c69386b..f15fa3697153: result

Compilation is OK but tests are in progress.

A small additional fix to allow the compilation of each exported commit:

- 843c30e1447a: mptcp: fix compilation error in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- d27c2802c206: mptcp: fix compilation error in t/mptcp-process-MP_CAPABLE-data-option
- ed5fd3d9a3e8: conflict in t/mptcp-Add-path-manager-interface
- f15fa3697153..a8dcfeb3a5c6: result (empty, normal)

Tests are in progress.

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
author
#13 lore raw
Quoted 110 lines · Matthieu Baerts
Quoted 102 lines · Matthieu Baerts

Hi Paolo, Mat,

Quoted 38 lines · Mat Martineau
Quoted 29 lines · Paolo Abeni

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and
clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places,
as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks,
is simpler then other alternatives but waste some space inside the subflow
struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

Quoted 6 lines
options.c  |    7 ------
protocol.c |   20 ++++++++---------
protocol.h |   15 ++++++++++++-
subflow.c  |   68 
++++++++++++++++++++++++++++++++++++++++---------------------
4 files changed, 68 insertions(+), 42 deletions(-)
Quoted 3 lines

Hi Paolo -

Thanks for the fixes from v1. Looks good to me.

Thank you for the patches and the reviews!

Please check the "/!\" below

- e0350744cafc: "squashed" patch 1/7 in "mptcp: Handle MP_CAPABLE options for outgoing connections"
- 65850c198790: conflict in t/mptcp-Add-key-generation-and-token-tree
- 7a3cef638c7b: conflict in t/mptcp-Implement-MPTCP-receive-path
- fba261bbcdd9: conflict in t/mptcp-process-MP_CAPABLE-data-option /!\ comment is re-added below
- af9296ffbeec: conflict in t/mptcp-cope-with-later-TCP-fallback
- 55dbb555ec6c: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ I had to modify the first condition in subflow_ulp_clone()
- 7e25825cceea: mptcp:subflow: re-add removed comment in t/mptcp-process-MP_CAPABLE-data-option
- 5593f3432c76] Revert "mptcp:subflow: re-add removed comment" in t/mptcp-Add-handling-of-incoming-MP_JOIN-
- 5c6690820e0a..513c7bff2864: result

- df2d5cfd1573: "squashed" patch 2/7 in "mptcp: Create SUBFLOW socket for incoming connections"
- b146e9ab6e2a: conflict in t/mptcp-recvmsg-can-drain-data-from-multiple-subflows
- 6bc74228e82e: conflict in t/mptcp-increment-MIB-counters-in-a-few-places
- 513c7bff2864..dbf315c33403: result

- 3abec1c771df: "squashed" patch 3/7 in "mptcp: Add key generation and token tree"
- dbf315c33403..72aec0bc2ad9: result

- ecde144ffa56: "squashed" patch 4/7 in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- 006e52131d4f: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- b0ae53ced8cd: conflict in t/mptcp-Add-ADD_ADDR-handling
- d099fdd0460f: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 72aec0bc2ad9..1f5cf153a4b1: result

- 73afeb8aabbd: "squashed" patch 5/7 in "mptcp: Implement MPTCP receive path"
- 6259583be5a2: conflict in t/mptcp-Add-path-manager-interface
- 23f44e1993f4: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ tcp_state_change and tcp_write_space have been set for both like
in mptcp_net-next_export_v6.2
- 49007086b792: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 1f5cf153a4b1..803fb6ea75b0: result

- 5724921dc089: "squashed" patch 6/7 in "mptcp: cope with later TCP fallback"
/!\ the second part of the patch was already applied in a previous
conflict resolution
- 803fb6ea75b0..02e14c69386b: result

Quoted 6 lines

- aa031bb3cab2: "squashed" patch 7/7 in "mptcp: Add handling of incoming MP_JOIN requests"
- 6d39473b63da: "Signed-off-by" + "Co-developed-by"
- 02e14c69386b..f15fa3697153: result

Compilation is OK but tests are in progress.

Quoted 8 lines

A small additional fix to allow the compilation of each exported commit:

- 843c30e1447a: mptcp: fix compilation error in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- d27c2802c206: mptcp: fix compilation error in t/mptcp-process-MP_CAPABLE-data-option
- ed5fd3d9a3e8: conflict in t/mptcp-Add-path-manager-interface
- f15fa3697153..a8dcfeb3a5c6: result (empty, normal)

Thank you for all the great work!

I checked the mentioned relevant conflict commits, the delta vs my local tree and did some self-tests run. LGTM

Thanks,

Paolo

#14 lore raw

Hi Paolo,

Quoted 120 lines · Paolo Abeni
Quoted 110 lines · Matthieu Baerts
Quoted 102 lines · Matthieu Baerts

Hi Paolo, Mat,

Quoted 38 lines · Mat Martineau
Quoted 29 lines · Paolo Abeni

This series do real TCP fallback for passive MPTCP connection when ULP clone
fails: clear the 'is_mptcp' flag, reset overridden callback, icsk ops and
clear the ULP ctx.

Additionally uses the 'is_mptcp' flag to check for fallback in more places,
as suggested by Mat (patches 2, 4), cope with NULL ctx in subflow_syn_recv_sock() (patches 3, 7), and restore TCP callback on later fallback, too (patch 6) for consistency.

This still uses function pointers to store all the overriden TCP callbacks,
is simpler then other alternatives but waste some space inside the subflow
struct.

The rebased tree is available at:

https://github.com/pabeni/mptcp/tree/mptcp_net-next_export_v7.1

This is on top of export branch(a)b50a38e09bbc6182136836564945a323641a5039 (tag: export/20200109T154238)

v1 -> v2
- uses sk_is_mptcp() when possible (Mat)
- drop rendundant checks (Mat)

Quoted 6 lines
options.c  |    7 ------
protocol.c |   20 ++++++++---------
protocol.h |   15 ++++++++++++-
subflow.c  |   68
++++++++++++++++++++++++++++++++++++++++---------------------
4 files changed, 68 insertions(+), 42 deletions(-)
Quoted 3 lines

Hi Paolo -

Thanks for the fixes from v1. Looks good to me.

Thank you for the patches and the reviews!

Please check the "/!\" below

- e0350744cafc: "squashed" patch 1/7 in "mptcp: Handle MP_CAPABLE options for outgoing connections"
- 65850c198790: conflict in t/mptcp-Add-key-generation-and-token-tree
- 7a3cef638c7b: conflict in t/mptcp-Implement-MPTCP-receive-path
- fba261bbcdd9: conflict in t/mptcp-process-MP_CAPABLE-data-option /!\ comment is re-added below
- af9296ffbeec: conflict in t/mptcp-cope-with-later-TCP-fallback
- 55dbb555ec6c: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ I had to modify the first condition in subflow_ulp_clone()
- 7e25825cceea: mptcp:subflow: re-add removed comment in t/mptcp-process-MP_CAPABLE-data-option
- 5593f3432c76] Revert "mptcp:subflow: re-add removed comment" in t/mptcp-Add-handling-of-incoming-MP_JOIN-
- 5c6690820e0a..513c7bff2864: result

- df2d5cfd1573: "squashed" patch 2/7 in "mptcp: Create SUBFLOW socket for incoming connections"
- b146e9ab6e2a: conflict in t/mptcp-recvmsg-can-drain-data-from-multiple-subflows
- 6bc74228e82e: conflict in t/mptcp-increment-MIB-counters-in-a-few-places
- 513c7bff2864..dbf315c33403: result

- 3abec1c771df: "squashed" patch 3/7 in "mptcp: Add key generation and token tree"
- dbf315c33403..72aec0bc2ad9: result

- ecde144ffa56: "squashed" patch 4/7 in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- 006e52131d4f: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- b0ae53ced8cd: conflict in t/mptcp-Add-ADD_ADDR-handling
- d099fdd0460f: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 72aec0bc2ad9..1f5cf153a4b1: result

- 73afeb8aabbd: "squashed" patch 5/7 in "mptcp: Implement MPTCP receive path"
- 6259583be5a2: conflict in t/mptcp-Add-path-manager-interface
- 23f44e1993f4: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
/!\ tcp_state_change and tcp_write_space have been set for both like
in mptcp_net-next_export_v6.2
- 49007086b792: conflict in t/mptcp-Add-handling-of-outgoing-MP_JOIN-requests
- 1f5cf153a4b1..803fb6ea75b0: result

- 5724921dc089: "squashed" patch 6/7 in "mptcp: cope with later TCP fallback"
/!\ the second part of the patch was already applied in a previous
conflict resolution
- 803fb6ea75b0..02e14c69386b: result

Quoted 6 lines

- aa031bb3cab2: "squashed" patch 7/7 in "mptcp: Add handling of incoming MP_JOIN requests"
- 6d39473b63da: "Signed-off-by" + "Co-developed-by"
- 02e14c69386b..f15fa3697153: result

Compilation is OK but tests are in progress.

Quoted 8 lines

A small additional fix to allow the compilation of each exported commit:

- 843c30e1447a: mptcp: fix compilation error in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- d27c2802c206: mptcp: fix compilation error in t/mptcp-process-MP_CAPABLE-data-option
- ed5fd3d9a3e8: conflict in t/mptcp-Add-path-manager-interface
- f15fa3697153..a8dcfeb3a5c6: result (empty, normal)

Quoted 4 lines

Thank you for all the great work!

I checked the mentioned relevant conflict commits, the delta vs my local tree and did some self-tests run. LGTM

Glad to hear that it looks good! Thank you for having checked!

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium