Skip to content

Commit 78d8b7b

Browse files
Florian Westphaldavem330
authored andcommitted
mptcp: subflow: split subflow_init_req
When syncookie support is added, we will need to add a variant of subflow_init_req() helper. It will do almost same thing except that it will not compute/add a token to the mptcp token tree. To avoid excess copy&paste, this commit splits away part of the code into a new helper, __subflow_init_req, that can then be re-used from the 'no insert' function added in a followup change. Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 535fb81 commit 78d8b7b

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

net/mptcp/subflow.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,9 @@ static struct mptcp_sock *subflow_token_join_request(struct request_sock *req,
9191
return msk;
9292
}
9393

94-
static void subflow_init_req(struct request_sock *req,
95-
const struct sock *sk_listener,
96-
struct sk_buff *skb)
94+
static int __subflow_init_req(struct request_sock *req, const struct sock *sk_listener)
9795
{
98-
struct mptcp_subflow_context *listener = mptcp_subflow_ctx(sk_listener);
9996
struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);
100-
struct mptcp_options_received mp_opt;
101-
102-
pr_debug("subflow_req=%p, listener=%p", subflow_req, listener);
103-
104-
mptcp_get_options(skb, &mp_opt);
10597

10698
subflow_req->mp_capable = 0;
10799
subflow_req->mp_join = 0;
@@ -113,9 +105,29 @@ static void subflow_init_req(struct request_sock *req,
113105
* TCP option space.
114106
*/
115107
if (rcu_access_pointer(tcp_sk(sk_listener)->md5sig_info))
116-
return;
108+
return -EINVAL;
117109
#endif
118110

111+
return 0;
112+
}
113+
114+
static void subflow_init_req(struct request_sock *req,
115+
const struct sock *sk_listener,
116+
struct sk_buff *skb)
117+
{
118+
struct mptcp_subflow_context *listener = mptcp_subflow_ctx(sk_listener);
119+
struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);
120+
struct mptcp_options_received mp_opt;
121+
int ret;
122+
123+
pr_debug("subflow_req=%p, listener=%p", subflow_req, listener);
124+
125+
ret = __subflow_init_req(req, sk_listener);
126+
if (ret)
127+
return;
128+
129+
mptcp_get_options(skb, &mp_opt);
130+
119131
if (mp_opt.mp_capable) {
120132
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE);
121133

0 commit comments

Comments
 (0)