int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
                      u32 cookie);
 struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);
+struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
+                                           struct sock *sk, struct sk_buff *skb);
 #ifdef CONFIG_SYN_COOKIES
 
 /* Syncookies use a monotonic timer which increments every 60 seconds.
 
 }
 EXPORT_SYMBOL(cookie_ecn_ok);
 
+struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
+                                           struct sock *sk,
+                                           struct sk_buff *skb)
+{
+       struct tcp_request_sock *treq;
+       struct request_sock *req;
+
+#ifdef CONFIG_MPTCP
+       if (sk_is_mptcp(sk))
+               ops = &mptcp_subflow_request_sock_ops;
+#endif
+
+       req = inet_reqsk_alloc(ops, sk, false);
+       if (!req)
+               return NULL;
+
+#if IS_ENABLED(CONFIG_MPTCP)
+       treq = tcp_rsk(req);
+       treq->is_mptcp = sk_is_mptcp(sk);
+       if (treq->is_mptcp) {
+               int err = mptcp_subflow_init_cookie_req(req, sk, skb);
+
+               if (err) {
+                       reqsk_free(req);
+                       return NULL;
+               }
+       }
+#endif
+
+       return req;
+}
+EXPORT_SYMBOL_GPL(cookie_tcp_reqsk_alloc);
+
 /* On input, sk is a listener.
  * Output is listener if incoming packet would not create a child
  *           NULL if memory could not be allocated.
                goto out;
 
        ret = NULL;
-       req = inet_reqsk_alloc(&tcp_request_sock_ops, sk, false); /* for safety */
+       req = cookie_tcp_reqsk_alloc(&tcp_request_sock_ops, sk, skb);
        if (!req)
                goto out;
 
        treq->snt_synack        = 0;
        treq->tfo_listener      = false;
 
-       if (IS_ENABLED(CONFIG_MPTCP))
-               treq->is_mptcp = 0;
-
        if (IS_ENABLED(CONFIG_SMC))
                ireq->smc_ok = 0;
 
 
 
        af_ops->init_req(req, sk, skb);
 
-       if (IS_ENABLED(CONFIG_MPTCP) && want_cookie)
-               tcp_rsk(req)->is_mptcp = 0;
-
        if (security_inet_conn_request(sk, skb, req))
                goto drop_and_free;
 
 
                goto out;
 
        ret = NULL;
-       req = inet_reqsk_alloc(&tcp6_request_sock_ops, sk, false);
+       req = cookie_tcp_reqsk_alloc(&tcp6_request_sock_ops, sk, skb);
        if (!req)
                goto out;
 
        treq = tcp_rsk(req);
        treq->tfo_listener = false;
 
-       if (IS_ENABLED(CONFIG_MPTCP))
-               treq->is_mptcp = 0;
-
        if (security_inet_conn_request(sk, skb, req))
                goto out_free;