Skip to contentSkip to conversation

mptcp: using TOKEN_MAX_RETRIES instead of magic number

PATCH Superseded Jianguo Wu 2 participants 3 messages Apr 21, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 1/1 mptcp: using TOKEN_MAX_RETRIES instead of magic number

From: Jianguo Wu <[email protected]>

We have macro TOKEN_MAX_RETRIES for the number of token generate retries, so using TOKEN_MAX_RETRIES in subflow_check_req().

Fixes 535fb8152f31 ("mptcp: token: move retry to caller")
---
 net/mptcp/protocol.h | 2 ++
 net/mptcp/subflow.c  | 2 +-
 net/mptcp/token.c    | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)
net/mptcp/protocol.h +2 -0
index abd8e31..88f1e2b 100644
@@ -14,6 +14,8 @@
 
 #define MPTCP_SUPPORTED_VERSION	1
 
+#define TOKEN_MAX_RETRIES	4
+
 /* MPTCP option bits */
 #define OPTION_MPTCP_MPC_SYN	BIT(0)
 #define OPTION_MPTCP_MPC_SYNACK	BIT(1)
net/mptcp/subflow.c +1 -1
index 325ea7e..977a848 100644
@@ -162,7 +162,7 @@ static int subflow_check_req(struct request_sock *req,
 	}
 
 	if (mp_opt.mp_capable && listener->request_mptcp) {
-		int err, retries = 4;
+		int err, retries = TOKEN_MAX_RETRIES;
 
 		subflow_req->ssn_offset = TCP_SKB_CB(skb)->seq;
 again:
net/mptcp/token.c +0 -1
index 72a24e6..555c962 100644
@@ -33,7 +33,6 @@
 #include <net/mptcp.h>
 #include "protocol.h"
 
-#define TOKEN_MAX_RETRIES	4
 #define TOKEN_MAX_CHAIN_LEN	4
 
 struct token_bucket {
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Jianguo,

Thank you for the patch!

Quoted 18 lines · Jianguo Wu

From: Jianguo Wu <[email protected]>

We have macro TOKEN_MAX_RETRIES for the number of token generate retries, so using TOKEN_MAX_RETRIES in subflow_check_req().

Fixes 535fb8152f31 ("mptcp: token: move retry to caller")
---
 net/mptcp/protocol.h | 2 ++
 net/mptcp/subflow.c  | 2 +-
 net/mptcp/token.c    | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)
net/mptcp/protocol.h +0 -0
index abd8e31..88f1e2b 100644

net/mptcp/protocol.h line 17

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -14,6 +14,8 @@
 
 #define MPTCP_SUPPORTED_VERSION	1
 
+#define TOKEN_MAX_RETRIES	4

Now that this is "exposed" in a header file, probably best to rename it to add "MPTCP_" suffix like (most of) the others here.

Also maybe best to declare it around where the token related functions are declared, no? In other words, just before mptcp_token_init().

Or after the other "#define" we have here but it looks strange to put this at before them.

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
author
#2 lore raw
Quoted 31 lines · Matthieu Baerts

Hi Jianguo,

Thank you for the patch!

Quoted 18 lines · Jianguo Wu

From: Jianguo Wu <[email protected]>

We have macro TOKEN_MAX_RETRIES for the number of token generate retries, so using TOKEN_MAX_RETRIES in subflow_check_req().

Fixes 535fb8152f31 ("mptcp: token: move retry to caller")
---
 net/mptcp/protocol.h | 2 ++
 net/mptcp/subflow.c  | 2 +-
 net/mptcp/token.c    | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)
net/mptcp/protocol.h +0 -0
index abd8e31..88f1e2b 100644

net/mptcp/protocol.h line 17

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -14,6 +14,8 @@
 
 #define MPTCP_SUPPORTED_VERSION	1
 
+#define TOKEN_MAX_RETRIES	4

Now that this is "exposed" in a header file, probably best to rename it to add "MPTCP_" suffix like (most of) the others here.

Quoted 6 lines

Also maybe best to declare it around where the token related functions are declared, no? In other words, just before mptcp_token_init().

Or after the other "#define" we have here but it looks strange to put this at before them.

Hi Matt, I will send v2 as your suggestion, Thanks!

Quoted 3 lines

Cheers,
Matt