blob: 4b161d5aba0b4123e027015a31c6214d501cee4a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
3 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Begun April 1, 1996, Mike Shaver.
5 * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
6 */
7
8#include <linux/mm.h>
9#include <linux/module.h>
10#include <linux/sysctl.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030011#include <linux/igmp.h>
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020012#include <linux/inetdevice.h>
Stephen Hemminger227b60f2007-10-10 17:30:46 -070013#include <linux/seqlock.h>
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -080014#include <linux/init.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/slab.h>
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000016#include <linux/nsproxy.h>
Glauber Costa3dc43e32011-12-11 21:47:05 +000017#include <linux/swap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <net/snmp.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030019#include <net/icmp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <net/ip.h>
21#include <net/route.h>
22#include <net/tcp.h>
Hideo Aoki95766ff2007-12-31 00:29:24 -080023#include <net/udp.h>
Paul Moore446fda42006-08-03 16:48:06 -070024#include <net/cipso_ipv4.h>
Pavel Emelyanov04128f22007-10-15 02:33:45 -070025#include <net/inet_frag.h>
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000026#include <net/ping.h>
Glauber Costa3aaabe22011-12-11 21:47:06 +000027#include <net/tcp_memcontrol.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Herbert Xu89cee8b2005-12-13 23:14:27 -080029static int zero;
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +000030static int one = 1;
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +000031static int four = 4;
Eric Dumazet95bd09e2013-08-27 05:46:32 -070032static int gso_max_segs = GSO_MAX_SEGS;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090033static int tcp_retr1_max = 255;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034static int ip_local_port_range_min[] = { 1, 1 };
35static int ip_local_port_range_max[] = { 65535, 65535 };
Alexey Dobriyan0147fc02010-11-22 12:54:21 +000036static int tcp_adv_win_scale_min = -31;
37static int tcp_adv_win_scale_max = 31;
Eric Dumazet249fab72010-12-13 12:16:14 -080038static int ip_ttl_min = 1;
39static int ip_ttl_max = 255;
Michal Tesar651e9272013-07-19 14:09:01 +020040static int tcp_syn_retries_min = 1;
41static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000042static int ip_ping_group_range_min[] = { 0, 0 };
43static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Stephen Hemminger227b60f2007-10-10 17:30:46 -070045/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070046static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070047{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070048 write_seqlock(&net->ipv4.sysctl_local_ports.lock);
49 net->ipv4.sysctl_local_ports.range[0] = range[0];
50 net->ipv4.sysctl_local_ports.range[1] = range[1];
51 write_sequnlock(&net->ipv4.sysctl_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070052}
53
54/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070055static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070056 void __user *buffer,
57 size_t *lenp, loff_t *ppos)
58{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070059 struct net *net =
60 container_of(table->data, struct net, ipv4.sysctl_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070061 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070062 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070063 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070064 .data = &range,
65 .maxlen = sizeof(range),
66 .mode = table->mode,
67 .extra1 = &ip_local_port_range_min,
68 .extra2 = &ip_local_port_range_max,
69 };
70
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070071 inet_get_local_port_range(net, &range[0], &range[1]);
72
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070073 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070074
75 if (write && ret == 0) {
Anton Arapova25de532007-10-18 22:00:17 -070076 if (range[1] < range[0])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070077 ret = -EINVAL;
78 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070079 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070080 }
81
82 return ret;
83}
84
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000085
Eric W. Biederman7064d162012-05-24 10:34:21 -060086static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000087{
Eric W. Biederman7064d162012-05-24 10:34:21 -060088 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070089 struct net *net =
90 container_of(table->data, struct net, ipv4.sysctl_ping_group_range);
Eric Dumazet95c96172012-04-15 05:58:06 +000091 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000092 do {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070093 seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000094
95 *low = data[0];
96 *high = data[1];
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070097 } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000098}
99
100/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600101static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000102{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600103 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700104 struct net *net =
105 container_of(table->data, struct net, ipv4.sysctl_ping_group_range);
106 write_seqlock(&net->ipv4.sysctl_local_ports.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600107 data[0] = low;
108 data[1] = high;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700109 write_sequnlock(&net->ipv4.sysctl_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000110}
111
112/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700113static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000114 void __user *buffer,
115 size_t *lenp, loff_t *ppos)
116{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600117 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000118 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600119 gid_t urange[2];
120 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700121 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600122 .data = &urange,
123 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000124 .mode = table->mode,
125 .extra1 = &ip_ping_group_range_min,
126 .extra2 = &ip_ping_group_range_max,
127 };
128
Eric W. Biederman7064d162012-05-24 10:34:21 -0600129 inet_get_ping_group_range_table(table, &low, &high);
130 urange[0] = from_kgid_munged(user_ns, low);
131 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000132 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
133
Eric W. Biederman7064d162012-05-24 10:34:21 -0600134 if (write && ret == 0) {
135 low = make_kgid(user_ns, urange[0]);
136 high = make_kgid(user_ns, urange[1]);
137 if (!gid_valid(low) || !gid_valid(high) ||
138 (urange[1] < urange[0]) || gid_lt(high, low)) {
139 low = make_kgid(&init_user_ns, 1);
140 high = make_kgid(&init_user_ns, 0);
141 }
142 set_ping_group_range(table, low, high);
143 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000144
145 return ret;
146}
147
Joe Perchesfe2c6332013-06-11 23:04:25 -0700148static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700149 void __user *buffer, size_t *lenp, loff_t *ppos)
150{
151 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700152 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700153 .data = val,
154 .maxlen = TCP_CA_NAME_MAX,
155 };
156 int ret;
157
158 tcp_get_default_congestion_control(val);
159
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700160 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700161 if (write && ret == 0)
162 ret = tcp_set_default_congestion_control(val);
163 return ret;
164}
165
Joe Perchesfe2c6332013-06-11 23:04:25 -0700166static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700167 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800168 void __user *buffer, size_t *lenp,
169 loff_t *ppos)
170{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700171 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800172 int ret;
173
174 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
175 if (!tbl.data)
176 return -ENOMEM;
177 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700178 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800179 kfree(tbl.data);
180 return ret;
181}
182
Joe Perchesfe2c6332013-06-11 23:04:25 -0700183static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800185 void __user *buffer, size_t *lenp,
186 loff_t *ppos)
187{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700188 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800189 int ret;
190
191 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
192 if (!tbl.data)
193 return -ENOMEM;
194
195 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700196 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800197 if (write && ret == 0)
198 ret = tcp_set_allowed_congestion_control(tbl.data);
199 kfree(tbl.data);
200 return ret;
201}
202
Joe Perchesfe2c6332013-06-11 23:04:25 -0700203static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
Glauber Costa3dc43e32011-12-11 21:47:05 +0000204 void __user *buffer, size_t *lenp,
205 loff_t *ppos)
206{
207 int ret;
208 unsigned long vec[3];
209 struct net *net = current->nsproxy->net_ns;
Andrew Mortonc255a452012-07-31 16:43:02 -0700210#ifdef CONFIG_MEMCG_KMEM
Glauber Costa3aaabe22011-12-11 21:47:06 +0000211 struct mem_cgroup *memcg;
212#endif
Glauber Costa3dc43e32011-12-11 21:47:05 +0000213
Joe Perchesfe2c6332013-06-11 23:04:25 -0700214 struct ctl_table tmp = {
Glauber Costa3dc43e32011-12-11 21:47:05 +0000215 .data = &vec,
216 .maxlen = sizeof(vec),
217 .mode = ctl->mode,
218 };
219
220 if (!write) {
221 ctl->data = &net->ipv4.sysctl_tcp_mem;
222 return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
223 }
224
225 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
226 if (ret)
227 return ret;
228
Andrew Mortonc255a452012-07-31 16:43:02 -0700229#ifdef CONFIG_MEMCG_KMEM
Glauber Costa3aaabe22011-12-11 21:47:06 +0000230 rcu_read_lock();
231 memcg = mem_cgroup_from_task(current);
232
233 tcp_prot_mem(memcg, vec[0], 0);
234 tcp_prot_mem(memcg, vec[1], 1);
235 tcp_prot_mem(memcg, vec[2], 2);
236 rcu_read_unlock();
237#endif
238
Glauber Costa3dc43e32011-12-11 21:47:05 +0000239 net->ipv4.sysctl_tcp_mem[0] = vec[0];
240 net->ipv4.sysctl_tcp_mem[1] = vec[1];
241 net->ipv4.sysctl_tcp_mem[2] = vec[2];
242
243 return 0;
244}
245
Joe Perchesfe2c6332013-06-11 23:04:25 -0700246static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
247 void __user *buffer, size_t *lenp,
248 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000249{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700250 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000251 struct tcp_fastopen_context *ctxt;
252 int ret;
253 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
254
255 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
256 if (!tbl.data)
257 return -ENOMEM;
258
259 rcu_read_lock();
260 ctxt = rcu_dereference(tcp_fastopen_ctx);
261 if (ctxt)
262 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000263 else
264 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000265 rcu_read_unlock();
266
267 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
268 user_key[0], user_key[1], user_key[2], user_key[3]);
269 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
270
271 if (write && ret == 0) {
272 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
273 user_key + 2, user_key + 3) != 4) {
274 ret = -EINVAL;
275 goto bad_key;
276 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200277 /* Generate a dummy secret but don't publish it. This
278 * is needed so we don't regenerate a new key on the
279 * first invocation of tcp_fastopen_cookie_gen
280 */
281 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000282 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
283 }
284
285bad_key:
286 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
287 user_key[0], user_key[1], user_key[2], user_key[3],
288 (char *)tbl.data, ret);
289 kfree(tbl.data);
290 return ret;
291}
292
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800293static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 .procname = "tcp_timestamps",
296 .data = &sysctl_tcp_timestamps,
297 .maxlen = sizeof(int),
298 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800299 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900301 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 .procname = "tcp_window_scaling",
303 .data = &sysctl_tcp_window_scaling,
304 .maxlen = sizeof(int),
305 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800306 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900308 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 .procname = "tcp_sack",
310 .data = &sysctl_tcp_sack,
311 .maxlen = sizeof(int),
312 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800313 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900315 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 .procname = "tcp_retrans_collapse",
317 .data = &sysctl_tcp_retrans_collapse,
318 .maxlen = sizeof(int),
319 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800320 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900322 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 .procname = "ip_default_ttl",
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900324 .data = &sysctl_ip_default_ttl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 .maxlen = sizeof(int),
326 .mode = 0644,
Eric Dumazet249fab72010-12-13 12:16:14 -0800327 .proc_handler = proc_dointvec_minmax,
328 .extra1 = &ip_ttl_min,
329 .extra2 = &ip_ttl_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900331 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 .procname = "ip_no_pmtu_disc",
333 .data = &ipv4_config.no_pmtu_disc,
334 .maxlen = sizeof(int),
335 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800336 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 },
338 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 .procname = "ip_nonlocal_bind",
340 .data = &sysctl_ip_nonlocal_bind,
341 .maxlen = sizeof(int),
342 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800343 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 },
345 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 .procname = "tcp_syn_retries",
347 .data = &sysctl_tcp_syn_retries,
348 .maxlen = sizeof(int),
349 .mode = 0644,
Michal Tesar651e9272013-07-19 14:09:01 +0200350 .proc_handler = proc_dointvec_minmax,
351 .extra1 = &tcp_syn_retries_min,
352 .extra2 = &tcp_syn_retries_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 },
354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 .procname = "tcp_synack_retries",
356 .data = &sysctl_tcp_synack_retries,
357 .maxlen = sizeof(int),
358 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800359 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 },
361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 .procname = "tcp_max_orphans",
363 .data = &sysctl_tcp_max_orphans,
364 .maxlen = sizeof(int),
365 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800366 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 },
368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700370 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 .maxlen = sizeof(int),
372 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800373 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 },
375 {
Alexander Duyck6648bd72012-06-21 13:58:31 +0000376 .procname = "ip_early_demux",
377 .data = &sysctl_ip_early_demux,
378 .maxlen = sizeof(int),
379 .mode = 0644,
380 .proc_handler = proc_dointvec
381 },
382 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 .procname = "ip_dynaddr",
384 .data = &sysctl_ip_dynaddr,
385 .maxlen = sizeof(int),
386 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800387 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 },
389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "tcp_keepalive_time",
391 .data = &sysctl_tcp_keepalive_time,
392 .maxlen = sizeof(int),
393 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800394 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .procname = "tcp_keepalive_probes",
398 .data = &sysctl_tcp_keepalive_probes,
399 .maxlen = sizeof(int),
400 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800401 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 },
403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .procname = "tcp_keepalive_intvl",
405 .data = &sysctl_tcp_keepalive_intvl,
406 .maxlen = sizeof(int),
407 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800408 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 },
410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 .procname = "tcp_retries1",
412 .data = &sysctl_tcp_retries1,
413 .maxlen = sizeof(int),
414 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800415 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 .extra2 = &tcp_retr1_max
417 },
418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 .procname = "tcp_retries2",
420 .data = &sysctl_tcp_retries2,
421 .maxlen = sizeof(int),
422 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800423 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 },
425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .procname = "tcp_fin_timeout",
427 .data = &sysctl_tcp_fin_timeout,
428 .maxlen = sizeof(int),
429 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800430 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 },
432#ifdef CONFIG_SYN_COOKIES
433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 .procname = "tcp_syncookies",
435 .data = &sysctl_tcp_syncookies,
436 .maxlen = sizeof(int),
437 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800438 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 },
440#endif
441 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000442 .procname = "tcp_fastopen",
443 .data = &sysctl_tcp_fastopen,
444 .maxlen = sizeof(int),
445 .mode = 0644,
446 .proc_handler = proc_dointvec,
447 },
448 {
Jerry Chu10467162012-08-31 12:29:11 +0000449 .procname = "tcp_fastopen_key",
450 .mode = 0600,
451 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
452 .proc_handler = proc_tcp_fastopen_key,
453 },
454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700456 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .maxlen = sizeof(int),
458 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800459 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "tcp_abort_on_overflow",
463 .data = &sysctl_tcp_abort_on_overflow,
464 .maxlen = sizeof(int),
465 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800466 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 .procname = "tcp_stdurg",
470 .data = &sysctl_tcp_stdurg,
471 .maxlen = sizeof(int),
472 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800473 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .procname = "tcp_rfc1337",
477 .data = &sysctl_tcp_rfc1337,
478 .maxlen = sizeof(int),
479 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800480 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 },
482 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 .procname = "tcp_max_syn_backlog",
484 .data = &sysctl_max_syn_backlog,
485 .maxlen = sizeof(int),
486 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800487 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 },
489 {
Amerigo Wange3826f12010-05-05 00:27:06 +0000490 .procname = "ip_local_reserved_ports",
491 .data = NULL, /* initialized in sysctl_ipv4_init */
492 .maxlen = 65536,
493 .mode = 0644,
494 .proc_handler = proc_do_large_bitmap,
495 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 .procname = "igmp_max_memberships",
498 .data = &sysctl_igmp_max_memberships,
499 .maxlen = sizeof(int),
500 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800501 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 .procname = "igmp_max_msf",
505 .data = &sysctl_igmp_max_msf,
506 .maxlen = sizeof(int),
507 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800508 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 },
510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 .procname = "inet_peer_threshold",
512 .data = &inet_peer_threshold,
513 .maxlen = sizeof(int),
514 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800515 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 },
517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "inet_peer_minttl",
519 .data = &inet_peer_minttl,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800522 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .procname = "inet_peer_maxttl",
526 .data = &inet_peer_maxttl,
527 .maxlen = sizeof(int),
528 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800529 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 },
531 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 .procname = "tcp_orphan_retries",
533 .data = &sysctl_tcp_orphan_retries,
534 .maxlen = sizeof(int),
535 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800536 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 },
538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 .procname = "tcp_fack",
540 .data = &sysctl_tcp_fack,
541 .maxlen = sizeof(int),
542 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800543 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 },
545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .procname = "tcp_reordering",
547 .data = &sysctl_tcp_reordering,
548 .maxlen = sizeof(int),
549 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800550 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 },
552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "tcp_dsack",
554 .data = &sysctl_tcp_dsack,
555 .maxlen = sizeof(int),
556 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800557 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "tcp_wmem",
561 .data = &sysctl_tcp_wmem,
562 .maxlen = sizeof(sysctl_tcp_wmem),
563 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000564 .proc_handler = proc_dointvec_minmax,
565 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 },
567 {
Eric Dumazetc9bee3b2013-07-22 20:27:07 -0700568 .procname = "tcp_notsent_lowat",
569 .data = &sysctl_tcp_notsent_lowat,
570 .maxlen = sizeof(sysctl_tcp_notsent_lowat),
571 .mode = 0644,
572 .proc_handler = proc_dointvec,
573 },
574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .procname = "tcp_rmem",
576 .data = &sysctl_tcp_rmem,
577 .maxlen = sizeof(sysctl_tcp_rmem),
578 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000579 .proc_handler = proc_dointvec_minmax,
580 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 },
582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .procname = "tcp_app_win",
584 .data = &sysctl_tcp_app_win,
585 .maxlen = sizeof(int),
586 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800587 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 },
589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "tcp_adv_win_scale",
591 .data = &sysctl_tcp_adv_win_scale,
592 .maxlen = sizeof(int),
593 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000594 .proc_handler = proc_dointvec_minmax,
595 .extra1 = &tcp_adv_win_scale_min,
596 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 },
598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .procname = "tcp_tw_reuse",
600 .data = &sysctl_tcp_tw_reuse,
601 .maxlen = sizeof(int),
602 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800603 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 },
605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "tcp_frto",
607 .data = &sysctl_tcp_frto,
608 .maxlen = sizeof(int),
609 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800610 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
612 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 .procname = "tcp_low_latency",
614 .data = &sysctl_tcp_low_latency,
615 .maxlen = sizeof(int),
616 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800617 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 },
619 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 .procname = "tcp_no_metrics_save",
621 .data = &sysctl_tcp_nometrics_save,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800624 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 },
626 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 .procname = "tcp_moderate_rcvbuf",
628 .data = &sysctl_tcp_moderate_rcvbuf,
629 .maxlen = sizeof(int),
630 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800631 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 },
633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "tcp_tso_win_divisor",
635 .data = &sysctl_tcp_tso_win_divisor,
636 .maxlen = sizeof(int),
637 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800638 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 },
640 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700641 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700643 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800644 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800646 {
John Heffner5d424d52006-03-20 17:53:41 -0800647 .procname = "tcp_mtu_probing",
648 .data = &sysctl_tcp_mtu_probing,
649 .maxlen = sizeof(int),
650 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800651 .proc_handler = proc_dointvec,
John Heffner5d424d52006-03-20 17:53:41 -0800652 },
653 {
John Heffner5d424d52006-03-20 17:53:41 -0800654 .procname = "tcp_base_mss",
655 .data = &sysctl_tcp_base_mss,
656 .maxlen = sizeof(int),
657 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800658 .proc_handler = proc_dointvec,
John Heffner5d424d52006-03-20 17:53:41 -0800659 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900660 {
Rick Jones15d99e02006-03-20 22:40:29 -0800661 .procname = "tcp_workaround_signed_windows",
662 .data = &sysctl_tcp_workaround_signed_windows,
663 .maxlen = sizeof(int),
664 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800665 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800666 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000667 {
668 .procname = "tcp_limit_output_bytes",
669 .data = &sysctl_tcp_limit_output_bytes,
670 .maxlen = sizeof(int),
671 .mode = 0644,
672 .proc_handler = proc_dointvec
673 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200674 {
675 .procname = "tcp_challenge_ack_limit",
676 .data = &sysctl_tcp_challenge_ack_limit,
677 .maxlen = sizeof(int),
678 .mode = 0644,
679 .proc_handler = proc_dointvec
680 },
Chris Leech95937822006-05-23 18:02:55 -0700681#ifdef CONFIG_NET_DMA
682 {
Chris Leech95937822006-05-23 18:02:55 -0700683 .procname = "tcp_dma_copybreak",
684 .data = &sysctl_tcp_dma_copybreak,
685 .maxlen = sizeof(int),
686 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800687 .proc_handler = proc_dointvec
Chris Leech95937822006-05-23 18:02:55 -0700688 },
689#endif
David S. Miller35089bb2006-06-13 22:33:04 -0700690 {
David S. Miller35089bb2006-06-13 22:33:04 -0700691 .procname = "tcp_slow_start_after_idle",
692 .data = &sysctl_tcp_slow_start_after_idle,
693 .maxlen = sizeof(int),
694 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800695 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700696 },
Paul Moore446fda42006-08-03 16:48:06 -0700697#ifdef CONFIG_NETLABEL
698 {
Paul Moore446fda42006-08-03 16:48:06 -0700699 .procname = "cipso_cache_enable",
700 .data = &cipso_v4_cache_enabled,
701 .maxlen = sizeof(int),
702 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800703 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700704 },
705 {
Paul Moore446fda42006-08-03 16:48:06 -0700706 .procname = "cipso_cache_bucket_size",
707 .data = &cipso_v4_cache_bucketsize,
708 .maxlen = sizeof(int),
709 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800710 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700711 },
712 {
Paul Moore446fda42006-08-03 16:48:06 -0700713 .procname = "cipso_rbm_optfmt",
714 .data = &cipso_v4_rbm_optfmt,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800717 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700718 },
719 {
Paul Moore446fda42006-08-03 16:48:06 -0700720 .procname = "cipso_rbm_strictvalid",
721 .data = &cipso_v4_rbm_strictvalid,
722 .maxlen = sizeof(int),
723 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800724 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700725 },
726#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800727 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800728 .procname = "tcp_available_congestion_control",
729 .maxlen = TCP_CA_BUF_MAX,
730 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800731 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800732 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800733 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800734 .procname = "tcp_allowed_congestion_control",
735 .maxlen = TCP_CA_BUF_MAX,
736 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800737 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800738 },
John Heffner886236c2007-03-25 19:21:45 -0700739 {
John Heffner886236c2007-03-25 19:21:45 -0700740 .procname = "tcp_max_ssthresh",
741 .data = &sysctl_tcp_max_ssthresh,
742 .maxlen = sizeof(int),
743 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800744 .proc_handler = proc_dointvec,
John Heffner886236c2007-03-25 19:21:45 -0700745 },
Hideo Aoki95766ff2007-12-31 00:29:24 -0800746 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000747 .procname = "tcp_thin_linear_timeouts",
748 .data = &sysctl_tcp_thin_linear_timeouts,
749 .maxlen = sizeof(int),
750 .mode = 0644,
751 .proc_handler = proc_dointvec
752 },
Andreas Petlund7e380172010-02-18 04:48:19 +0000753 {
754 .procname = "tcp_thin_dupack",
755 .data = &sysctl_tcp_thin_dupack,
756 .maxlen = sizeof(int),
757 .mode = 0644,
758 .proc_handler = proc_dointvec
759 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000760 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000761 .procname = "tcp_early_retrans",
762 .data = &sysctl_tcp_early_retrans,
763 .maxlen = sizeof(int),
764 .mode = 0644,
765 .proc_handler = proc_dointvec_minmax,
766 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000767 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000768 },
769 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700770 .procname = "tcp_min_tso_segs",
771 .data = &sysctl_tcp_min_tso_segs,
772 .maxlen = sizeof(int),
773 .mode = 0644,
774 .proc_handler = proc_dointvec_minmax,
775 .extra1 = &zero,
776 .extra2 = &gso_max_segs,
777 },
778 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800779 .procname = "udp_mem",
780 .data = &sysctl_udp_mem,
781 .maxlen = sizeof(sysctl_udp_mem),
782 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000783 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800784 },
785 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800786 .procname = "udp_rmem_min",
787 .data = &sysctl_udp_rmem_min,
788 .maxlen = sizeof(sysctl_udp_rmem_min),
789 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800790 .proc_handler = proc_dointvec_minmax,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000791 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800792 },
793 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800794 .procname = "udp_wmem_min",
795 .data = &sysctl_udp_wmem_min,
796 .maxlen = sizeof(sysctl_udp_wmem_min),
797 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800798 .proc_handler = proc_dointvec_minmax,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000799 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800800 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800801 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800803
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700804static struct ctl_table ipv4_net_table[] = {
805 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700806 .procname = "icmp_echo_ignore_all",
807 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
808 .maxlen = sizeof(int),
809 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800810 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700811 },
812 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700813 .procname = "icmp_echo_ignore_broadcasts",
814 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800817 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700818 },
819 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700820 .procname = "icmp_ignore_bogus_error_responses",
821 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
822 .maxlen = sizeof(int),
823 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800824 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700825 },
826 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700827 .procname = "icmp_errors_use_inbound_ifaddr",
828 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
829 .maxlen = sizeof(int),
830 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800831 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700832 },
833 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700834 .procname = "icmp_ratelimit",
835 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800838 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700839 },
840 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700841 .procname = "icmp_ratemask",
842 .data = &init_net.ipv4.sysctl_icmp_ratemask,
843 .maxlen = sizeof(int),
844 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800845 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700846 },
Neil Horman1080d702008-10-27 12:28:25 -0700847 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000848 .procname = "ping_group_range",
849 .data = &init_net.ipv4.sysctl_ping_group_range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600850 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000851 .mode = 0644,
852 .proc_handler = ipv4_ping_group_range,
853 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000854 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000855 .procname = "tcp_ecn",
856 .data = &init_net.ipv4.sysctl_tcp_ecn,
857 .maxlen = sizeof(int),
858 .mode = 0644,
859 .proc_handler = proc_dointvec
860 },
861 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700862 .procname = "ip_local_port_range",
863 .maxlen = sizeof(init_net.ipv4.sysctl_local_ports.range),
864 .data = &init_net.ipv4.sysctl_local_ports.range,
865 .mode = 0644,
866 .proc_handler = ipv4_local_port_range,
867 },
868 {
Glauber Costa3dc43e32011-12-11 21:47:05 +0000869 .procname = "tcp_mem",
870 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_mem),
871 .mode = 0644,
872 .proc_handler = ipv4_tcp_mem,
873 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700874 { }
875};
876
Pavel Emelyanov15775192008-03-26 01:54:18 -0700877static __net_init int ipv4_sysctl_init_net(struct net *net)
878{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700879 struct ctl_table *table;
880
881 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800882 if (!net_eq(net, &init_net)) {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700883 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
884 if (table == NULL)
885 goto err_alloc;
886
887 table[0].data =
888 &net->ipv4.sysctl_icmp_echo_ignore_all;
889 table[1].data =
890 &net->ipv4.sysctl_icmp_echo_ignore_broadcasts;
891 table[2].data =
892 &net->ipv4.sysctl_icmp_ignore_bogus_error_responses;
893 table[3].data =
894 &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr;
895 table[4].data =
896 &net->ipv4.sysctl_icmp_ratelimit;
897 table[5].data =
898 &net->ipv4.sysctl_icmp_ratemask;
Neil Horman1080d702008-10-27 12:28:25 -0700899 table[6].data =
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000900 &net->ipv4.sysctl_ping_group_range;
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000901 table[7].data =
902 &net->ipv4.sysctl_tcp_ecn;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700903 table[8].data =
904 &net->ipv4.sysctl_local_ports.range;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000905
Eric W. Biederman464dc802012-11-16 03:02:59 +0000906 /* Don't export sysctls to unprivileged users */
907 if (net->user_ns != &init_user_ns)
908 table[0].procname = NULL;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700909 }
910
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000911 /*
912 * Sane defaults - nobody may create ping sockets.
913 * Boot scripts should set this to distro-specific group.
914 */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600915 net->ipv4.sysctl_ping_group_range[0] = make_kgid(&init_user_ns, 1);
916 net->ipv4.sysctl_ping_group_range[1] = make_kgid(&init_user_ns, 0);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000917
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700918 /*
919 * Set defaults for local port range
920 */
921 seqlock_init(&net->ipv4.sysctl_local_ports.lock);
922 net->ipv4.sysctl_local_ports.range[0] = 32768;
923 net->ipv4.sysctl_local_ports.range[1] = 61000;
924
Glauber Costa4acb4192012-01-30 01:20:17 +0000925 tcp_init_mem(net);
Glauber Costa3dc43e32011-12-11 21:47:05 +0000926
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000927 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700928 if (net->ipv4.ipv4_hdr == NULL)
929 goto err_reg;
930
Pavel Emelyanov15775192008-03-26 01:54:18 -0700931 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700932
933err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800934 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700935 kfree(table);
936err_alloc:
937 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -0700938}
939
940static __net_exit void ipv4_sysctl_exit_net(struct net *net)
941{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700942 struct ctl_table *table;
943
944 table = net->ipv4.ipv4_hdr->ctl_table_arg;
945 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
946 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700947}
948
949static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
950 .init = ipv4_sysctl_init_net,
951 .exit = ipv4_sysctl_exit_net,
952};
953
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800954static __init int sysctl_ipv4_init(void)
955{
956 struct ctl_table_header *hdr;
Amerigo Wange3826f12010-05-05 00:27:06 +0000957 struct ctl_table *i;
958
959 for (i = ipv4_table; i->procname; i++) {
960 if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
961 i->data = sysctl_local_reserved_ports;
962 break;
963 }
964 }
965 if (!i->procname)
966 return -EINVAL;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800967
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000968 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700969 if (hdr == NULL)
970 return -ENOMEM;
971
972 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000973 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700974 return -ENOMEM;
975 }
976
977 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800978}
979
980__initcall(sysctl_ipv4_init);