aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>2010-09-15 13:27:52 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-15 15:01:44 -0400
commit01f83d69844d307be2aa6fea88b0e8fe5cbdb2f4 (patch)
treeb01eba7a8b9cf737312c3721ff8ef361baa55bea /include
parent6dcbc12290abb452a5e42713faa6461b248e2f55 (diff)
tcp: Prevent overzealous packetization by SWS logic.
If peer uses tiny MSS (say, 75 bytes) and similarly tiny advertised window, the SWS logic will packetize to half the MSS unnecessarily. This causes problems with some embedded devices. However for large MSS devices we do want to half-MSS packetize otherwise we never get enough packets into the pipe for things like fast retransmit and recovery to work. Be careful also to handle the case where MSS > window, otherwise we'll never send until the probe timer. Reported-by: ツ Leandro Melo de Sales <leandroal@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/tcp.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index eaa9582779d0..3e4b33e36602 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -475,8 +475,22 @@ extern unsigned int tcp_current_mss(struct sock *sk);
475/* Bound MSS / TSO packet size with the half of the window */ 475/* Bound MSS / TSO packet size with the half of the window */
476static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) 476static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
477{ 477{
478 if (tp->max_window && pktsize > (tp->max_window >> 1)) 478 int cutoff;
479 return max(tp->max_window >> 1, 68U - tp->tcp_header_len); 479
480 /* When peer uses tiny windows, there is no use in packetizing
481 * to sub-MSS pieces for the sake of SWS or making sure there
482 * are enough packets in the pipe for fast recovery.
483 *
484 * On the other hand, for extremely large MSS devices, handling
485 * smaller than MSS windows in this way does make sense.
486 */
487 if (tp->max_window >= 512)
488 cutoff = (tp->max_window >> 1);
489 else
490 cutoff = tp->max_window;
491
492 if (cutoff && pktsize > cutoff)
493 return max_t(int, cutoff, 68U - tp->tcp_header_len);
480 else 494 else
481 return pktsize; 495 return pktsize;
482} 496}