{"id":831081,"url":"http://patchwork.ozlabs.org/api/1.2/patches/831081/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171027045510.5827-15-edumazet@google.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171027045510.5827-15-edumazet@google.com>","list_archive_url":null,"date":"2017-10-27T04:55:09","name":"[v2,net-next,14/15] tcp: Namespace-ify sysctl_tcp_adv_win_scale","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"77ec56c9c535b11a1b24bbb7017e6134c8b6df4d","submitter":{"id":13357,"url":"http://patchwork.ozlabs.org/api/1.2/people/13357/?format=json","name":"Eric Dumazet","email":"edumazet@google.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171027045510.5827-15-edumazet@google.com/mbox/","series":[{"id":10492,"url":"http://patchwork.ozlabs.org/api/1.2/series/10492/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=10492","date":"2017-10-27T04:54:55","name":"tcp: move 14 sysctls to namespaces","version":2,"mbox":"http://patchwork.ozlabs.org/series/10492/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/831081/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/831081/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"E+Wr4gQp\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yNWmF6h33z9t30\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 27 Oct 2017 15:55:57 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752059AbdJ0Ezz (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 27 Oct 2017 00:55:55 -0400","from mail-io0-f193.google.com ([209.85.223.193]:46698 \"EHLO\n\tmail-io0-f193.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751932AbdJ0Ezp (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 27 Oct 2017 00:55:45 -0400","by mail-io0-f193.google.com with SMTP id 101so10132869ioj.3\n\tfor <netdev@vger.kernel.org>; Thu, 26 Oct 2017 21:55:44 -0700 (PDT)","from localhost ([2620:15c:2c4:201:c5be:583d:61a8:d070])\n\tby smtp.gmail.com with ESMTPSA id\n\to190sm3110770ioe.71.2017.10.26.21.55.43\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tThu, 26 Oct 2017 21:55:43 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=google.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=HlgHOSHTe/WGQ9tvp6yG5YHM35EVvABvKnMvAh+sDOA=;\n\tb=E+Wr4gQpjbg1bC0B6kjbmfE4QwLrvW9JlM7rFOVIcF5G39YA73/4BcszNElCzwVtE5\n\tJ1PT3DTyyIcDvnsUlgfJ45PaZ7QsnU9W5uOG3tTfGoQ8vuotPeSJbaLloPOMKlOWv0WR\n\trfE2BSHpN2WOSGBrHKxyuHyMXuWboiPYd2AgnW+4ja+ei2t9/xdM0keprJ0g7dl8UAkE\n\tiUFPHFnavmaso2hnWj0b7TzE6e8eOKtySpXUyF4BkaDN0ANxF/WUcGwlzXwsJNoBfGhX\n\ty0xffM2nMmobi8GdEoJgVTU/SF54jgfKzmoIGyOtzObGlgT0ueo5HIzjVp3xw7+Jicr2\n\tiYig==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=HlgHOSHTe/WGQ9tvp6yG5YHM35EVvABvKnMvAh+sDOA=;\n\tb=T8vlyRamVKLsCqAt9VtxXBwwI6tjFvCXD9YUwV55ePMz5uFbH4gM9HF+JZnDywhE4+\n\tHNYSyHMg797QlUhGrDmpH9GzidGhbNhUUlF6VNzJfb0ccWPEEDVBieTVkAJysnxM0+pZ\n\tqILQmVtb8XJJVO+vXgYGpQznZ+F5iCHSBAVU7nbX25lobXSDJcHs2r/3BtALef3wr7pt\n\tdbKHVGPYa5bBL9jUbvu5W05Lb30he4HuVFrrfsu3PTf4YlQvw01xSr8GrRnxxDPSpOSw\n\tfcxgtN98FaaCwHLs3Q/wnLFzeCEEoItT3c/W7gmCBpcsWiXBiJXGaRWqyhIbKNZtKhBJ\n\tJUrw==","X-Gm-Message-State":"AMCzsaVCOCLjIEgfqSCAzD+sznieAdyenPglNcWDMmgGEM2jGM9NFPxu\n\tSd/iAltN1dYJUhZUNjvbPpwafA==","X-Google-Smtp-Source":"ABhQp+TCY1xs+dXU9ijxwMN+xS6t11sT7MNGp/RR+Id9L8B7tWqsWaOE0TwF4iBASz7H+Vz3uC+O4Q==","X-Received":"by 10.107.17.31 with SMTP id z31mr31999359ioi.124.1509080144080; \n\tThu, 26 Oct 2017 21:55:44 -0700 (PDT)","From":"Eric Dumazet <edumazet@google.com>","To":"\"David S . Miller\" <davem@davemloft.net>","Cc":"netdev <netdev@vger.kernel.org>, Eric Dumazet <edumazet@google.com>,\n\tEric Dumazet <eric.dumazet@gmail.com>","Subject":"[PATCH v2 net-next 14/15] tcp: Namespace-ify\n\tsysctl_tcp_adv_win_scale","Date":"Thu, 26 Oct 2017 21:55:09 -0700","Message-Id":"<20171027045510.5827-15-edumazet@google.com>","X-Mailer":"git-send-email 2.15.0.rc2.357.g7e34df9404-goog","In-Reply-To":"<20171027045510.5827-1-edumazet@google.com>","References":"<20171027045510.5827-1-edumazet@google.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Signed-off-by: Eric Dumazet <edumazet@google.com>\n---\n include/net/netns/ipv4.h   |  1 +\n include/net/tcp.h          |  9 ++++-----\n net/ipv4/sysctl_net_ipv4.c | 18 +++++++++---------\n net/ipv4/tcp_input.c       | 13 +++++--------\n net/ipv4/tcp_ipv4.c        |  1 +\n 5 files changed, 20 insertions(+), 22 deletions(-)","diff":"diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h\nindex 63f91d52cbc0ad35d8e04a8da0d9f57aa960bcb0..9dbb07d4eff465428817831e55c6a4922b7208fb 100644\n--- a/include/net/netns/ipv4.h\n+++ b/include/net/netns/ipv4.h\n@@ -140,6 +140,7 @@ struct netns_ipv4 {\n \tint sysctl_tcp_max_reordering;\n \tint sysctl_tcp_dsack;\n \tint sysctl_tcp_app_win;\n+\tint sysctl_tcp_adv_win_scale;\n \tstruct inet_timewait_death_row tcp_death_row;\n \tint sysctl_max_syn_backlog;\n \tint sysctl_tcp_fastopen;\ndiff --git a/include/net/tcp.h b/include/net/tcp.h\nindex 7aa3d65062a14a98358f8868fa2c0dbb2c74a0ce..0dc27cd248997bf6a0463477db38db483c312fb0 100644\n--- a/include/net/tcp.h\n+++ b/include/net/tcp.h\n@@ -247,7 +247,6 @@ extern int sysctl_tcp_max_orphans;\n extern long sysctl_tcp_mem[3];\n extern int sysctl_tcp_wmem[3];\n extern int sysctl_tcp_rmem[3];\n-extern int sysctl_tcp_adv_win_scale;\n extern int sysctl_tcp_frto;\n extern int sysctl_tcp_nometrics_save;\n extern int sysctl_tcp_moderate_rcvbuf;\n@@ -1311,9 +1310,9 @@ void tcp_select_initial_window(int __space, __u32 mss, __u32 *rcv_wnd,\n \t\t\t       __u32 *window_clamp, int wscale_ok,\n \t\t\t       __u8 *rcv_wscale, __u32 init_rcv_wnd);\n \n-static inline int tcp_win_from_space(int space)\n+static inline int tcp_win_from_space(const struct sock *sk, int space)\n {\n-\tint tcp_adv_win_scale = sysctl_tcp_adv_win_scale;\n+\tint tcp_adv_win_scale = sock_net(sk)->ipv4.sysctl_tcp_adv_win_scale;\n \n \treturn tcp_adv_win_scale <= 0 ?\n \t\t(space>>(-tcp_adv_win_scale)) :\n@@ -1323,13 +1322,13 @@ static inline int tcp_win_from_space(int space)\n /* Note: caller must be prepared to deal with negative returns */\n static inline int tcp_space(const struct sock *sk)\n {\n-\treturn tcp_win_from_space(sk->sk_rcvbuf -\n+\treturn tcp_win_from_space(sk, sk->sk_rcvbuf -\n \t\t\t\t  atomic_read(&sk->sk_rmem_alloc));\n }\n \n static inline int tcp_full_space(const struct sock *sk)\n {\n-\treturn tcp_win_from_space(sk->sk_rcvbuf);\n+\treturn tcp_win_from_space(sk, sk->sk_rcvbuf);\n }\n \n extern void tcp_openreq_init_rwin(struct request_sock *req,\ndiff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c\nindex e057788834a99cf99e141a602ddbe19b8e6fce3c..a95123e1e7da706c88bf5553b7d8ef6c2653ab50 100644\n--- a/net/ipv4/sysctl_net_ipv4.c\n+++ b/net/ipv4/sysctl_net_ipv4.c\n@@ -437,15 +437,6 @@ static struct ctl_table ipv4_table[] = {\n \t\t.proc_handler\t= proc_dointvec_minmax,\n \t\t.extra1\t\t= &one,\n \t},\n-\t{\n-\t\t.procname\t= \"tcp_adv_win_scale\",\n-\t\t.data\t\t= &sysctl_tcp_adv_win_scale,\n-\t\t.maxlen\t\t= sizeof(int),\n-\t\t.mode\t\t= 0644,\n-\t\t.proc_handler\t= proc_dointvec_minmax,\n-\t\t.extra1\t\t= &tcp_adv_win_scale_min,\n-\t\t.extra2\t\t= &tcp_adv_win_scale_max,\n-\t},\n \t{\n \t\t.procname\t= \"tcp_frto\",\n \t\t.data\t\t= &sysctl_tcp_frto,\n@@ -1145,6 +1136,15 @@ static struct ctl_table ipv4_net_table[] = {\n \t\t.mode\t\t= 0644,\n \t\t.proc_handler\t= proc_dointvec\n \t},\n+\t{\n+\t\t.procname\t= \"tcp_adv_win_scale\",\n+\t\t.data\t\t= &init_net.ipv4.sysctl_tcp_adv_win_scale,\n+\t\t.maxlen\t\t= sizeof(int),\n+\t\t.mode\t\t= 0644,\n+\t\t.proc_handler\t= proc_dointvec_minmax,\n+\t\t.extra1\t\t= &tcp_adv_win_scale_min,\n+\t\t.extra2\t\t= &tcp_adv_win_scale_max,\n+\t},\n \t{ }\n };\n \ndiff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c\nindex 6af4b58ac6d5de54bdbb418f41a0b18eee38ca50..8ee2c84b0bc67f943dbaea95d9433e82b9a7d082 100644\n--- a/net/ipv4/tcp_input.c\n+++ b/net/ipv4/tcp_input.c\n@@ -79,9 +79,6 @@\n #include <linux/unaligned/access_ok.h>\n #include <linux/static_key.h>\n \n-int sysctl_tcp_adv_win_scale __read_mostly = 1;\n-EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);\n-\n /* rfc5961 challenge ack rate limiting */\n int sysctl_tcp_challenge_ack_limit = 1000;\n \n@@ -363,8 +360,8 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb)\n {\n \tstruct tcp_sock *tp = tcp_sk(sk);\n \t/* Optimize this! */\n-\tint truesize = tcp_win_from_space(skb->truesize) >> 1;\n-\tint window = tcp_win_from_space(sysctl_tcp_rmem[2]) >> 1;\n+\tint truesize = tcp_win_from_space(sk, skb->truesize) >> 1;\n+\tint window = tcp_win_from_space(sk, sysctl_tcp_rmem[2]) >> 1;\n \n \twhile (tp->rcv_ssthresh <= window) {\n \t\tif (truesize <= skb->len)\n@@ -389,7 +386,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)\n \t\t/* Check #2. Increase window, if skb with such overhead\n \t\t * will fit to rcvbuf in future.\n \t\t */\n-\t\tif (tcp_win_from_space(skb->truesize) <= skb->len)\n+\t\tif (tcp_win_from_space(sk, skb->truesize) <= skb->len)\n \t\t\tincr = 2 * tp->advmss;\n \t\telse\n \t\t\tincr = __tcp_grow_window(sk, skb);\n@@ -630,7 +627,7 @@ void tcp_rcv_space_adjust(struct sock *sk)\n \t\t}\n \n \t\trcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER);\n-\t\twhile (tcp_win_from_space(rcvmem) < tp->advmss)\n+\t\twhile (tcp_win_from_space(sk, rcvmem) < tp->advmss)\n \t\t\trcvmem += 128;\n \n \t\trcvbuf = min(rcvwin / tp->advmss * rcvmem, sysctl_tcp_rmem[2]);\n@@ -4809,7 +4806,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,\n \t\t *   overlaps to the next one.\n \t\t */\n \t\tif (!(TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)) &&\n-\t\t    (tcp_win_from_space(skb->truesize) > skb->len ||\n+\t\t    (tcp_win_from_space(sk, skb->truesize) > skb->len ||\n \t\t     before(TCP_SKB_CB(skb)->seq, start))) {\n \t\t\tend_of_skbs = false;\n \t\t\tbreak;\ndiff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c\nindex 189664ebd28e4cda7ef40a47591c3bd8cac3574b..1fe30fb99308b3e3fd07509b509b0e3727cc5d44 100644\n--- a/net/ipv4/tcp_ipv4.c\n+++ b/net/ipv4/tcp_ipv4.c\n@@ -2491,6 +2491,7 @@ static int __net_init tcp_sk_init(struct net *net)\n \tnet->ipv4.sysctl_tcp_max_reordering = 300;\n \tnet->ipv4.sysctl_tcp_dsack = 1;\n \tnet->ipv4.sysctl_tcp_app_win = 31;\n+\tnet->ipv4.sysctl_tcp_adv_win_scale = 1;\n \n \tnet->ipv4.sysctl_tcp_fastopen = TFO_CLIENT_ENABLE;\n \tspin_lock_init(&net->ipv4.tcp_fastopen_ctx_lock);\n","prefixes":["v2","net-next","14/15"]}