Skip to contentSkip to conversation

Minor patches [Remaining two]

PATCH In review Peter Krystad 2 participants 5 messages Jun 11, 2019

Subsystems (3)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

v2 cover Minor patches [Remaining two]

Responding to comments and rebase.

v2 - fix mp_opt usage and remove changes to mptcp_write_options logic.

Peter Krystad (2):
mptcp: reduce number of pr_debug() calls.
mptcp: Refactor mptcp_established_options() to single hook

 include/net/mptcp.h   | 21 ++++---------
 net/ipv4/tcp_output.c | 20 ++++---------
 net/mptcp/options.c   | 70 +++++++++++++++++++++++++++++--------------
 3 files changed, 58 insertions(+), 53 deletions(-)
Signature · 1 line
2.17.2
author
#1 lore raw

PATCH v2 1/2 mptcp: reduce number of pr_debug() calls.

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)
net/mptcp/options.c +16 -14
index 1bee4a267fd8..a6ab6cef4a44 100644
@@ -13,7 +13,7 @@
 void mptcp_parse_option(const unsigned char *ptr, int opsize,
 			struct tcp_options_received *opt_rx)
 {
-	struct mptcp_options_received *mp_opt;
+	struct mptcp_options_received *mp_opt = &opt_rx->mptcp;
 	u8 subtype = *ptr >> 4;
 	int expected_opsize;
 
@@ -29,25 +29,28 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 		    opsize != TCPOLEN_MPTCP_MPC_SYNACK)
 			break;
 
-		pr_debug("MP_CAPABLE");
-		opt_rx->mptcp.version = *ptr++ & MPTCPOPT_VERSION_MASK;
-		if (opt_rx->mptcp.version != 0)
+		mp_opt->version = *ptr++ & MPTCPOPT_VERSION_MASK;
+		if (mp_opt->version != 0)
 			break;
 
-		pr_debug("flags=%02x", *ptr);
-		opt_rx->mptcp.flags = *ptr++;
-		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
-		    (opt_rx->mptcp.flags & MPTCP_CAP_EXTENSIBILITY))
+		mp_opt->flags = *ptr++;
+		if (!((mp_opt->flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
+		    (mp_opt->flags & MPTCP_CAP_EXTENSIBILITY))
 			break;
 
-		opt_rx->mptcp.mp_capable = 1;
-		opt_rx->mptcp.sndr_key = get_unaligned_be64(ptr);
-		pr_debug("sndr_key=%llu", opt_rx->mptcp.sndr_key);
+		mp_opt->mp_capable = 1;
+		mp_opt->sndr_key = get_unaligned_be64(ptr);
 		ptr += 8;
+
 		if (opsize == TCPOLEN_MPTCP_MPC_SYNACK) {
-			opt_rx->mptcp.rcvr_key = get_unaligned_be64(ptr);
-			pr_debug("rcvr_key=%llu", opt_rx->mptcp.rcvr_key);
+			mp_opt->rcvr_key = get_unaligned_be64(ptr);
 			ptr += 8;
+			pr_debug("MP_CAPABLE flags=%x, sndr=%llu, rcvr=%llu",
+				 mp_opt->flags, mp_opt->sndr_key,
+				 mp_opt->rcvr_key);
+		} else {
+			pr_debug("MP_CAPABLE flags=%x, sndr=%llu",
+				 mp_opt->flags, mp_opt->sndr_key);
 		}
 		break;
 
@@ -83,7 +86,6 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 	 */
 	case MPTCPOPT_DSS:
 		pr_debug("DSS");
-		mp_opt = &opt_rx->mptcp;
 		mp_opt->dss = 1;
 		ptr++;
 
Signature · 1 line
2.17.2
#2 lore raw

Re: [MPTCP] [PATCH v2 1/2] mptcp: reduce number of pr_debug() calls.

Hi Peter,

Quoted 1 line · Peter Krystad

squashto: Handle MPTCP TCP options

Thank you for this v2!

- 8c31f2a73c52: "squashed" in "mptcp: Handle MPTCP TCP options"
- f435387d7a74: conflict
- 3dbe13718918: conflict
- 6614ebdd54b7..076a9a1a7cc8: result

Tests are good, Belgium won, it seems everything is good to finish preparing these patches for Eric!

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
#3 lore raw

PATCH v2 2/2 mptcp: Refactor mptcp_established_options() to single hook

In reply to Peter Krystad

Make there be only one callout from tcp_output.c for this hook. Includes refactoring from the first patch of the MP_JOIN RFC.

squashto: Write MPTCP DSS headers

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/net/mptcp.h   | 21 ++++++---------------
 net/ipv4/tcp_output.c | 20 +++++---------------
 net/mptcp/options.c   | 40 +++++++++++++++++++++++++++++++---------
 3 files changed, 42 insertions(+), 39 deletions(-)
include/net/mptcp.h +6 -15
index d84489adbd86..ec3d7f7e5f45 100644
@@ -57,13 +57,11 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 bool mptcp_syn_options(struct sock *sk, unsigned int *size,
 			       struct mptcp_out_options* opts);
 void mptcp_rcv_synsent(struct sock *sk);
-bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
-				   unsigned int *size, unsigned int remaining,
-				   struct mptcp_out_options* opts);
 bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
 			  struct mptcp_out_options *opts);
-bool mptcp_established_options(struct sock *sk, unsigned int *size,
-				       struct mptcp_out_options *opts);
+bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
+			       unsigned int *size, unsigned int remaining,
+			       struct mptcp_out_options* opts);
 
 void mptcp_attach_dss(struct sock *sk, struct sk_buff *skb,
 		      struct tcp_options_received *opt_rx);
@@ -106,15 +104,6 @@ static inline void mptcp_rcv_synsent(struct sock *sk)
 {
 }
 
-static inline bool mptcp_established_options_dss(struct sock *sk,
-						 struct sk_buff *skb,
-						 unsigned int *size,
-						 unsigned int remaining,
-						 struct mptcp_out_options* opts)
-{
-	return false;
-}
-
 static inline bool mptcp_synack_options(const struct request_sock *req,
 					unsigned int *size,
 					struct mptcp_out_options *opts)
@@ -123,8 +112,10 @@ static inline bool mptcp_synack_options(const struct request_sock *req,
 }
 
 static inline bool mptcp_established_options(struct sock *sk,
+					     struct sk_buff *skb,
 					     unsigned int *size,
-					     struct mptcp_out_options *opts)
+					     unsigned int remaining,
+					     struct mptcp_out_options* opts);
 {
 	return false;
 }
net/ipv4/tcp_output.c +5 -15
index 0b4865c55e4e..08675fd0f070 100644
@@ -796,22 +796,12 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb
 	 */
 	if (sk_is_mptcp(sk)) {
 		unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
-		unsigned int opt_size;
+		unsigned int opt_size = 0;
 
-		if (mptcp_established_options(sk, &opt_size, &opts->mptcp)) {
-			if (remaining >= opt_size) {
-				opts->options |= OPTION_MPTCP;
-				size += opt_size;
-			}
-		} else {
-			unsigned int dss_size;
-
-			if (mptcp_established_options_dss(sk, skb, &dss_size,
-							  remaining,
-							  &opts->mptcp)) {
-				opts->options |= OPTION_MPTCP;
-				size += dss_size;
-			}
+		if (mptcp_established_options(sk, skb, &opt_size, remaining,
+					      &opts->mptcp)) {
+			opts->options |= OPTION_MPTCP;
+			size += opt_size;
 		}
 	}
 
net/mptcp/options.c +31 -9
index a6ab6cef4a44..d285a33cd480 100644
@@ -249,12 +249,13 @@ void mptcp_rcv_synsent(struct sock *sk)
 	}
 }
 
-bool mptcp_established_options(struct sock *sk, unsigned int *size,
-			       struct mptcp_out_options *opts)
+static bool mptcp_established_options_mp(struct sock *sk, unsigned int *size,
+					 unsigned int remaining,
+					 struct mptcp_out_options *opts)
 {
 	struct subflow_context *subflow = subflow_ctx(sk);
 
-	if (subflow->mp_capable && !subflow->fourth_ack) {
+	if (!subflow->fourth_ack && remaining >= TCPOLEN_MPTCP_MPC_ACK) {
 		opts->suboptions = OPTION_MPTCP_MPC_ACK;
 		opts->sndr_key = subflow->local_key;
 		opts->rcvr_key = subflow->remote_key;
@@ -267,17 +268,15 @@ bool mptcp_established_options(struct sock *sk, unsigned int *size,
 	return false;
 }
 
-bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
-				   unsigned int *size, unsigned int remaining,
-				   struct mptcp_out_options *opts)
+static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
+					  unsigned int *size,
+					  unsigned int remaining,
+					  struct mptcp_out_options *opts)
 {
 	unsigned int dss_size = 0;
 	struct mptcp_ext *mpext;
 	unsigned int ack_size;
 
-	if (!subflow_ctx(sk)->mp_capable)
-		return false;
-
 	mpext = skb ? mptcp_get_ext(skb) : NULL;
 
 	if (!skb || (mpext && mpext->use_map)) {
@@ -338,6 +337,29 @@ bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	return true;
 }
 
+bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
+			       unsigned int *size, unsigned int remaining,
+			       struct mptcp_out_options *opts)
+{
+	unsigned int opt_size = 0;
+
+	if (!subflow_ctx(sk)->mp_capable)
+		return false;
+
+	if (mptcp_established_options_mp(sk, &opt_size, remaining, opts)) {
+		*size += opt_size;
+		remaining -= opt_size;
+		return true;
+	} else if (mptcp_established_options_dss(sk, skb, &opt_size, remaining,
+					       opts)) {
+		*size += opt_size;
+		remaining -= opt_size;
+		return true;
+	}
+
+	return false;
+}
+
 bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
 			  struct mptcp_out_options *opts)
 {
Signature · 1 line
2.17.2
#4 lore raw
In reply to Peter Krystad

Hi Peter,

Quoted 3 lines · Peter Krystad

Responding to comments and rebase.

v2 - fix mp_opt usage and remove changes to mptcp_write_options logic.

Thank you for this new version!
Is the second patch the exact same one as the previous version I applied in commit 98555b04a8d9?

https://github.com/multipath-tcp/mptcp_net-next/commit/98555b04a8d9

Best regards,
Matt

Quoted 9 lines

Peter Krystad (2):
mptcp: reduce number of pr_debug() calls.
mptcp: Refactor mptcp_established_options() to single hook

 include/net/mptcp.h   | 21 ++++---------
 net/ipv4/tcp_output.c | 20 ++++---------
 net/mptcp/options.c   | 70 +++++++++++++++++++++++++++++--------------
 3 files changed, 58 insertions(+), 53 deletions(-)
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