net: set net.core.rmem_max and net.core.wmem_max to 4 MB
Subsystems (5)
PATCH 1/1 net: set net.core.rmem_max and net.core.wmem_max to 4 MB
SO_RCVBUF and SO_SNDBUF have limited range today, unless distros or system admins change rmem_max and wmem_max.
Even iproute2 uses 1 MB SO_RCVBUF which is capped by the kernel.
Decouple [rw]mem_max and [rw]mem_default and increase [rw]mem_max to 4 MB.
Before:
$ sysctl net.core.rmem_default net.core.rmem_max net.core.wmem_default net.core.wmem_max net.core.rmem_default = 212992 net.core.rmem_max = 212992 net.core.wmem_default = 212992 net.core.wmem_max = 212992
After:
$ sysctl net.core.rmem_default net.core.rmem_max net.core.wmem_default net.core.wmem_max net.core.rmem_default = 212992 net.core.rmem_max = 4194304 net.core.wmem_default = 212992 net.core.wmem_max = 4194304
--- Documentation/admin-guide/sysctl/net.rst | 4 ++++ Documentation/networking/ip-sysctl.rst | 6 +++--- include/net/sock.h | 4 ++-- net/core/sock.c | 8 ++++---- net/ipv4/arp.c | 2 +- net/ipv6/ndisc.c | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-)
Documentation/admin-guide/sysctl/net.rst +4 -0
@@ -222,6 +222,8 @@ rmem_max The maximum receive socket buffer size in bytes. +Default: 4194304 + rps_default_mask ----------------
@@ -247,6 +249,8 @@ wmem_max The maximum send socket buffer size in bytes. +Default: 4194304 + message_burst and message_cost ------------------------------
Documentation/networking/ip-sysctl.rst +3 -3
@@ -209,7 +209,7 @@ neigh/default/unres_qlen_bytes - INTEGER Setting negative value is meaningless and will return error. - Default: SK_WMEM_MAX, (same as net.core.wmem_default). + Default: SK_WMEM_DEFAULT, (same as net.core.wmem_default). Exact value depends on architecture and kernel options, but should be enough to allow queuing 256 packets
@@ -805,8 +805,8 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max This value results in initial window of 65535. max: maximal size of receive buffer allowed for automatically - selected receiver buffers for TCP socket. This value does not override - net.core.rmem_max. Calling setsockopt() with SO_RCVBUF disables + selected receiver buffers for TCP socket. + Calling setsockopt() with SO_RCVBUF disables automatic tuning of that socket's receive buffer size, in which case this value is ignored. Default: between 131072 and 32MB, depending on RAM size.
include/net/sock.h +2 -2
@@ -2924,8 +2924,8 @@ void sk_get_meminfo(const struct sock *sk, u32 *meminfo);*/ #define _SK_MEM_PACKETS 256#define _SK_MEM_OVERHEAD SKB_TRUESIZE(256) -#define SK_WMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) -#define SK_RMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) +#define SK_WMEM_DEFAULT (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) +#define SK_RMEM_DEFAULT (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS)extern __u32 sysctl_wmem_max;extern __u32 sysctl_rmem_max;
net/core/sock.c +4 -4
@@ -281,12 +281,12 @@ static struct lock_class_key af_elock_keys[AF_MAX];static struct lock_class_key af_kern_callback_keys[AF_MAX ];/* Run time adjustable parameters. */ -__u32 sysctl_wmem_max__read_mostly =SK_WMEM_MAX ; +__u32 sysctl_wmem_max__read_mostly =4 <<20 ;EXPORT_SYMBOL (sysctl_wmem_max); -__u32 sysctl_rmem_max__read_mostly =SK_RMEM_MAX ; +__u32 sysctl_rmem_max__read_mostly =4 <<20 ;EXPORT_SYMBOL (sysctl_rmem_max); -__u32 sysctl_wmem_default__read_mostly =SK_WMEM_MAX ; -__u32 sysctl_rmem_default__read_mostly =SK_RMEM_MAX ; +__u32 sysctl_wmem_default__read_mostly =SK_WMEM_DEFAULT ; +__u32 sysctl_rmem_default__read_mostly =SK_RMEM_DEFAULT ;DEFINE_STATIC_KEY_FALSE (memalloc_socks_key);EXPORT_SYMBOL_GPL (memalloc_socks_key);
net/ipv4/arp.c +1 -1
@@ -170,7 +170,7 @@ struct neigh_table arp_tbl = { [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, [NEIGH_VAR_INTERVAL_PROBE_TIME_MS] = 5 * HZ, [NEIGH_VAR_GC_STALETIME] = 60 * HZ, - [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, + [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_DEFAULT, [NEIGH_VAR_PROXY_QLEN] = 64, [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10,
net/ipv6/ndisc.c +1 -1
@@ -130,7 +130,7 @@ struct neigh_table nd_tbl = { [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, [NEIGH_VAR_INTERVAL_PROBE_TIME_MS] = 5 * HZ, [NEIGH_VAR_GC_STALETIME] = 60 * HZ, - [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, + [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_DEFAULT, [NEIGH_VAR_PROXY_QLEN] = 64, [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10,
Signature · 1 line
2.51.0.rc1.193.gad69d77794-goog
Quoted 20 lines · Eric Dumazet
SO_RCVBUFandSO_SNDBUFhave limited range today, unless distros or system admins changermem_maxandwmem_max.Even iproute2 uses 1 MB
SO_RCVBUFwhich is capped by the kernel.Decouple [rw]mem_max and [rw]mem_default and increase [rw]mem_max to 4 MB.
Before:
$ sysctl net.core.rmem_default net.core.rmem_max net.core.wmem_default net.core.wmem_max net.core.rmem_default = 212992 net.core.rmem_max = 212992 net.core.wmem_default = 212992 net.core.wmem_max = 212992After:
Quoted 8 lines
$ sysctl net.core.rmem_default net.core.rmem_max net.core.wmem_default net.core.wmem_max net.core.rmem_default = 212992 net.core.rmem_max = 4194304 net.core.wmem_default = 212992 net.core.wmem_max = 4194304Signed-off-by Eric Dumazet <[email protected]>---
Great! Thanks, Eric!
neal
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 19 Aug 2025 17:40:30 +0000 you wrote:
SO_RCVBUFandSO_SNDBUFhave limited range today, unless distros or system admins changermem_maxandwmem_max.Even iproute2 uses 1 MB
SO_RCVBUFwhich is capped by the kernel.Decouple [rw]mem_max and [rw]mem_default and increase [rw]mem_max to 4 MB.
[...]
Here is the summary with links:
- [net-next] net: set net.core.rmem_max and net.core.wmem_max to 4 MB
https://git.kernel.org/netdev/net-next/c/a6d4f25888b8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html