mptcp: use proper req destructor for IPv6
[platform/kernel/linux-starfive.git] / net / mptcp / subflow.c
index 30524dd..613f515 100644 (file)
@@ -45,7 +45,6 @@ static void subflow_req_destructor(struct request_sock *req)
                sock_put((struct sock *)subflow_req->msk);
 
        mptcp_token_destroy_request(req);
-       tcp_request_sock_ops.destructor(req);
 }
 
 static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
@@ -550,6 +549,12 @@ drop:
        return 0;
 }
 
+static void subflow_v4_req_destructor(struct request_sock *req)
+{
+       subflow_req_destructor(req);
+       tcp_request_sock_ops.destructor(req);
+}
+
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 static struct request_sock_ops mptcp_subflow_v6_request_sock_ops __ro_after_init;
 static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_after_init;
@@ -581,6 +586,12 @@ drop:
        tcp_listendrop(sk);
        return 0; /* don't send reset */
 }
+
+static void subflow_v6_req_destructor(struct request_sock *req)
+{
+       subflow_req_destructor(req);
+       tcp6_request_sock_ops.destructor(req);
+}
 #endif
 
 struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_ops *ops,
@@ -1929,8 +1940,6 @@ static int subflow_ops_init(struct request_sock_ops *subflow_ops)
        if (!subflow_ops->slab)
                return -ENOMEM;
 
-       subflow_ops->destructor = subflow_req_destructor;
-
        return 0;
 }
 
@@ -1938,6 +1947,8 @@ void __init mptcp_subflow_init(void)
 {
        mptcp_subflow_v4_request_sock_ops = tcp_request_sock_ops;
        mptcp_subflow_v4_request_sock_ops.slab_name = "request_sock_subflow_v4";
+       mptcp_subflow_v4_request_sock_ops.destructor = subflow_v4_req_destructor;
+
        if (subflow_ops_init(&mptcp_subflow_v4_request_sock_ops) != 0)
                panic("MPTCP: failed to init subflow v4 request sock ops\n");
 
@@ -1963,6 +1974,8 @@ void __init mptcp_subflow_init(void)
 
        mptcp_subflow_v6_request_sock_ops = tcp6_request_sock_ops;
        mptcp_subflow_v6_request_sock_ops.slab_name = "request_sock_subflow_v6";
+       mptcp_subflow_v6_request_sock_ops.destructor = subflow_v6_req_destructor;
+
        if (subflow_ops_init(&mptcp_subflow_v6_request_sock_ops) != 0)
                panic("MPTCP: failed to init subflow v6 request sock ops\n");