Skip to contentSkip to conversation

mptcp: Remove flags field from struct mptcp_options_received

PATCH In review Peter Krystad 3 participants 4 messages Dec 5, 2019 – Dec 6, 2019

Subsystems (3)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

PATCH 1/1 mptcp: Remove flags field from struct mptcp_options_received

This field is only used temporarily while parsing options, use a local variable instead.

Also move key fields to final position and fix indents.

Formatted to apply directly to Handle MPTCP TCP options.

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h |  7 +++----
 net/mptcp/options.c | 17 ++++++++---------
 2 files changed, 11 insertions(+), 13 deletions(-)
include/linux/tcp.h +3 -4
index da2a281e2c98..7c8a6f877900 100644
@@ -97,13 +97,12 @@ struct tcp_options_received {
 	u16	mss_clamp;	/* Maximal mss, negotiated at connection setup */
 #if IS_ENABLED(CONFIG_MPTCP)
 	struct mptcp_options_received {
-		u8      mp_capable : 1,
+		u64	sndr_key;
+		u64	rcvr_key;
+		u8	mp_capable : 1,
 			mp_join : 1,
 			dss : 1,
 			version : 4;
-		u8      flags;
-		u64     sndr_key;
-		u64     rcvr_key;
 	} mptcp;
 #endif
 };
net/mptcp/options.c +8 -9
index adf65d3ff27b..a3dc787e7408 100644
@@ -14,6 +14,7 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 {
 	struct mptcp_options_received *mp_opt = &opt_rx->mptcp;
 	u8 subtype = *ptr >> 4;
+	u8 flags;
 
 	switch (subtype) {
 	/* MPTCPOPT_MP_CAPABLE
@@ -31,9 +32,9 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 		if (mp_opt->version != 0)
 			break;
 
-		mp_opt->flags = *ptr++;
-		if (!((mp_opt->flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
-		    (mp_opt->flags & MPTCP_CAP_EXTENSIBILITY))
+		flags = *ptr++;
+		if (!((flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA1) ||
+		    (flags & MPTCP_CAP_EXTENSIBILITY))
 			break;
 
 		/* RFC 6824, Section 3.1:
@@ -49,7 +50,7 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 		 *
 		 * We don't implement DSS checksum - fall back to TCP.
 		 */
-		if (mp_opt->flags & MPTCP_CAP_CHECKSUM_REQD)
+		if (flags & MPTCP_CAP_CHECKSUM_REQD)
 			break;
 
 		mp_opt->mp_capable = 1;
@@ -59,12 +60,10 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 		if (opsize == TCPOLEN_MPTCP_MPC_SYNACK) {
 			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);
+			pr_debug("MP_CAPABLE sndr=%llu, rcvr=%llu",
+				 mp_opt->sndr_key, mp_opt->rcvr_key);
 		} else {
-			pr_debug("MP_CAPABLE flags=%x, sndr=%llu",
-				 mp_opt->flags, mp_opt->sndr_key);
+			pr_debug("MP_CAPABLE sndr=%llu", mp_opt->sndr_key);
 		}
 		break;
 
Signature · 1 line
2.17.2
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Peter Krystad

This field is only used temporarily while parsing options, use a local variable instead.

Also move key fields to final position and fix indents.

Formatted to apply directly to Handle MPTCP TCP options.

Quoted 7 lines

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h |  7 +++----
 net/mptcp/options.c | 17 ++++++++---------
 2 files changed, 11 insertions(+), 13 deletions(-)

LGTM,

Acked-by Davide Caratti <dcaratti(a)redhat.com>
author
#2 lore raw

Davide, Matt -

Thanks Davide.

This patch and the other like it are all I plan to do for part 1 for "optimizing struct mptcp_received_options". The other MPTCP options that really grow the size are introduced after kselftest commit.

Now that we will be v1 past kselftest I will need to modify the ADD_ADDR handling for v1 change, and this will then effect how the struct mptcp_received_options is optimized.

Peter.

Quoted 21 lines · Davide Caratti
Quoted 7 lines · Peter Krystad

This field is only used temporarily while parsing options, use a local variable instead.

Also move key fields to final position and fix indents.

Formatted to apply directly to Handle MPTCP TCP options.

Quoted 7 lines

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h |  7 +++----
 net/mptcp/options.c | 17 ++++++++---------
 2 files changed, 11 insertions(+), 13 deletions(-)

LGTM,

Acked-by Davide Caratti <dcaratti(a)redhat.com>
#3 lore raw
In reply to Davide Caratti

Hi Peter, Davide,

Quoted 16 lines · Davide Caratti
Quoted 7 lines · Peter Krystad

This field is only used temporarily while parsing options, use a local variable instead.

Also move key fields to final position and fix indents.

Formatted to apply directly to Handle MPTCP TCP options.

Quoted 7 lines

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
  include/linux/tcp.h |  7 +++----
  net/mptcp/options.c | 17 ++++++++---------
  2 files changed, 11 insertions(+), 13 deletions(-)
Quoted 3 lines

LGTM,

Acked-by Davide Caratti <dcaratti(a)redhat.com>

Thank you for the patch and the review!

- 8be6e97e540a: "squashed" in "mptcp: Handle MPTCP TCP options"
- d6eeffa1a019: conflict in t/mptcp-Implement-MPTCP-receive-path
- 504ee582ba86: conflict in t/mptcp-move-from-sha1-v0-to-sha256-v1
- 7ba44f0d910a: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- 3cd04070f4de: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- 7c57362bfddb..b81566586cde: result

(I also fixed a few tabs/spaces when I had the opportunity: when I had conflicts when new fields were introduced, not using tabs)

Tests + export 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