Skip to contentSkip to conversation

mptcp: Add explicit check for protocol version

PATCH In review Peter Krystad 3 participants 3 messages May 21, 2019 – May 22, 2019

Subsystems (2)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

PATCH 1/1 mptcp: Add explicit check for protocol version

Currently only MPTCP v0 is supported so ignore v1 MP_CAPABLE option.

Also, make sure zeros are shifted to the correct position...

Squash to "Handle MPTCP TCP options".

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/mptcp/options.c +6 -3
index c71e40f6f06a..9b9b9c9390c1 100644
@@ -30,8 +30,11 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 			break;
 
 		pr_debug("MP_CAPABLE");
-		opt_rx->mptcp.mp_capable = 1;
 		opt_rx->mptcp.version = *ptr++ & MPTCPOPT_VERSION_MASK;
+		if (opt_rx->mptcp.version != 0)
+			break;
+
+		opt_rx->mptcp.mp_capable = 1;
 		pr_debug("flags=%02x", *ptr);
 		opt_rx->mptcp.flags = *ptr++;
 		opt_rx->mptcp.sndr_key = get_unaligned_be64(ptr);
@@ -399,8 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 			len = TCPOLEN_MPTCP_MPC_ACK;
 
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
-			       (MPTCPOPT_MP_CAPABLE << 20) |
-			       ((MPTCPOPT_VERSION_MASK & 0) << 16) |
+			       (MPTCPOPT_MP_CAPABLE << 12) |
+			       ((MPTCPOPT_VERSION_MASK & 0) << 8) |
 			       MPTCP_CAP_HMAC_SHA1);
 		put_unaligned_be64(opts->sndr_key, ptr);
 		ptr += 2;
Signature · 1 line
2.17.2
#1 lore raw
Quoted 6 lines · Peter Krystad

Currently only MPTCP v0 is supported so ignore v1 MP_CAPABLE option.

Also, make sure zeros are shifted to the correct position...

Squash to "Handle MPTCP TCP options".

Thanks Peter, patch looks ready to merge.

Mat

Quoted 35 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>

---
net/mptcp/options.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
net/mptcp/options.c +6 -3
index c71e40f6f06a..9b9b9c9390c1 100644
@@ -30,8 +30,11 @@ void mptcp_parse_option(const unsigned char *ptr, int opsize,
 			break;
 
 		pr_debug("MP_CAPABLE");
-		opt_rx->mptcp.mp_capable = 1;
 		opt_rx->mptcp.version = *ptr++ & MPTCPOPT_VERSION_MASK;
+		if (opt_rx->mptcp.version != 0)
+			break;
+
+		opt_rx->mptcp.mp_capable = 1;
 		pr_debug("flags=%02x", *ptr);
 		opt_rx->mptcp.flags = *ptr++;
 		opt_rx->mptcp.sndr_key = get_unaligned_be64(ptr);
@@ -399,8 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
 			len = TCPOLEN_MPTCP_MPC_ACK;
 
 		*ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
-			       (MPTCPOPT_MP_CAPABLE << 20) |
-			       ((MPTCPOPT_VERSION_MASK & 0) << 16) |
+			       (MPTCPOPT_MP_CAPABLE << 12) |
+			       ((MPTCPOPT_VERSION_MASK & 0) << 8) |
 			       MPTCP_CAP_HMAC_SHA1);
 		put_unaligned_be64(opts->sndr_key, ptr);
 		ptr += 2;
Signature · 1 line
2.17.2

--
Mat Martineau
Intel

#2 lore raw

Hi Peter, Mat,

Quoted 11 lines · Mat Martineau
Quoted 6 lines · Peter Krystad

Currently only MPTCP v0 is supported so ignore v1 MP_CAPABLE option.

Also, make sure zeros are shifted to the correct position...

Squash to "Handle MPTCP TCP options".

Thanks Peter, patch looks ready to merge.

Thank you for the fix and the review!

Just squashed as asked.

- squash: 06eaaf5cd641 (with a small conflict)
- update of the commit message: b14c889ea79c (mention which version is supported)
- conflict: 6ffdacc999da (opposite as before)
- result: 182f21f25f6a..bcf4fe51494f (from TopGit)
- exported commit: 09df85bafe0f

Cheers,
Matt

Quoted 50 lines

Mat

Quoted 37 lines
Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>

---
net/mptcp/options.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
net/mptcp/options.c +4 -1
index c71e40f6f06a..9b9b9c9390c1 100644
@@ -30,8 +30,11 @@ void mptcp_parse_option(const unsigned char *ptr,
 int opsize,
             break;
 
         pr_debug("MP_CAPABLE");
-        opt_rx->mptcp.mp_capable = 1;
         opt_rx->mptcp.version = *ptr++ & MPTCPOPT_VERSION_MASK;
+        if (opt_rx->mptcp.version != 0)
+            break;
+
+        opt_rx->mptcp.mp_capable = 1;
         pr_debug("flags=%02x", *ptr);
         opt_rx->mptcp.flags = *ptr++;

        opt_rx->mptcp.sndr_key = get_unaligned_be64(ptr);

net/mptcp/options.c +2 -2
@@ -399,8 +402,8 @@ void mptcp_write_options(__be32 *ptr, struct
 mptcp_out_options *opts)
             len = TCPOLEN_MPTCP_MPC_ACK;
 
         *ptr++ = htonl((TCPOPT_MPTCP << 24) | (len << 16) |
-                   (MPTCPOPT_MP_CAPABLE << 20) |
-                   ((MPTCPOPT_VERSION_MASK & 0) << 16) |
+                   (MPTCPOPT_MP_CAPABLE << 12) |
+                   ((MPTCPOPT_VERSION_MASK & 0) << 8) |
                    MPTCP_CAP_HMAC_SHA1);
         put_unaligned_be64(opts->sndr_key, ptr);

        ptr += 2;
--
2.17.2

Signature · 6 lines
Mat Martineau
Intel
_______________________________________________
mptcp mailing list
mptcp(a)lists.01.org
https://lists.01.org/mailman/listinfo/mptcp
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