Skip to contentSkip to conversation

Minor patches [Remaining two]

PATCH Superseded Peter Krystad 4 participants 10 messages Jun 8, 2019 – Jun 11, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

cover Minor patches [Remaining two]

Responding to comments and rebase.

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   | 73 ++++++++++++++++++++++++++++---------------
 3 files changed, 59 insertions(+), 55 deletions(-)
Signature · 1 line
2.17.2
author
#1 lore raw

PATCH 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 | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
net/mptcp/options.c +17 -16
index 1bee4a267fd8..cad1702323a3 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,29 @@ 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) ||
+		mp_opt->flags = *ptr++;
+		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) ==
+		    MPTCP_CAP_HMAC_SHA1) ||
 		    (opt_rx->mptcp.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 +87,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++;
 
@@ -399,10 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 
 		if (OPTION_MPTCP_MPC_SYN & opts->suboptions)
 			len = TCPOLEN_MPTCP_MPC_SYN;
-		else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)
-			len = TCPOLEN_MPTCP_MPC_SYNACK;
 		else
-			len = TCPOLEN_MPTCP_MPC_ACK;
+			len = TCPOLEN_MPTCP_MPC_SYNACK;
 
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
 			       (MPTCPOPT_MP_CAPABLE << 12) |
Signature · 1 line
2.17.2
#2 lore raw

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

Hi Peter,

Quoted 1 line · Peter Krystad

squashto: Handle MPTCP TCP options

Thank you for the new patch!

I have two questions, please see below.

Quoted 27 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
net/mptcp/options.c +3 -4
index 1bee4a267fd8..cad1702323a3 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,29 @@ 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)

net/mptcp/options.c void mptcp_parse_option(const unsigned char *ptr, int opsize, · line 40

Quoted 10 lines
net/mptcp/options.c +3 -3
 			break;
 
-		pr_debug("flags=%02x", *ptr);
-		opt_rx->mptcp.flags = *ptr++;
-		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
+		mp_opt->flags = *ptr++;
+		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) ==
+		    MPTCP_CAP_HMAC_SHA1) ||
 		    (opt_rx->mptcp.flags & MPTCP_CAP_EXTENSIBILITY))
 			break;

detail: could we use "mp_opt->flags" here instead of "opt_rx->mptcp.flags" used twice here above.

Quoted 31 lines
net/mptcp/options.c +10 -6
-		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 +87,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++;
 

net/mptcp/options.c void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) · line 406

Quoted 8 lines
net/mptcp/options.c +1 -3
@@ -399,10 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 
 		if (OPTION_MPTCP_MPC_SYN & opts->suboptions)
 			len = TCPOLEN_MPTCP_MPC_SYN;
-		else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)
-			len = TCPOLEN_MPTCP_MPC_SYNACK;
 		else
-			len = TCPOLEN_MPTCP_MPC_ACK;
+			len = TCPOLEN_MPTCP_MPC_SYNACK;

I am not sure to follow why you did this change. It doesn't seem to be related to the pr_debug() calls. Are you doing that because TCPOLEN_MPTCP_MPC_ACK == TCPOLEN_MPTCP_MPC_SYNACK == 20?

3 commits are modifying this first block in mptcp_write_options():
- 47168d901887 (mptcp: Handle MPTCP TCP options)
- 5e4c2881c7c9 (mptcp: Handle MP_CAPABLE options for outgoing connections)
- 447773e0cd92 (mptcp: Create SUBFLOW socket for incoming connections)

The first one introduces this block (with "OPTION_MPTCP_MPC_SYNACK"). The second one removes "OPTION_MPTCP_MPC_SYNACK" condition. The third one re-adds "OPTION_MPTCP_MPC_SYNACK".

Should we not introduce "OPTION_MPTCP_MPC_SYNACK" condition only at the 3rd patch and keep:

    else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)

for clarity purposes?

It's a detail but it is blocking me to know how to apply this patch correctly and avoid this add/remove/re-add :)

Cheers,
Matt

Quoted 3 lines
net/mptcp/options.c +0 -0
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
 			       (MPTCPOPT_MP_CAPABLE << 12) |
 
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

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

See my responses inline:

Quoted 38 lines · Matthieu Baerts

Hi Peter,

Quoted 1 line · Peter Krystad

squashto: Handle MPTCP TCP options

Thank you for the new patch!

I have two questions, please see below.

Quoted 29 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
net/mptcp/options.c +3 -4
index 1bee4a267fd8..cad1702323a3 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,29 @@ 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;
 
Quoted 11 lines

net/mptcp/options.c void mptcp_parse_option(const unsigned char *ptr, int opsize, · line 40

Quoted 8 lines
net/mptcp/options.c +3 -3
-		pr_debug("flags=%02x", *ptr);
-		opt_rx->mptcp.flags = *ptr++;
-		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
+		mp_opt->flags = *ptr++;
+		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) ==
+		    MPTCP_CAP_HMAC_SHA1) ||
 		    (opt_rx->mptcp.flags & MPTCP_CAP_EXTENSIBILITY))
 			break;

detail: could we use "mp_opt->flags" here instead of "opt_rx->mptcp.flags" used twice here above.

Sure.

Quoted 32 lines
Quoted 32 lines
net/mptcp/options.c +10 -6
-		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 +87,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++;
 
@@ -399,10 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 
Quoted 11 lines

net/mptcp/options.c void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) · line 406

Quoted 7 lines
net/mptcp/options.c +1 -3
 		if (OPTION_MPTCP_MPC_SYN & opts->suboptions)
 			len = TCPOLEN_MPTCP_MPC_SYN;
-		else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)
-			len = TCPOLEN_MPTCP_MPC_SYNACK;
 		else
-			len = TCPOLEN_MPTCP_MPC_ACK;
+			len = TCPOLEN_MPTCP_MPC_SYNACK;

I am not sure to follow why you did this change. It doesn't seem to be related to the pr_debug() calls. Are you doing that because TCPOLEN_MPTCP_MPC_ACK == TCPOLEN_MPTCP_MPC_SYNACK == 20?

I'll pull this out of the patch, not sure why I did this here either, it was fine as is.

Quoted 9 lines

3 commits are modifying this first block in mptcp_write_options():
- 47168d901887 (mptcp: Handle MPTCP TCP options)
- 5e4c2881c7c9 (mptcp: Handle MP_CAPABLE options for outgoing connections)
- 447773e0cd92 (mptcp: Create SUBFLOW socket for incoming connections)

The first one introduces this block (with "OPTION_MPTCP_MPC_SYNACK"). The second one removes "OPTION_MPTCP_MPC_SYNACK" condition. The third one re-adds "OPTION_MPTCP_MPC_SYNACK".

Quoted 6 lines

Should we not introduce "OPTION_MPTCP_MPC_SYNACK" condition only at the 3rd patch and keep:

    else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)

for clarity purposes?

Yes, use of the OPTION_MPTCP_MPC_SYNACK condition should be added by the "incoming connections" commit. A long time ago I split a single commit into the current "incoming" and "outgoing" commits, and did not get this part quite clean enough.

Peter.

Quoted 10 lines

It's a detail but it is blocking me to know how to apply this patch correctly and avoid this add/remove/re-add :)

Cheers,
Matt

Quoted 3 lines
net/mptcp/options.c +0 -0
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
 			       (MPTCPOPT_MP_CAPABLE << 12) |
 
#4 lore raw

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

Hi Peter,

Quoted 100 lines · Peter Krystad

See my responses inline:

Quoted 38 lines · Matthieu Baerts

Hi Peter,

Quoted 1 line · Peter Krystad

squashto: Handle MPTCP TCP options

Thank you for the new patch!

I have two questions, please see below.

Quoted 29 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
net/mptcp/options.c +3 -4
index 1bee4a267fd8..cad1702323a3 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,29 @@ 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;
 
Quoted 11 lines

net/mptcp/options.c void mptcp_parse_option(const unsigned char *ptr, int opsize, · line 40

Quoted 8 lines
net/mptcp/options.c +3 -3
-		pr_debug("flags=%02x", *ptr);
-		opt_rx->mptcp.flags = *ptr++;
-		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
+		mp_opt->flags = *ptr++;
+		if (!((opt_rx->mptcp.flags & MPTCP_CAP_FLAG_MASK) ==
+		    MPTCP_CAP_HMAC_SHA1) ||
 		    (opt_rx->mptcp.flags & MPTCP_CAP_EXTENSIBILITY))
 			break;

detail: could we use "mp_opt->flags" here instead of "opt_rx->mptcp.flags" used twice here above.

Sure.

Quoted 32 lines
Quoted 32 lines
net/mptcp/options.c +10 -6
-		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 +87,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++;
 
@@ -399,10 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 
Quoted 11 lines

net/mptcp/options.c void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts) · line 406

Quoted 7 lines
net/mptcp/options.c +1 -3
 		if (OPTION_MPTCP_MPC_SYN & opts->suboptions)
 			len = TCPOLEN_MPTCP_MPC_SYN;
-		else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)
-			len = TCPOLEN_MPTCP_MPC_SYNACK;
 		else
-			len = TCPOLEN_MPTCP_MPC_ACK;
+			len = TCPOLEN_MPTCP_MPC_SYNACK;

I am not sure to follow why you did this change. It doesn't seem to be related to the pr_debug() calls. Are you doing that because TCPOLEN_MPTCP_MPC_ACK == TCPOLEN_MPTCP_MPC_SYNACK == 20?

Quoted 2 lines

I'll pull this out of the patch, not sure why I did this here either, it was fine as is.

Thank you for this new patch!

Quoted 12 lines
Quoted 12 lines

3 commits are modifying this first block in mptcp_write_options():
- 47168d901887 (mptcp: Handle MPTCP TCP options)
- 5e4c2881c7c9 (mptcp: Handle MP_CAPABLE options for outgoing connections)
- 447773e0cd92 (mptcp: Create SUBFLOW socket for incoming connections)

The first one introduces this block (with "OPTION_MPTCP_MPC_SYNACK"). The second one removes "OPTION_MPTCP_MPC_SYNACK" condition. The third one re-adds "OPTION_MPTCP_MPC_SYNACK".

Should we not introduce "OPTION_MPTCP_MPC_SYNACK" condition only at the 3rd patch and keep:

Quoted 8 lines
Quoted 3 lines
    else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions)

for clarity purposes?

Yes, use of the OPTION_MPTCP_MPC_SYNACK condition should be added by the "incoming connections" commit. A long time ago I split a single commit into the current "incoming" and "outgoing" commits, and did not get this part quite clean enough.

Thank you for this explanation!
I just cleaned that!

- f1eea07b5639: clean "mptcp: Handle MPTCP TCP options"
- no signed-off modified for this
- 3a58fe749160..6614ebdd54b7: result: the code is still the same as before

Cheers,
Matt

Quoted 14 lines

Peter.

Quoted 10 lines

It's a detail but it is blocking me to know how to apply this patch correctly and avoid this add/remove/re-add :)

Cheers,
Matt

Quoted 3 lines
net/mptcp/options.c +0 -0
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
 			       (MPTCPOPT_MP_CAPABLE << 12) |
 
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
#5 lore raw

PATCH 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 cad1702323a3..a5a6772f1268 100644
@@ -250,12 +250,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;
@@ -268,17 +269,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)) {
@@ -339,6 +338,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
#6 lore raw

Re: [MPTCP] [PATCH 2/2] mptcp: Refactor mptcp_established_options() to single hook

Quoted 11 lines · 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(-)

...

Quoted 4 lines
net/mptcp/options.c +0 -0
index cad1702323a3..a5a6772f1268 100644

...

Quoted 20 lines
net/mptcp/options.c +16 -0
@@ -339,6 +338,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;

net/mptcp/options.c bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, · line 366

Quoted 10 lines
net/mptcp/options.c +7 -0
+		remaining -= opt_size;
+		return true;
+	}
+
+	return false;
+}
+
 bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
 			  struct mptcp_out_options *opts)
 {

Given that you're thinking of introducing changes in the mp vs. dss code blocks above, and have consolidated the mp_capable check, this looks ready to merge. Thanks, Peter.

--
Mat Martineau
Intel

#7 lore raw

Re: [MPTCP] [PATCH 2/2] mptcp: Refactor mptcp_established_options() to single hook

In reply to Peter Krystad

Hi Peter, Paolo, Mat,

Quoted 4 lines · 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

Thank you for the new version of the patch and the reviews!

- 98555b04a8d9: "squashed" in "mptcp: Write MPTCP DSS headers to outgoing data packets"
- da0f223d5698: signed-off
- no conflicts
- 7311dd424a7e..fc816436135c: result

Note that I had to do an extra modification to fix a compilation issue when CONFIG_MPTCP is not set, see 6e78ea220386 (mptcp: fix compilation without CONFIG_MPTCP) or below:

Quoted 46 lines
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 +3 -14
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)

include/net/mptcp.h static inline bool mptcp_synack_options(const struct request_sock *req, · line 118

Quoted 8 lines
include/net/mptcp.h +3 -1
@@ -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);

I had to remove the semi-colon at the end of this line to fix a compilation issue.

Please also note that I saw checkpatch.pl forces us to place the star next to the variable name:

struct mptcp_out_options *opts

instead of

struct mptcp_out_options* opts

I will try to fix a maximum of these checkpatch.pl issues once the MP_JOIN support is added in our repo and before sending patches to 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
#8 lore raw
In reply to Peter Krystad

Hi,

Quoted 11 lines · Peter Krystad

Responding to comments and rebase.

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   | 73 ++++++++++++++++++++++++++++---------------
 3 files changed, 59 insertions(+), 55 deletions(-)

Thanks Peter for following up with this, LGTM!

I think there are still a couple of checkpatch issues, but they could be handled separatelly, as per Matthieu email.

Cheers,

Paolo

#9 lore raw
In reply to Peter Krystad

Hi Peter,

Quoted 5 lines · Peter Krystad

Responding to comments and rebase.

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

I just applied your second patch in the repo but not the first one:
please see the corresponding email to see what is blocking me.

I can also apply everything except the small change at the end of this second patch and see what to do later. I mean: I can help integrating a part of it not to block the release of your MP_JOIN support.

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