- * Disable rfc1323 and rfc1644 if we havn't got any response to
- * our third SYN to work-around some broken terminal servers
- * (most of which have hopefully been retired) that have bad VJ
- * header compression code which trashes TCP segments containing
- * unknown-to-them TCP options.
+ * Check for potential Path MTU Discovery Black Hole
+ */
+
+ if (tcp_pmtud_black_hole_detect && (tp->t_state == TCPS_ESTABLISHED)) {
+ if (((tp->t_flags & (TF_PMTUD|TF_MAXSEGSNT)) == (TF_PMTUD|TF_MAXSEGSNT)) && (tp->t_rxtshift == 2)) {
+ /*
+ * Enter Path MTU Black-hole Detection mechanism:
+ * - Disable Path MTU Discovery (IP "DF" bit).
+ * - Reduce MTU to lower value than what we negociated with peer.
+ */
+
+ tp->t_flags &= ~TF_PMTUD; /* Disable Path MTU Discovery for now */
+ tp->t_flags |= TF_BLACKHOLE; /* Record that we may have found a black hole */
+ optlen = tp->t_maxopd - tp->t_maxseg;
+ tp->t_pmtud_saved_maxopd = tp->t_maxopd; /* Keep track of previous MSS */
+ if (tp->t_maxopd > tcp_pmtud_black_hole_mss)
+ tp->t_maxopd = tcp_pmtud_black_hole_mss; /* Reduce the MSS to intermediary value */
+ else {
+ tp->t_maxopd = /* use the default MSS */
+#if INET6
+ isipv6 ? tcp_v6mssdflt :
+#endif /* INET6 */
+ tcp_mssdflt;
+ }
+ tp->t_maxseg = tp->t_maxopd - optlen;
+ }
+ /*
+ * If further retransmissions are still unsuccessful with a lowered MTU,
+ * maybe this isn't a Black Hole and we restore the previous MSS and
+ * blackhole detection flags.
+ */
+ else {
+
+ if ((tp->t_flags & TF_BLACKHOLE) && (tp->t_rxtshift > 4)) {
+ tp->t_flags |= TF_PMTUD;
+ tp->t_flags &= ~TF_BLACKHOLE;
+ optlen = tp->t_maxopd - tp->t_maxseg;
+ tp->t_maxopd = tp->t_pmtud_saved_maxopd;
+ tp->t_maxseg = tp->t_maxopd - optlen;
+ }
+ }
+ }
+
+
+ /*
+ * Disable rfc1323 and rfc1644 if we haven't got any response to
+ * our SYN (after we reach the threshold) to work-around some
+ * broken terminal servers (most of which have hopefully been
+ * retired) that have bad VJ header compression code which
+ * trashes TCP segments containing unknown-to-them TCP options.