Skip to contentSkip to conversation

Optimize struct mptcp_options_received

PATCH In review Peter Krystad 3 participants 7 messages Dec 12, 2019 – Dec 13, 2019

Subsystems (3)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

cover Optimize struct mptcp_options_received

Changes for part 1 commits. Conflicts are straightforward when squashed.

Peter Krystad (2):
mptcp: Move struct mptcp_options_received
mptcp: Remove version field from mptcp_options_received

 include/linux/tcp.h  | 19 +++++++++++--------
 net/mptcp/options.c  |  7 ++++---
 net/mptcp/protocol.h |  2 ++
 3 files changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.2
author
#1 lore raw

PATCH 1/2 mptcp: Move struct mptcp_options_received

Move struct mptcp_options_received out of enclosing tcp struct.

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
include/linux/tcp.h +12 -8
index 7c8a6f877900..36f5d8e53e25 100644
@@ -78,6 +78,17 @@ struct tcp_sack_block {
 #define TCP_SACK_SEEN     (1 << 0)   /*1 = peer is SACK capable, */
 #define TCP_DSACK_SEEN    (1 << 2)   /*1 = DSACK was received from peer*/
 
+#if IS_ENABLED(CONFIG_MPTCP)
+struct mptcp_options_received {
+	u64	sndr_key;
+	u64	rcvr_key;
+	u8	mp_capable : 1,
+		mp_join : 1,
+		dss : 1,
+		version : 4;
+};
+#endif
+
 struct tcp_options_received {
 /*	PAWS/RTTM data	*/
 	int	ts_recent_stamp;/* Time we stored ts_recent (for aging) */
@@ -96,14 +107,7 @@ struct tcp_options_received {
 	u16	user_mss;	/* mss requested by user in ioctl	*/
 	u16	mss_clamp;	/* Maximal mss, negotiated at connection setup */
 #if IS_ENABLED(CONFIG_MPTCP)
-	struct mptcp_options_received {
-		u64	sndr_key;
-		u64	rcvr_key;
-		u8	mp_capable : 1,
-			mp_join : 1,
-			dss : 1,
-			version : 4;
-	} mptcp;
+	struct mptcp_options_received	mptcp;
 #endif
 };
 
Signature · 1 line
2.17.2
author
#2 lore raw

PATCH 2/2 mptcp: Remove version field from mptcp_options_received

In reply to Peter Krystad

This field is not necessary, all version logic is performed in mptcp_parse_options().

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 include/linux/tcp.h  | 3 +--
 net/mptcp/options.c  | 7 ++++---
 net/mptcp/protocol.h | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)
include/linux/tcp.h +1 -2
index 36f5d8e53e25..e5859d671111 100644
@@ -84,8 +84,7 @@ struct mptcp_options_received {
 	u64	rcvr_key;
 	u8	mp_capable : 1,
 		mp_join : 1,
-		dss : 1,
-		version : 4;
+		dss : 1;
 };
 #endif
 
net/mptcp/options.c +4 -3
index 9e21b72b45b9..cd4c0c8de6e0 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 version;
 	u8 flags;
 
 	switch (subtype) {
@@ -28,8 +29,8 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 		    opsize != TCPOLEN_MPTCP_MPC_ACK)
 			break;
 
-		mp_opt->version = *ptr++ & MPTCP_VERSION_MASK;
-		if (mp_opt->version != 0)
+		version = *ptr++ & MPTCP_VERSION_MASK;
+		if (version != MPTCP_SUPPORTED_VERSION)
 			break;
 
 		flags = *ptr++;
@@ -146,7 +147,7 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
 			       (MPTCPOPT_MP_CAPABLE << 12) |
-			       ((MPTCP_VERSION_MASK & 0) << 8) |
+			       (MPTCP_SUPPORTED_VERSION << 8) |
 			       MPTCP_CAP_HMAC_SHA1);
 		put_unaligned_be64(opts->sndr_key, ptr);
 		ptr += 2;
net/mptcp/protocol.h +2 -0
index bd420bef44a0..c59cf8b220b0 100644
@@ -7,6 +7,8 @@
 #ifndef __MPTCP_PROTOCOL_H
 #define __MPTCP_PROTOCOL_H
 
+#define MPTCP_SUPPORTED_VERSION	0
+
 /* MPTCP option bits */
 #define OPTION_MPTCP_MPC_SYN	BIT(0)
 #define OPTION_MPTCP_MPC_SYNACK	BIT(1)
Signature · 1 line
2.17.2
#4 lore raw
In reply to Peter Krystad

Hi,

Quoted 11 lines · Peter Krystad

Changes for part 1 commits. Conflicts are straightforward when squashed.

Peter Krystad (2):
mptcp: Move struct mptcp_options_received
mptcp: Remove version field from mptcp_options_received

 include/linux/tcp.h  | 19 +++++++++++--------
 net/mptcp/options.c  |  7 ++++---
 net/mptcp/protocol.h |  2 ++
 3 files changed, 17 insertions(+), 11 deletions(-)

LGTM!

I was just wondering if we should drop the version field ;)

Thanks,

Paolo

p.s. 'ack' applies to the all the 4 patches version-related.

#3 lore raw

[MPTCP] Re: [PATCH 2/2] mptcp: Remove version field from mptcp_options_received

In reply to Peter Krystad

Hi Peter, Paolo,

Quoted 17 lines · Peter Krystad

This field is not necessary, all version logic is performed in mptcp_parse_options().

squashto: Handle MPTCP TCP options

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
  include/linux/tcp.h  | 3 +--
  net/mptcp/options.c  | 7 ++++---
  net/mptcp/protocol.h | 2 ++
  3 files changed, 7 insertions(+), 5 deletions(-)
include/linux/tcp.h +0 -0
index 36f5d8e53e25..e5859d671111 100644

include/linux/tcp.h struct mptcp_options_received { · line 87

Quoted 6 lines
include/linux/tcp.h +1 -2
@@ -84,8 +84,7 @@ struct mptcp_options_received {
  	u64	rcvr_key;
  	u8	mp_capable : 1,
  		mp_join : 1,
-		dss : 1,
-		version : 4;
+		dss : 1;

I am finishing the application of this patch but now I am wondering: do we really need to remove "version" field from there?

I understand that we only set and read it in mptcp_parse_option() but we now have a hole of 4 bits :)

Potentially later, we might want to keep the version we got to act differently. But this should not happen before years.

Anyway I am going to finish the application of this patch and we can see tomorrow if we have to put it back but I guess we don't.

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
#5 lore raw
In reply to Paolo Abeni

Hi Peter, Paolo,

Quoted 10 lines · Paolo Abeni

Hi,

Quoted 7 lines · Peter Krystad

Changes for part 1 commits. Conflicts are straightforward when squashed.

Peter Krystad (2):
mptcp: Move struct mptcp_options_received
mptcp: Remove version field from mptcp_options_received

Quoted 6 lines
Quoted 4 lines
  include/linux/tcp.h  | 19 +++++++++++--------
  net/mptcp/options.c  |  7 ++++---
  net/mptcp/protocol.h |  2 ++
  3 files changed, 17 insertions(+), 11 deletions(-)

LGTM!

Thank you for the patches and the reviews!

Because there are a few conflicts and these patches were created on top of "mptcp: Handle MPTCP TCP options" (and it is late for me :) ), may you check that at least the "result" is OK for you?

- ca28c8b4337c: "squashed" patch 1/2 in "mptcp: Handle MPTCP TCP options"
- 29ddc320cce4: "squashed" patch 2/2 in "mptcp: Handle MPTCP TCP options"
- cadaa98e433f: conflict in t/mptcp-Add-key-generation-and-token-tree
- 92e51f00d505: conflict in t/mptcp-Implement-MPTCP-receive-path
- 651f0bfd3c50: conflict in t/mptcp-move-from-sha1-v0-to-sha256-v1
- eca85f157716: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- 93ae416aea97: conflict in t/mptcp-Add-path-manager-interface
- 3466814d0772: conflict in t/mptcp-Add-ADD_ADDR-handling
- b3ce6ad38226: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- e000e15dedfd: fix how the conflict was solved in t/mptcp-Implement-MPTCP-receive-path
- 62e097f0112b: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- c5b8ad49fc3a..3549fa17fbd3: result

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

The result looks fine, thank you for your efforts!

Peter.

Quoted 47 lines · Matthieu Baerts

Hi Peter, Paolo,

Quoted 10 lines · Paolo Abeni

Hi,

Quoted 7 lines · Peter Krystad

Changes for part 1 commits. Conflicts are straightforward when squashed.

Peter Krystad (2):
mptcp: Move struct mptcp_options_received
mptcp: Remove version field from mptcp_options_received

Quoted 6 lines
Quoted 4 lines
  include/linux/tcp.h  | 19 +++++++++++--------
  net/mptcp/options.c  |  7 ++++---
  net/mptcp/protocol.h |  2 ++
  3 files changed, 17 insertions(+), 11 deletions(-)

LGTM!

Thank you for the patches and the reviews!

Because there are a few conflicts and these patches were created on top of "mptcp: Handle MPTCP TCP options" (and it is late for me :) ), may you check that at least the "result" is OK for you?

- ca28c8b4337c: "squashed" patch 1/2 in "mptcp: Handle MPTCP TCP options"
- 29ddc320cce4: "squashed" patch 2/2 in "mptcp: Handle MPTCP TCP options"
- cadaa98e433f: conflict in t/mptcp-Add-key-generation-and-token-tree
- 92e51f00d505: conflict in t/mptcp-Implement-MPTCP-receive-path
- 651f0bfd3c50: conflict in t/mptcp-move-from-sha1-v0-to-sha256-v1
- eca85f157716: conflict in t/mptcp-parse-and-emit-MP_CAPABLE-option-according-to-v1-spec
- 93ae416aea97: conflict in t/mptcp-Add-path-manager-interface
- 3466814d0772: conflict in t/mptcp-Add-ADD_ADDR-handling
- b3ce6ad38226: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- e000e15dedfd: fix how the conflict was solved in t/mptcp-Implement-MPTCP-receive-path
- 62e097f0112b: conflict in t/mptcp-Add-handling-of-incoming-MP_JOIN-requests
- c5b8ad49fc3a..3549fa17fbd3: result

Cheers;
Matt