Add sysctl to set the advertised TCP initial receive window.
Subsystems (4)
PATCH 1/1 Add sysctl to set the advertised TCP initial receive window.
Add a sysctl, tcp_init_rcv_wnd, to set the TCP initial receive window size advertised by passive and active TCP connections.
The current Linux TCP implementation limits the advertised TCP initial receive window to the one proscribed by slow start. For short leave TCP connections used for transaction type of traffic (i.e. http requests), bounding the advertised TCP initial receive window results in increased latency to complete the transaction. There exists environments where strict adherence to using the TCP initial receive window used by slow start is un-necessary.
The tcp_init_rcv_wnd sysctl allows increasing the TCP initial receive window for all TCP connections or on a per TCP connection, allowing for some of the TCP connection to advertise larger TCP receive window than the ones bounded by slow start.
---
Documentation/networking/ip-sysctl.txt | 6 ++++++ include/linux/tcp.h | 2 ++ include/net/tcp.h | 7 ++++++- net/ipv4/inet_connection_sock.c | 5 +++++ net/ipv4/syncookies.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 8 ++++++++ net/ipv4/tcp.c | 10 ++++++++++ net/ipv4/tcp_ipv4.c | 3 ++- net/ipv4/tcp_output.c | 20 ++++++++++++++++---- net/ipv6/syncookies.c | 3 +-- 10 files changed, 57 insertions(+), 9 deletions(-)
Documentation/networking/ip-sysctl.txt +6 -0
@@ -479,6 +479,12 @@ tcp_dma_copybreak - INTEGER and CONFIG_NET_DMA is enabled. Default: 4096 +tcp_init_rcv_wnd - INTEGER + Initial receive window, in MSS, advertised by an active or passive + tcp socket. Use a value from 0 to TCP_INIT_RCV_WND_MAX. When + set to 0, use an initial receive window following RFC2414. + Default: 0 + UDP variables: udp_mem - vector of 3 INTEGERs: min, pressure, max
include/linux/tcp.h +2 -0
@@ -96,6 +96,7 @@ enum {#define TCP_QUICKACK 12/* Block/reenable quick acks */ #define TCP_CONGESTION 13/* Congestion control algorithm */ #define TCP_MD5SIG 14/* TCP MD5 Signature (RFC2385) */ +#define TCP_INIT_RCV_WND 15/* Passive connection receive window */ #define TCPI_OPT_TIMESTAMPS 1#define TCPI_OPT_SACK 2
@@ -221,6 +222,7 @@ struct tcp_options_received {u8 num_sacks;/* Number of SACK blocks */ u16 user_mss;/* mss requested by user in ioctl */ u16 mss_clamp;/* Maximal mss, negotiated at connection setup */ +u8 init_rcv_wnd;/* TCP initial receive window in MSS */ };/* This is the max number of SACKS that we'll generate and process. It's safe
include/net/tcp.h +6 -1
@@ -65,6 +65,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);/* Minimal RCV_MSS. */ #define TCP_MIN_RCVMSS 536U +/* TCP initial receive window. Maximum number of mss allowed. */ +#define TCP_INIT_RCV_WND_MAX 16 +/* The least MTU to use for probing */ #define TCP_BASE_MSS 512
@@ -237,6 +240,7 @@ extern int sysctl_tcp_base_mss;extern int sysctl_tcp_workaround_signed_windows;extern int sysctl_tcp_slow_start_after_idle;extern int sysctl_tcp_max_ssthresh; +extern int sysctl_tcp_init_rcv_wnd;extern atomic_t tcp_memory_allocated;extern struct percpu_counter tcp_sockets_allocated;
@@ -972,7 +976,8 @@ static inline void tcp_sack_reset(struct tcp_options_received *rx_opt)/* Determine a window scaling and initial window to offer. */ extern void tcp_select_initial_window (int __space,__u32 mss,__u32 *rcv_wnd,__u32 *window_clamp, -int wscale_ok,__u8 *rcv_wscale); +int wscale_ok,__u8 *rcv_wscale, +struct tcp_sock *tp);static inline int tcp_win_from_space (int space) {
net/ipv4/inet_connection_sock.c +5 -0
@@ -20,6 +20,7 @@#include <net/inet_hashtables.h> #include <net/inet_timewait_sock.h> #include <net/ip.h> +#include <net/tcp.h> #include <net/route.h> #include <net/tcp_states.h> #include <net/xfrm.h>
@@ -628,11 +629,15 @@ int inet_csk_listen_start(struct sock *sk, const int nr_table_entries) {struct inet_sock *inet =inet_sk (sk);struct inet_connection_sock *icsk =inet_csk (sk); +struct tcp_sock *tp =tcp_sk (sk);int rc =reqsk_queue_alloc (&icsk->icsk_accept_queue, nr_table_entries);if (rc !=0 )return rc; +if (tp->rx_opt.init_rcv_wnd ==0 ) + tp->rx_opt.init_rcv_wnd = sysctl_tcp_init_rcv_wnd; + sk->sk_max_ack_backlog =0 ; sk->sk_ack_backlog =0 ;inet_csk_delack_init (sk);
net/ipv4/syncookies.c +1 -1
@@ -356,7 +356,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,tcp_select_initial_window (tcp_full_space (sk), req->mss, &req->rcv_wnd, &req->window_clamp, - ireq->wscale_ok, &rcv_wscale); + ireq->wscale_ok, &rcv_wscale, tp); ireq->rcv_wscale = rcv_wscale;
net/ipv4/sysctl_net_ipv4.c +8 -0
@@ -656,6 +656,14 @@ static struct ctl_table ipv4_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "tcp_init_rcv_wnd", + .data = &sysctl_tcp_init_rcv_wnd, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + },#ifdef CONFIG_NETLABEL { .ctl_name = NET_CIPSOV4_CACHE_ENABLE,
net/ipv4/tcp.c +10 -0
@@ -2248,6 +2248,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,break ;#endif +case TCP_INIT_RCV_WND : + val =min_t (int, val,TCP_INIT_RCV_WND_MAX ); + tp->rx_opt.init_rcv_wnd = val; +break ; +default : err = -ENOPROTOOPT ;break ;
@@ -2425,6 +2430,11 @@ static int do_tcp_getsockopt(struct sock *sk, int level,if (copy_to_user (optval, icsk->icsk_ca_ops->name, len))return -EFAULT ;return 0 ; + +case TCP_INIT_RCV_WND : + val = tp->rx_opt.init_rcv_wnd; +break ; +default :return -ENOPROTOOPT ; }
net/ipv4/tcp_ipv4.c +2 -1
@@ -1829,6 +1829,8 @@ static int tcp_v4_init_sock(struct sock *sk) sk->sk_sndbuf = sysctl_tcp_wmem[1 ]; sk->sk_rcvbuf = sysctl_tcp_rmem[1 ]; + tp->rx_opt.init_rcv_wnd = sysctl_tcp_init_rcv_wnd; +local_bh_disable ();percpu_counter_inc (&tcp_sockets_allocated);local_bh_enable ();
@@ -2493,4 +2495,3 @@ EXPORT_SYMBOL(tcp_proc_register);EXPORT_SYMBOL (tcp_proc_unregister);#endif EXPORT_SYMBOL (sysctl_tcp_low_latency); -
net/ipv4/tcp_output.c +16 -4
@@ -59,6 +59,9 @@ int sysctl_tcp_base_mss __read_mostly = 512;/* By default, RFC2861 behavior. */ int sysctl_tcp_slow_start_after_idle__read_mostly =1 ; +/* Initial advertised receive window. Enabled using a non '0' value.*/ +int sysctl_tcp_init_rcv_wnd__read_mostly =0 ; +/* Account for new data that has been sent to the network. */ static void tcp_event_new_data_sent (struct sock *sk,struct sk_buff *skb) {
@@ -179,7 +182,8 @@ static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts)*/ void tcp_select_initial_window (int __space,__u32 mss,__u32 *rcv_wnd,__u32 *window_clamp, -int wscale_ok,__u8 *rcv_wscale) +int wscale_ok,__u8 *rcv_wscale, +struct tcp_sock *tp) {unsigned int space = (__space <0 ?0 : __space);
@@ -228,7 +232,13 @@ void tcp_select_initial_window(int __space, __u32 mss, init_cwnd =2 ; else if (mss > 1460) init_cwnd =3 ; -if (*rcv_wnd > init_cwnd * mss) +/* when initializing use the value from init_rcv_wnd +* rather than the default from above +*/ +if (tp && tp->rx_opt.init_rcv_wnd && + (*rcv_wnd > tp->rx_opt.init_rcv_wnd * mss)) + *rcv_wnd = tp->rx_opt.init_rcv_wnd * mss; +else if (*rcv_wnd > init_cwnd * mss) *rcv_wnd = init_cwnd * mss; }
@@ -2254,7 +2264,8 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, &req->rcv_wnd, &req->window_clamp, ireq->wscale_ok, - &rcv_wscale); + &rcv_wscale, + tp); ireq->rcv_wscale = rcv_wscale; }
@@ -2342,7 +2353,8 @@ static void tcp_connect_init(struct sock *sk) &tp->rcv_wnd, &tp->window_clamp, sysctl_tcp_window_scaling, - &rcv_wscale); + &rcv_wscale, + tp); tp->rx_opt.rcv_wscale = rcv_wscale; tp->rcv_ssthresh = tp->rcv_wnd;
net/ipv6/syncookies.c +1 -2
@@ -267,7 +267,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) req->window_clamp = tp->window_clamp ? :dst_metric (dst,RTAX_WINDOW );tcp_select_initial_window (tcp_full_space (sk), req->mss, &req->rcv_wnd, &req->window_clamp, - ireq->wscale_ok, &rcv_wscale); + ireq->wscale_ok, &rcv_wscale, tp); ireq->rcv_wscale = rcv_wscale;
@@ -278,4 +278,3 @@ out_free:reqsk_free (req);return NULL ; } -
Quoted 2 lines · On Tue, 2009-12-08 at 14:40 -0800, [email protected] wrote:
Add a sysctl,
tcp_init_rcv_wnd, to set the TCP initial receive window size advertised by passive and active TCP connections.
[]
Quoted 5 lines
net/ipv4/sysctl_net_ipv4.c +0
-0
net/ipv4/sysctl_net_ipv4.c static struct ctl_table ipv4_table[] = { · line 665
Quoted 10 lines
net/ipv4/sysctl_net_ipv4.c +7
-0@@ -656,6 +656,14 @@ static struct ctl_table ipv4_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "tcp_init_rcv_wnd", + .data = &sysctl_tcp_init_rcv_wnd, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec_minmax, .extra1 = &zero, .extra2 = &SOMESTATIC_FOR_TCP_INIT_RCV_WND_MAX,
?
Quoted 9 lines · [email protected] writes:
Add a sysctl,
tcp_init_rcv_wnd, to set the TCP initial receive window size advertised by passive and active TCP connections.
The current Linux TCP implementation limits the advertised TCP initial receive window to the one proscribed by slow start. For short leave TCP connections used for transaction type of traffic (i.e. http requests), bounding the advertised TCP initial receive window results in increased latency to complete the transaction. There exists environments where strict adherence to using the TCP initial receive window used by slow start is un-necessary.
That's not the Internet?
Quoted 4 lines
The
tcp_init_rcv_wndsysctl allows increasing the TCP initial receive window for all TCP connections or on a per TCP connection, allowing for some of the TCP connection to advertise larger TCP receive window than the ones bounded by slow start.
Traditionally it was very discouraged to expose such settings to users. There's the danger that lots of people will essentially turn off cwnd without knowing what they're doing to "make downloads go faster", causing problems in the public network.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 19 lines · Andi Kleen
Quoted 9 lines · [email protected] writes:
Add a sysctl,
tcp_init_rcv_wnd, to set the TCP initial receive window size advertised by passive and active TCP connections.
The current Linux TCP implementation limits the advertised TCP initial receive window to the one proscribed by slow start. For short leave TCP connections used for transaction type of traffic (i.e. http requests), bounding the advertised TCP initial receive window results in increased latency to complete the transaction. There exists environments where strict adherence to using the TCP initial receive window used by slow start is un-necessary.That's not the Internet?
Quoted 4 lines
The
tcp_init_rcv_wndsysctl allows increasing the TCP initial receive window for all TCP connections or on a per TCP connection, allowing for some of the TCP connection to advertise larger TCP receive window than the ones bounded by slow start.
Quoted 5 lines
Traditionally it was very discouraged to expose such settings to users. There's the danger that lots of people will essentially turn off cwnd without knowing what they're doing to "make downloads go faster", causing problems in the public network.
The dangers to the Internet are not exposed on the receiver side but more on the sender side and its correct adherence to slow start. A large majority of clients on the Internet are currently advertising initial receive windows much higher than 3*MSS (in many cases 64K or higher), so the impetus is on server side to do the right thing.
Support for setting initial congestion window is already supported in the stack, but, as has been pointed out this list, it's pretty useless without the ability to set a larger initial receive window. If we can use larger initial congestion windows on private networks that we know to be essentially uncongested, this can result in reduced transactional latency by one or more RTTs. The performance benefits should be fairly obvious, but we can provide numbers if necessary.
Thanks,
Tom
Quoted 9 lines
-Andi
--
[email protected] -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
David Miller
maintainerFrom: Tom Herbert <[email protected]>
Date: Wed, 9 Dec 2009 10:01:24 -0800
Quoted 2 lines
If we can use larger initial congestion windows on private networks that we know to be
With the keyword here being "network", which is why this must be a route attribute not a sysctl with global unilatteral effect.
Otherwise I can tell you what people with both forward and inward facing interfaces are going to do, they'll turn the thing on globally with your sysctl even though they process real Internet traffic.
No way, we're not going to make it so easy to screw things up.
I like the suggestion, it keeps it in the line of how init_cwnd works now.
Quoted 15 lines · David Miller
From: Tom Herbert <[email protected]>
Date: Wed, 9 Dec 2009 10:01:24 -0800Quoted 2 lines
If we can use larger initial congestion windows on private networks that we know to be
With the keyword here being "network", which is why this must be a route attribute not a sysctl with global unilatteral effect.
Otherwise I can tell you what people with both forward and inward facing interfaces are going to do, they'll turn the thing on globally with your sysctl even though they process real Internet traffic.
No way, we're not going to make it so easy to screw things up.