Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: increase sk_[max_]ack_backlog

sk_ack_backlog & sk_max_ack_backlog were 16bit fields, meaning
listen() backlog was limited to 65535.

It is time to increase the width to allow much bigger backlog,
if admins change /proc/sys/net/core/somaxconn &
/proc/sys/net/ipv4/tcp_max_syn_backlog default values.

Tested:

echo 5000000 >/proc/sys/net/core/somaxconn
echo 5000000 >/proc/sys/net/ipv4/tcp_max_syn_backlog

Ran a SYNFLOOD test against a listener using listen(fd, 5000000)

myhost~# grep request_sock_TCP /proc/slabinfo
request_sock_TCP 4185642 4411940 304 13 1 : tunables 54 27 8 : slabdata 339380 339380 0

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
becb74f0 fa76ce73

+2 -4
+2 -2
include/net/sock.h
··· 405 405 rwlock_t sk_callback_lock; 406 406 int sk_err, 407 407 sk_err_soft; 408 - unsigned short sk_ack_backlog; 409 - unsigned short sk_max_ack_backlog; 408 + u32 sk_ack_backlog; 409 + u32 sk_max_ack_backlog; 410 410 __u32 sk_priority; 411 411 #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) 412 412 __u32 sk_cgrp_prioidx;
-2
net/core/sysctl_net_core.c
··· 24 24 25 25 static int zero = 0; 26 26 static int one = 1; 27 - static int ushort_max = USHRT_MAX; 28 27 29 28 static int net_msg_warn; /* Unused, but still a sysctl */ 30 29 ··· 400 401 .maxlen = sizeof(int), 401 402 .mode = 0644, 402 403 .extra1 = &zero, 403 - .extra2 = &ushort_max, 404 404 .proc_handler = proc_dointvec_minmax 405 405 }, 406 406 { }