Skip to content

Commit

Permalink
net: limit tcp/udp rmem/wmem to SOCK_{RCV,SND}BUF_MIN
Browse files Browse the repository at this point in the history
This is similar to b1cb59c(net: sysctl_net_core: check SNDBUF
and RCVBUF for min length). I don't think too small values can cause
crashes in the case of udp and tcp, but I've seen this set to too
small values which triggered awful performance. It also makes the
setting consistent across all the wmem/rmem sysctls.

Signed-off-by: Sorin Dumitru <sdumitru@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sorin Dumitru authored and David S. Miller committed May 31, 2015
1 parent 5befa5e commit 8133534
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/ipv4/sysctl_net_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ static int tcp_syn_retries_min = 1;
static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
static int ip_ping_group_range_min[] = { 0, 0 };
static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
static int min_sndbuf = SOCK_MIN_SNDBUF;
static int min_rcvbuf = SOCK_MIN_RCVBUF;

/* Update system visible IP port range */
static void set_local_port_range(struct net *net, int range[2])
Expand Down Expand Up @@ -528,7 +530,7 @@ static struct ctl_table ipv4_table[] = {
.maxlen = sizeof(sysctl_tcp_wmem),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one,
.extra1 = &min_sndbuf,
},
{
.procname = "tcp_notsent_lowat",
Expand All @@ -543,7 +545,7 @@ static struct ctl_table ipv4_table[] = {
.maxlen = sizeof(sysctl_tcp_rmem),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one,
.extra1 = &min_rcvbuf,
},
{
.procname = "tcp_app_win",
Expand Down Expand Up @@ -756,15 +758,15 @@ static struct ctl_table ipv4_table[] = {
.maxlen = sizeof(sysctl_udp_rmem_min),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one
.extra1 = &min_rcvbuf,
},
{
.procname = "udp_wmem_min",
.data = &sysctl_udp_wmem_min,
.maxlen = sizeof(sysctl_udp_wmem_min),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one
.extra1 = &min_sndbuf,
},
{ }
};
Expand Down

0 comments on commit 8133534

Please sign in to comment.