浏览代码

sysctl net: Keep tcp_syn_retries inside the boundary

Limit the min/max value passed to the
/proc/sys/net/ipv4/tcp_syn_retries.

Signed-off-by: Michal Tesar <mtesar@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Michal Tesar 12 年之前
父节点
当前提交
651e92716a
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      net/ipv4/sysctl_net_ipv4.c

+ 5 - 1
net/ipv4/sysctl_net_ipv4.c

@@ -36,6 +36,8 @@ static int tcp_adv_win_scale_min = -31;
 static int tcp_adv_win_scale_max = 31;
 static int tcp_adv_win_scale_max = 31;
 static int ip_ttl_min = 1;
 static int ip_ttl_min = 1;
 static int ip_ttl_max = 255;
 static int ip_ttl_max = 255;
+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_min[] = { 0, 0 };
 static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
 static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
 
 
@@ -332,7 +334,9 @@ static struct ctl_table ipv4_table[] = {
 		.data		= &sysctl_tcp_syn_retries,
 		.data		= &sysctl_tcp_syn_retries,
 		.maxlen		= sizeof(int),
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &tcp_syn_retries_min,
+		.extra2		= &tcp_syn_retries_max
 	},
 	},
 	{
 	{
 		.procname	= "tcp_synack_retries",
 		.procname	= "tcp_synack_retries",