From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net-next 2/5] tcp: fix delayed acks behavior for SO_RCVLOWAT Date: Mon, 16 Apr 2018 10:33:36 -0700 Message-ID: <20180416173339.6310-3-edumazet@google.com> References: <20180416173339.6310-1-edumazet@google.com> Cc: netdev , Eric Dumazet , Neal Cardwell , Yuchung Cheng , Soheil Hassas Yeganeh , Eric Dumazet To: "David S . Miller" Return-path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:43210 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753082AbeDPRdt (ORCPT ); Mon, 16 Apr 2018 13:33:49 -0400 Received: by mail-pg0-f67.google.com with SMTP id f132so3000153pgc.10 for ; Mon, 16 Apr 2018 10:33:49 -0700 (PDT) In-Reply-To: <20180416173339.6310-1-edumazet@google.com> Sender: netdev-owner@vger.kernel.org List-ID: We should not delay acks if there are not enough bytes in receive queue to satisfy SO_RCVLOWAT. Since [E]POLLIN event is not going to be generated, there is little hope for a delayed ack to be useful. In fact, delaying ACK prevents sender from completing the transfer. Signed-off-by: Eric Dumazet --- net/ipv4/tcp_input.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 367def6ddeda950db841c0b9ccec98787e19e728..d854363a43875e98adbeea72c3434afb06f0f2b4 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5026,9 +5026,12 @@ static void __tcp_ack_snd_check(struct sock *sk, int ofo_possible) /* More than one full frame received... */ if (((tp->rcv_nxt - tp->rcv_wup) > inet_csk(sk)->icsk_ack.rcv_mss && /* ... and right edge of window advances far enough. - * (tcp_recvmsg() will send ACK otherwise). Or... + * (tcp_recvmsg() will send ACK otherwise). + * If application uses SO_RCVLOWAT, we want send ack now if + * we have not received enough bytes to satisfy the condition. */ - __tcp_select_window(sk) >= tp->rcv_wnd) || + (tp->rcv_nxt - tp->copied_seq < sk->sk_rcvlowat || + __tcp_select_window(sk) >= tp->rcv_wnd)) || /* We ACK each frame or... */ tcp_in_quickack_mode(sk) || /* We have out of order data. */ -- 2.17.0.484.g0c8726318c-goog