From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF097C10F11 for ; Wed, 24 Apr 2019 18:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E50A20684 for ; Wed, 24 Apr 2019 18:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556129388; bh=4keWdMm/tEZlCwMp8B2v1gf42EFGzm3x08l2s06Jfq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bi+e0CHQ09h+Srcm/eDEmIFCtEijTaGxA4TP/irUt8EPZY26/FdN2KHmlk8h1VQJP lNmS+L6G5XBYrMMXgQNOhXTI8Mf23dAhCYKKczoDe5HDixPnOB1H0wsLG9+Iv3g9lW NRWj0w8QnDjqtN7PTiFNmApWmM/QyyuwzqsvAJ0E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388159AbfDXRPD (ORCPT ); Wed, 24 Apr 2019 13:15:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:39256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388149AbfDXRO5 (ORCPT ); Wed, 24 Apr 2019 13:14:57 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F361206BA; Wed, 24 Apr 2019 17:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126097; bh=4keWdMm/tEZlCwMp8B2v1gf42EFGzm3x08l2s06Jfq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Inqy+8tvqXu5oX5bO2lKAY73jZfixQYbiWpqM0WAoFN0aRRRcnmRwH5SEhsWBQJ/p d/2TrC9EZbhfhDrSp9vE4Lb6OyG4r2LBwzF4+yMGoqDwj82w1J4CjIkIA2ggh0xoZO ZwJ4gtIEHY1KqqdGDpWfAEQhaT5E6PDYTV996+ig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell , Wei Wang , "David S. Miller" Subject: [PATCH 3.18 094/104] tcp: tcp_grow_window() needs to respect tcp_space() Date: Wed, 24 Apr 2019 19:09:51 +0200 Message-Id: <20190424170909.693071532@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170839.996641496@linuxfoundation.org> References: <20190424170839.996641496@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 50ce163a72d817a99e8974222dcf2886d5deb1ae ] For some reason, tcp_grow_window() correctly tests if enough room is present before attempting to increase tp->rcv_ssthresh, but does not prevent it to grow past tcp_space() This is causing hard to debug issues, like failing the (__tcp_select_window(sk) >= tp->rcv_wnd) test in __tcp_ack_snd_check(), causing ACK delays and possibly slow flows. Depending on tcp_rmem[2], MTU, skb->len/skb->truesize ratio, we can see the problem happening on "netperf -t TCP_RR -- -r 2000,2000" after about 60 round trips, when the active side no longer sends immediate acks. This bug predates git history. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Acked-by: Neal Cardwell Acked-by: Wei Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_input.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -358,11 +358,12 @@ static int __tcp_grow_window(const struc static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); + int room; + + room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh; /* Check #1 */ - if (tp->rcv_ssthresh < tp->window_clamp && - (int)tp->rcv_ssthresh < tcp_space(sk) && - !sk_under_memory_pressure(sk)) { + if (room > 0 && !sk_under_memory_pressure(sk)) { int incr; /* Check #2. Increase window, if skb with such overhead @@ -375,8 +376,7 @@ static void tcp_grow_window(struct sock if (incr) { incr = max_t(int, incr, 2 * skb->len); - tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, - tp->window_clamp); + tp->rcv_ssthresh += min(room, incr); inet_csk(sk)->icsk_ack.quick |= 1; } }