Implement autosizing TCP socket buffers.
authorPeter Avalos <pavalos@theshell.com>
Mon, 20 Jul 2009 01:50:00 +0000 (15:50 -1000)
committerPeter Avalos <pavalos@theshell.com>
Sun, 26 Jul 2009 21:54:54 +0000 (11:54 -1000)
commit5b0b9fa51337cb0f3a9c78c8f74fbe4be19d719e
treef668d92265d5b79eb094880182b64f0f19b03e47
parent310ad1d2d199f5f1cd933620f083d8ee0feb578e
Implement autosizing TCP socket buffers.

Normally the socket buffers are static (either derived from global
defaults or set with setsockopt) and do not adapt to real network
conditions. Two things happen: a) your socket buffers are too small
and you can't reach the full potential of the network between both
hosts; b) your socket buffers are too big and you waste a lot of
kernel memory for data just sitting around.

With automatic TCP send and receive socket buffers we can start with a
small buffer and quickly grow it in parallel with the TCP congestion
window to match real network conditions.

New sysctls are:
  net.inet.tcp.sendbuf_auto=1 (enabled)
  net.inet.tcp.sendbuf_inc=8192 (8K, step size)
  net.inet.tcp.sendbuf_max=16777216 (16M, growth limit)
  net.inet.tcp.recvbuf_auto=1 (enabled)
  net.inet.tcp.recvbuf_inc=16384 (16K, step size)
  net.inet.tcp.recvbuf_max=16777216 (16M, growth limit)

Additionally, add limiters and sanity checks for TCP MSS (maximum segment
size) resource exhaustion attacks.

Obtained-from: FreeBSD
sys/kern/uipc_socket.c
sys/kern/uipc_socket2.c
sys/kern/uipc_usrreq.c
sys/netinet/tcp.h
sys/netinet/tcp_input.c
sys/netinet/tcp_output.c
sys/netinet/tcp_subr.c
sys/netinet/tcp_usrreq.c
sys/netinet/tcp_var.h
sys/sys/socketvar.h