Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_timer.c
Show First 20 Lines • Show All 717 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
isipv6 = false; | isipv6 = false; | ||||
#endif | #endif | ||||
if (((V_tcp_pmtud_blackhole_detect == 1) || | if (((V_tcp_pmtud_blackhole_detect == 1) || | ||||
(V_tcp_pmtud_blackhole_detect == 2 && !isipv6) || | (V_tcp_pmtud_blackhole_detect == 2 && !isipv6) || | ||||
(V_tcp_pmtud_blackhole_detect == 3 && isipv6)) && | (V_tcp_pmtud_blackhole_detect == 3 && isipv6)) && | ||||
((tp->t_state == TCPS_ESTABLISHED) || | ((tp->t_state == TCPS_ESTABLISHED) || | ||||
(tp->t_state == TCPS_FIN_WAIT_1))) { | (tp->t_state == TCPS_FIN_WAIT_1))) { | ||||
if (tp->t_rxtshift == 1) { | |||||
/* | /* | ||||
* Idea here is that at each stage of mtu probe (usually, 1448 | * We enter blackhole detection after the first | ||||
* -> 1188 -> 524) should be given 2 chances to recover before | * unsuccessful timer based retransmission. | ||||
* further clamping down. 'tp->t_rxtshift % 2 == 0' should | * Then we reduce up to two times the MSS, each | ||||
* take care of that. | * candidate giving two tries of retransmissions. | ||||
* But we give a candidate only two tries, if it | |||||
* actually reduces the MSS. | |||||
*/ | */ | ||||
tp->t_blackhole_enter = 2; | |||||
tp->t_blackhole_exit = tp->t_blackhole_enter; | |||||
if (isipv6) { | |||||
#ifdef INET6 | |||||
if (tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss) | |||||
tp->t_blackhole_exit += 2; | |||||
if (tp->t_maxseg > V_tcp_v6mssdflt && | |||||
V_tcp_v6pmtud_blackhole_mss > V_tcp_v6mssdflt) | |||||
tp->t_blackhole_exit += 2; | |||||
#endif | |||||
} else { | |||||
#ifdef INET | |||||
if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss) | |||||
tp->t_blackhole_exit += 2; | |||||
if (tp->t_maxseg > V_tcp_mssdflt && | |||||
V_tcp_pmtud_blackhole_mss > V_tcp_mssdflt) | |||||
tp->t_blackhole_exit += 2; | |||||
#endif | |||||
} | |||||
} | |||||
if (((tp->t_flags2 & (TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) == | if (((tp->t_flags2 & (TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) == | ||||
(TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) && | (TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) && | ||||
(tp->t_rxtshift >= 2 && tp->t_rxtshift < 6 && | (tp->t_rxtshift >= tp->t_blackhole_enter && | ||||
tp->t_rxtshift % 2 == 0)) { | tp->t_rxtshift < tp->t_blackhole_exit && | ||||
(tp->t_rxtshift - tp->t_blackhole_enter) % 2 == 0)) { | |||||
/* | /* | ||||
* Enter Path MTU Black-hole Detection mechanism: | * Enter Path MTU Black-hole Detection mechanism: | ||||
* - Disable Path MTU Discovery (IP "DF" bit). | * - Disable Path MTU Discovery (IP "DF" bit). | ||||
* - Reduce MTU to lower value than what we | * - Reduce MTU to lower value than what we | ||||
* negotiated with peer. | * negotiated with peer. | ||||
*/ | */ | ||||
if ((tp->t_flags2 & TF2_PLPMTU_BLACKHOLE) == 0) { | if ((tp->t_flags2 & TF2_PLPMTU_BLACKHOLE) == 0) { | ||||
/* Record that we may have found a black hole. */ | /* Record that we may have found a black hole. */ | ||||
tp->t_flags2 |= TF2_PLPMTU_BLACKHOLE; | tp->t_flags2 |= TF2_PLPMTU_BLACKHOLE; | ||||
/* Keep track of previous MSS. */ | /* Keep track of previous MSS. */ | ||||
tp->t_pmtud_saved_maxseg = tp->t_maxseg; | tp->t_pmtud_saved_maxseg = tp->t_maxseg; | ||||
} | } | ||||
/* | /* | ||||
* Reduce the MSS to blackhole value or to the default | * Reduce the MSS to blackhole value or to the default | ||||
* in an attempt to retransmit. | * in an attempt to retransmit. | ||||
*/ | */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (isipv6 && | if (isipv6 && | ||||
tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss) { | tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss && | ||||
V_tcp_v6pmtud_blackhole_mss > V_tcp_v6mssdflt) { | |||||
/* Use the sysctl tuneable blackhole MSS. */ | /* Use the sysctl tuneable blackhole MSS. */ | ||||
tp->t_maxseg = V_tcp_v6pmtud_blackhole_mss; | tp->t_maxseg = V_tcp_v6pmtud_blackhole_mss; | ||||
TCPSTAT_INC(tcps_pmtud_blackhole_activated); | TCPSTAT_INC(tcps_pmtud_blackhole_activated); | ||||
} else if (isipv6) { | } else if (isipv6) { | ||||
/* Use the default MSS. */ | /* Use the default MSS. */ | ||||
tp->t_maxseg = V_tcp_v6mssdflt; | tp->t_maxseg = V_tcp_v6mssdflt; | ||||
/* | /* | ||||
* Disable Path MTU Discovery when we switch to | * Disable Path MTU Discovery when we switch to | ||||
* minmss. | * minmss. | ||||
*/ | */ | ||||
tp->t_flags2 &= ~TF2_PLPMTU_PMTUD; | tp->t_flags2 &= ~TF2_PLPMTU_PMTUD; | ||||
TCPSTAT_INC(tcps_pmtud_blackhole_activated_min_mss); | TCPSTAT_INC(tcps_pmtud_blackhole_activated_min_mss); | ||||
} | } | ||||
#endif | #endif | ||||
#if defined(INET6) && defined(INET) | #if defined(INET6) && defined(INET) | ||||
else | else | ||||
#endif | #endif | ||||
#ifdef INET | #ifdef INET | ||||
if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss) { | if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss && | ||||
V_tcp_pmtud_blackhole_mss > V_tcp_mssdflt) { | |||||
/* Use the sysctl tuneable blackhole MSS. */ | /* Use the sysctl tuneable blackhole MSS. */ | ||||
tp->t_maxseg = V_tcp_pmtud_blackhole_mss; | tp->t_maxseg = V_tcp_pmtud_blackhole_mss; | ||||
TCPSTAT_INC(tcps_pmtud_blackhole_activated); | TCPSTAT_INC(tcps_pmtud_blackhole_activated); | ||||
} else { | } else { | ||||
/* Use the default MSS. */ | /* Use the default MSS. */ | ||||
tp->t_maxseg = V_tcp_mssdflt; | tp->t_maxseg = V_tcp_mssdflt; | ||||
/* | /* | ||||
* Disable Path MTU Discovery when we switch to | * Disable Path MTU Discovery when we switch to | ||||
Show All 10 Lines | #endif | ||||
if (CC_ALGO(tp)->conn_init != NULL) | if (CC_ALGO(tp)->conn_init != NULL) | ||||
CC_ALGO(tp)->conn_init(tp->ccv); | CC_ALGO(tp)->conn_init(tp->ccv); | ||||
} else { | } else { | ||||
/* | /* | ||||
* If further retransmissions are still unsuccessful | * If further retransmissions are still unsuccessful | ||||
* with a lowered MTU, maybe this isn't a blackhole and | * with a lowered MTU, maybe this isn't a blackhole and | ||||
* we restore the previous MSS and blackhole detection | * we restore the previous MSS and blackhole detection | ||||
* flags. | * flags. | ||||
* The limit '6' is determined by giving each probe | |||||
* stage (1448, 1188, 524) 2 chances to recover. | |||||
*/ | */ | ||||
if ((tp->t_flags2 & TF2_PLPMTU_BLACKHOLE) && | if ((tp->t_flags2 & TF2_PLPMTU_BLACKHOLE) && | ||||
(tp->t_rxtshift >= 6)) { | (tp->t_rxtshift >= tp->t_blackhole_exit)) { | ||||
tp->t_flags2 |= TF2_PLPMTU_PMTUD; | tp->t_flags2 |= TF2_PLPMTU_PMTUD; | ||||
tp->t_flags2 &= ~TF2_PLPMTU_BLACKHOLE; | tp->t_flags2 &= ~TF2_PLPMTU_BLACKHOLE; | ||||
tp->t_maxseg = tp->t_pmtud_saved_maxseg; | tp->t_maxseg = tp->t_pmtud_saved_maxseg; | ||||
TCPSTAT_INC(tcps_pmtud_blackhole_failed); | TCPSTAT_INC(tcps_pmtud_blackhole_failed); | ||||
/* | /* | ||||
* Reset the slow-start flight size as it | * Reset the slow-start flight size as it | ||||
* may depend on the new MSS. | * may depend on the new MSS. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |