提交 01f83d69 编写于 作者: A Alexey Kuznetsov 提交者: David S. Miller

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: Nツ Leandro Melo de Sales <leandroal@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6dcbc122
...@@ -475,8 +475,22 @@ extern unsigned int tcp_current_mss(struct sock *sk); ...@@ -475,8 +475,22 @@ extern unsigned int tcp_current_mss(struct sock *sk);
/* Bound MSS / TSO packet size with the half of the window */ /* 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) static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
{ {
if (tp->max_window && pktsize > (tp->max_window >> 1)) int cutoff;
return max(tp->max_window >> 1, 68U - tp->tcp_header_len);
/* 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 else
return pktsize; return pktsize;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册