X-Git-Url: https://bbs.cooldavid.org/git/?a=blobdiff_plain;f=include%2Fnet%2Ftcp.h;h=3e4b33e36602caade361654d0561a65b3fba2224;hb=01f83d69844d307be2aa6fea88b0e8fe5cbdb2f4;hp=eaa9582779d029a9362c32b3816fed8c157e4d3e;hpb=6dcbc12290abb452a5e42713faa6461b248e2f55;p=net-next-2.6.git diff --git a/include/net/tcp.h b/include/net/tcp.h index eaa9582779d..3e4b33e3660 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -475,8 +475,22 @@ extern unsigned int tcp_current_mss(struct sock *sk); /* Bound MSS / TSO packet size with the half of the window */ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) { - if (tp->max_window && pktsize > (tp->max_window >> 1)) - return max(tp->max_window >> 1, 68U - tp->tcp_header_len); + int cutoff; + + /* When peer uses tiny windows, there is no use in packetizing + * to sub-MSS pieces for the sake of SWS or making sure there + * are enough packets in the pipe for fast recovery. + * + * On the other hand, for extremely large MSS devices, handling + * smaller than MSS windows in this way does make sense. + */ + if (tp->max_window >= 512) + cutoff = (tp->max_window >> 1); + else + cutoff = tp->max_window; + + if (cutoff && pktsize > cutoff) + return max_t(int, cutoff, 68U - tp->tcp_header_len); else return pktsize; }