From patchwork Fri Jul 29 03:11:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soheil Hassas Yeganeh X-Patchwork-Id: 653932 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3s0v0H0S5xz9t0w for ; Fri, 29 Jul 2016 13:11:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=TzQ5aDkp; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750844AbcG2DLz (ORCPT ); Thu, 28 Jul 2016 23:11:55 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:35622 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbcG2DLz (ORCPT ); Thu, 28 Jul 2016 23:11:55 -0400 Received: by mail-qk0-f195.google.com with SMTP id q62so6203713qkf.2 for ; Thu, 28 Jul 2016 20:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wbOEZ5LennCsPhf4ZRBpXQNC3FIaOGubZNSEks+7qd4=; b=TzQ5aDkpyVur8vHeLCKF1v5tfqncEUuynkWvlE8og8SdSBQ2sZsJyGx+4WkJTVyC+Z sWAvurrru9yItQlsHw79bHLZShteUSROsbAiW5iD6mxamF5IvQGq39DMD0qJhwhRgTpp 4mg6GNqMbVZiYvLJImwgCBgjtj4GMHDPpzfy3TOJmyvu0Qat0lsoQPPwlzg0fjsZvT3I p1i3U70/7wZJ8gbpGBbKkDEs89x1kH23Osipt6kBSfbtmQg8zuZZ60wT3AI/2leH9myW SfVn7R/IjgdijSVcpKx3oVlXiy4BWf3bbiJDa21ySuLnI/NtPepKZceGBo45SckNyrkv kwjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wbOEZ5LennCsPhf4ZRBpXQNC3FIaOGubZNSEks+7qd4=; b=gGFzdeOk6Wle6WJs5cEoNvCFWQl+9Bb2WylKSwaI5rJ6kPlRpPjO/bdubfv3s6ljzV 0z4Mr8F43YV7kszsMeHEXPhPSWDNHwy8VdEL+bi3G06kMdJJRpweWjLbbGhNtm5MU7mP BiJcsbqJOwJPgxE8AgSlAlTquK4I8G8THzabHJVXusRG9XWlMCDM7bTQPDEo/SXbbeEu JNfzHhWNITKJmP6I4hiUb4B49vprSmVA4S1eSCosVrn+1RMr4ZEvObLuNBPzM+9rjBXK wXJz77PPs7pxpuf8VWbY/YP67EsySWySr9FCJohGkRO6XUEkWdnItjGXkwJ34wGqGpwa JlZQ== X-Gm-Message-State: AEkoous8CR/DxhfNoDA+oqxilqx7wEuSrfB8kspGzOR9ob9TFwiR/qz7/VaM2quVSwyLqw== X-Received: by 10.55.107.130 with SMTP id g124mr45595620qkc.121.1469761914148; Thu, 28 Jul 2016 20:11:54 -0700 (PDT) Received: from soheil.nyc.corp.google.com ([100.101.230.57]) by smtp.gmail.com with ESMTPSA id 128sm9015155qke.10.2016.07.28.20.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jul 2016 20:11:53 -0700 (PDT) From: Soheil Hassas Yeganeh To: davem@davemloft.net, netdev@vger.kernel.org Cc: edumazet@google.com, ycheng@google.com, ncardwell@google.com, Soheil Hassas Yeganeh Subject: [PATCH net] tcp: consider recv buf for the initial window scale Date: Thu, 28 Jul 2016 23:11:34 -0400 Message-Id: <1469761894-26014-1-git-send-email-soheil.kdev@gmail.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Soheil Hassas Yeganeh tcp_select_initial_window() intends to advertise a window scaling for the maximum possible window size. To do so, it considers the maximum of net.ipv4.tcp_rmem[2] and net.core.rmem_max as the only possible upper-bounds. However, users with CAP_NET_ADMIN can use SO_RCVBUFFORCE to set the socket's receive buffer size to values larger than net.ipv4.tcp_rmem[2] and net.core.rmem_max. Thus, SO_RCVBUFFORCE is effectively ignored by tcp_select_initial_window(). To fix this, consider the maximum of net.ipv4.tcp_rmem[2], net.core.rmem_max and socket's initial buffer space. This part of the code does not have git history and as a result this patch does not have a `Fixes:` tag. Signed-off-by: Soheil Hassas Yeganeh Suggested-by: Neal Cardwell --- net/ipv4/tcp_output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index b26aa87..bdaef7f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -236,7 +236,8 @@ void tcp_select_initial_window(int __space, __u32 mss, /* Set window scaling on max possible window * See RFC1323 for an explanation of the limit to 14 */ - space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max); + space = max_t(u32, space, sysctl_tcp_rmem[2]); + space = max_t(u32, space, sysctl_rmem_max); space = min_t(u32, space, *window_clamp); while (space > 65535 && (*rcv_wscale) < 14) { space >>= 1;