@@ -45,7 +45,6 @@ static void subflow_req_destructor(struct request_sock *req)
45
45
sock_put ((struct sock * )subflow_req -> msk );
46
46
47
47
mptcp_token_destroy_request (req );
48
- tcp_request_sock_ops .destructor (req );
49
48
}
50
49
51
50
static void subflow_generate_hmac (u64 key1 , u64 key2 , u32 nonce1 , u32 nonce2 ,
@@ -529,7 +528,7 @@ static int subflow_v6_rebuild_header(struct sock *sk)
529
528
}
530
529
#endif
531
530
532
- struct request_sock_ops mptcp_subflow_request_sock_ops ;
531
+ static struct request_sock_ops mptcp_subflow_v4_request_sock_ops __ro_after_init ;
533
532
static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_after_init ;
534
533
535
534
static int subflow_v4_conn_request (struct sock * sk , struct sk_buff * skb )
@@ -542,15 +541,22 @@ static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb)
542
541
if (skb_rtable (skb )-> rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST ))
543
542
goto drop ;
544
543
545
- return tcp_conn_request (& mptcp_subflow_request_sock_ops ,
544
+ return tcp_conn_request (& mptcp_subflow_v4_request_sock_ops ,
546
545
& subflow_request_sock_ipv4_ops ,
547
546
sk , skb );
548
547
drop :
549
548
tcp_listendrop (sk );
550
549
return 0 ;
551
550
}
552
551
552
+ static void subflow_v4_req_destructor (struct request_sock * req )
553
+ {
554
+ subflow_req_destructor (req );
555
+ tcp_request_sock_ops .destructor (req );
556
+ }
557
+
553
558
#if IS_ENABLED (CONFIG_MPTCP_IPV6 )
559
+ static struct request_sock_ops mptcp_subflow_v6_request_sock_ops __ro_after_init ;
554
560
static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_after_init ;
555
561
static struct inet_connection_sock_af_ops subflow_v6_specific __ro_after_init ;
556
562
static struct inet_connection_sock_af_ops subflow_v6m_specific __ro_after_init ;
@@ -573,15 +579,36 @@ static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
573
579
return 0 ;
574
580
}
575
581
576
- return tcp_conn_request (& mptcp_subflow_request_sock_ops ,
582
+ return tcp_conn_request (& mptcp_subflow_v6_request_sock_ops ,
577
583
& subflow_request_sock_ipv6_ops , sk , skb );
578
584
579
585
drop :
580
586
tcp_listendrop (sk );
581
587
return 0 ; /* don't send reset */
582
588
}
589
+
590
+ static void subflow_v6_req_destructor (struct request_sock * req )
591
+ {
592
+ subflow_req_destructor (req );
593
+ tcp6_request_sock_ops .destructor (req );
594
+ }
595
+ #endif
596
+
597
+ struct request_sock * mptcp_subflow_reqsk_alloc (const struct request_sock_ops * ops ,
598
+ struct sock * sk_listener ,
599
+ bool attach_listener )
600
+ {
601
+ if (ops -> family == AF_INET )
602
+ ops = & mptcp_subflow_v4_request_sock_ops ;
603
+ #if IS_ENABLED (CONFIG_MPTCP_IPV6 )
604
+ else if (ops -> family == AF_INET6 )
605
+ ops = & mptcp_subflow_v6_request_sock_ops ;
583
606
#endif
584
607
608
+ return inet_reqsk_alloc (ops , sk_listener , attach_listener );
609
+ }
610
+ EXPORT_SYMBOL (mptcp_subflow_reqsk_alloc );
611
+
585
612
/* validate hmac received in third ACK */
586
613
static bool subflow_hmac_valid (const struct request_sock * req ,
587
614
const struct mptcp_options_received * mp_opt )
@@ -1904,7 +1931,6 @@ static struct tcp_ulp_ops subflow_ulp_ops __read_mostly = {
1904
1931
static int subflow_ops_init (struct request_sock_ops * subflow_ops )
1905
1932
{
1906
1933
subflow_ops -> obj_size = sizeof (struct mptcp_subflow_request_sock );
1907
- subflow_ops -> slab_name = "request_sock_subflow" ;
1908
1934
1909
1935
subflow_ops -> slab = kmem_cache_create (subflow_ops -> slab_name ,
1910
1936
subflow_ops -> obj_size , 0 ,
@@ -1914,16 +1940,17 @@ static int subflow_ops_init(struct request_sock_ops *subflow_ops)
1914
1940
if (!subflow_ops -> slab )
1915
1941
return - ENOMEM ;
1916
1942
1917
- subflow_ops -> destructor = subflow_req_destructor ;
1918
-
1919
1943
return 0 ;
1920
1944
}
1921
1945
1922
1946
void __init mptcp_subflow_init (void )
1923
1947
{
1924
- mptcp_subflow_request_sock_ops = tcp_request_sock_ops ;
1925
- if (subflow_ops_init (& mptcp_subflow_request_sock_ops ) != 0 )
1926
- panic ("MPTCP: failed to init subflow request sock ops\n" );
1948
+ mptcp_subflow_v4_request_sock_ops = tcp_request_sock_ops ;
1949
+ mptcp_subflow_v4_request_sock_ops .slab_name = "request_sock_subflow_v4" ;
1950
+ mptcp_subflow_v4_request_sock_ops .destructor = subflow_v4_req_destructor ;
1951
+
1952
+ if (subflow_ops_init (& mptcp_subflow_v4_request_sock_ops ) != 0 )
1953
+ panic ("MPTCP: failed to init subflow v4 request sock ops\n" );
1927
1954
1928
1955
subflow_request_sock_ipv4_ops = tcp_request_sock_ipv4_ops ;
1929
1956
subflow_request_sock_ipv4_ops .route_req = subflow_v4_route_req ;
@@ -1938,6 +1965,20 @@ void __init mptcp_subflow_init(void)
1938
1965
tcp_prot_override .release_cb = tcp_release_cb_override ;
1939
1966
1940
1967
#if IS_ENABLED (CONFIG_MPTCP_IPV6 )
1968
+ /* In struct mptcp_subflow_request_sock, we assume the TCP request sock
1969
+ * structures for v4 and v6 have the same size. It should not changed in
1970
+ * the future but better to make sure to be warned if it is no longer
1971
+ * the case.
1972
+ */
1973
+ BUILD_BUG_ON (sizeof (struct tcp_request_sock ) != sizeof (struct tcp6_request_sock ));
1974
+
1975
+ mptcp_subflow_v6_request_sock_ops = tcp6_request_sock_ops ;
1976
+ mptcp_subflow_v6_request_sock_ops .slab_name = "request_sock_subflow_v6" ;
1977
+ mptcp_subflow_v6_request_sock_ops .destructor = subflow_v6_req_destructor ;
1978
+
1979
+ if (subflow_ops_init (& mptcp_subflow_v6_request_sock_ops ) != 0 )
1980
+ panic ("MPTCP: failed to init subflow v6 request sock ops\n" );
1981
+
1941
1982
subflow_request_sock_ipv6_ops = tcp_request_sock_ipv6_ops ;
1942
1983
subflow_request_sock_ipv6_ops .route_req = subflow_v6_route_req ;
1943
1984
0 commit comments