@@ -32,6 +32,7 @@ struct mptcp_pernet {
3232 unsigned int close_timeout ;
3333 unsigned int stale_loss_cnt ;
3434 atomic_t active_disable_times ;
35+ u8 syn_retrans_before_tcp_fallback ;
3536 unsigned long active_disable_stamp ;
3637 u8 mptcp_enabled ;
3738 u8 checksum_enabled ;
@@ -92,6 +93,7 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
9293 pernet -> mptcp_enabled = 1 ;
9394 pernet -> add_addr_timeout = TCP_RTO_MAX ;
9495 pernet -> blackhole_timeout = 3600 ;
96+ pernet -> syn_retrans_before_tcp_fallback = 2 ;
9597 atomic_set (& pernet -> active_disable_times , 0 );
9698 pernet -> close_timeout = TCP_TIMEWAIT_LEN ;
9799 pernet -> checksum_enabled = 0 ;
@@ -245,6 +247,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
245247 .proc_handler = proc_blackhole_detect_timeout ,
246248 .extra1 = SYSCTL_ZERO ,
247249 },
250+ {
251+ .procname = "syn_retrans_before_tcp_fallback" ,
252+ .maxlen = sizeof (u8 ),
253+ .mode = 0644 ,
254+ .proc_handler = proc_dou8vec_minmax ,
255+ },
248256};
249257
250258static int mptcp_pernet_new_table (struct net * net , struct mptcp_pernet * pernet )
@@ -269,6 +277,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
269277 /* table[7] is for available_schedulers which is read-only info */
270278 table [8 ].data = & pernet -> close_timeout ;
271279 table [9 ].data = & pernet -> blackhole_timeout ;
280+ table [10 ].data = & pernet -> syn_retrans_before_tcp_fallback ;
272281
273282 hdr = register_net_sysctl_sz (net , MPTCP_SYSCTL_PATH , table ,
274283 ARRAY_SIZE (mptcp_sysctl_table ));
@@ -392,17 +401,21 @@ void mptcp_active_enable(struct sock *sk)
392401void mptcp_active_detect_blackhole (struct sock * ssk , bool expired )
393402{
394403 struct mptcp_subflow_context * subflow ;
395- u32 timeouts ;
396404
397405 if (!sk_is_mptcp (ssk ))
398406 return ;
399407
400- timeouts = inet_csk (ssk )-> icsk_retransmits ;
401408 subflow = mptcp_subflow_ctx (ssk );
402409
403410 if (subflow -> request_mptcp && ssk -> sk_state == TCP_SYN_SENT ) {
404- if (timeouts == 2 || (timeouts < 2 && expired )) {
405- MPTCP_INC_STATS (sock_net (ssk ), MPTCP_MIB_MPCAPABLEACTIVEDROP );
411+ struct net * net = sock_net (ssk );
412+ u8 timeouts , to_max ;
413+
414+ timeouts = inet_csk (ssk )-> icsk_retransmits ;
415+ to_max = mptcp_get_pernet (net )-> syn_retrans_before_tcp_fallback ;
416+
417+ if (timeouts == to_max || (timeouts < to_max && expired )) {
418+ MPTCP_INC_STATS (net , MPTCP_MIB_MPCAPABLEACTIVEDROP );
406419 subflow -> mpc_drop = 1 ;
407420 mptcp_subflow_early_fallback (mptcp_sk (subflow -> conn ), subflow );
408421 } else {
0 commit comments