@@ -3276,9 +3276,23 @@ void __init tcp_init(void)
sysctl_tcp_max_orphans = cnt / 2;
sysctl_max_syn_backlog = max(128, cnt / 256);
+ /*
+ * Despite the sysctl name, those values are always used in the code.
+ * CONFIG_PROC_SYSCTL only exposes it as a sysctl, allowing the admin
+ * to tweak them. If this is not configured, we need to provide
+ * a default value here
+ */
+#ifdef CONFIG_PROC_SYSCTL
/* Set per-socket limits to no more than 1/128 the pressure threshold */
limit = ((unsigned long)init_net.ipv4.sysctl_tcp_mem[1])
<< (PAGE_SHIFT - 7);
+#else
+ limit = nr_free_buffer_pages() / 8;
+ limit = max(limit, 128UL);
+ init_net.ipv4.sysctl_tcp_mem[0] = limit / 4 * 3;
+ init_net.ipv4.sysctl_tcp_mem[1] = limit;
+ init_net.ipv4.sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
+#endif
max_share = min(4UL*1024*1024, limit);
sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;