blob: 0d3c038d7b0454eb2213ad88eb7ebfe27504b2ee [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>
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -060027#include <net/protocol.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 Dumazet43e122b2015-08-21 17:38:02 -070032static int thousand = 1000;
Eric Dumazet95bd09e2013-08-27 05:46:32 -070033static int gso_max_segs = GSO_MAX_SEGS;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090034static int tcp_retr1_max = 255;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035static int ip_local_port_range_min[] = { 1, 1 };
36static int ip_local_port_range_max[] = { 65535, 65535 };
Alexey Dobriyan0147fc02010-11-22 12:54:21 +000037static int tcp_adv_win_scale_min = -31;
38static int tcp_adv_win_scale_max = 31;
Krister Johansen4548b682017-01-20 17:49:11 -080039static int ip_privileged_port_min;
40static int ip_privileged_port_max = 65535;
Eric Dumazet249fab72010-12-13 12:16:14 -080041static int ip_ttl_min = 1;
42static int ip_ttl_max = 255;
Michal Tesar651e9272013-07-19 14:09:01 +020043static int tcp_syn_retries_min = 1;
44static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000045static int ip_ping_group_range_min[] = { 0, 0 };
46static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Florian Westphalb6690b12017-07-30 03:57:20 +020048/* obsolete */
49static int sysctl_tcp_low_latency __read_mostly;
50
Stephen Hemminger227b60f2007-10-10 17:30:46 -070051/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070052static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070053{
Eric Dumazeted2dfd92015-05-27 11:34:37 -070054 bool same_parity = !((range[0] ^ range[1]) & 1);
55
WANG Cong4ee3bd42015-11-03 14:32:57 -080056 write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
Eric Dumazeted2dfd92015-05-27 11:34:37 -070057 if (same_parity && !net->ipv4.ip_local_ports.warned) {
58 net->ipv4.ip_local_ports.warned = true;
59 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
60 }
Cong Wangc9d8f1a2014-05-06 11:02:49 -070061 net->ipv4.ip_local_ports.range[0] = range[0];
62 net->ipv4.ip_local_ports.range[1] = range[1];
WANG Cong4ee3bd42015-11-03 14:32:57 -080063 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070064}
65
66/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070067static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070068 void __user *buffer,
69 size_t *lenp, loff_t *ppos)
70{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070071 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070072 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070073 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070074 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070075 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070076 .data = &range,
77 .maxlen = sizeof(range),
78 .mode = table->mode,
79 .extra1 = &ip_local_port_range_min,
80 .extra2 = &ip_local_port_range_max,
81 };
82
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070083 inet_get_local_port_range(net, &range[0], &range[1]);
84
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070085 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070086
87 if (write && ret == 0) {
Krister Johansen4548b682017-01-20 17:49:11 -080088 /* Ensure that the upper limit is not smaller than the lower,
89 * and that the lower does not encroach upon the privileged
90 * port limit.
91 */
92 if ((range[1] < range[0]) ||
93 (range[0] < net->ipv4.sysctl_ip_prot_sock))
Stephen Hemminger227b60f2007-10-10 17:30:46 -070094 ret = -EINVAL;
95 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070096 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070097 }
98
99 return ret;
100}
101
Krister Johansen4548b682017-01-20 17:49:11 -0800102/* Validate changes from /proc interface. */
103static int ipv4_privileged_ports(struct ctl_table *table, int write,
104 void __user *buffer, size_t *lenp, loff_t *ppos)
105{
106 struct net *net = container_of(table->data, struct net,
107 ipv4.sysctl_ip_prot_sock);
108 int ret;
109 int pports;
110 int range[2];
111 struct ctl_table tmp = {
112 .data = &pports,
113 .maxlen = sizeof(pports),
114 .mode = table->mode,
115 .extra1 = &ip_privileged_port_min,
116 .extra2 = &ip_privileged_port_max,
117 };
118
119 pports = net->ipv4.sysctl_ip_prot_sock;
120
121 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
122
123 if (write && ret == 0) {
124 inet_get_local_port_range(net, &range[0], &range[1]);
125 /* Ensure that the local port range doesn't overlap with the
126 * privileged port range.
127 */
128 if (range[0] < pports)
129 ret = -EINVAL;
130 else
131 net->ipv4.sysctl_ip_prot_sock = pports;
132 }
133
134 return ret;
135}
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000136
Eric W. Biederman7064d162012-05-24 10:34:21 -0600137static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000138{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600139 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700140 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700141 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +0000142 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000143 do {
WANG Cong396a30c2016-10-20 14:19:46 -0700144 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000145
146 *low = data[0];
147 *high = data[1];
WANG Cong396a30c2016-10-20 14:19:46 -0700148 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000149}
150
151/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600152static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000153{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600154 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700155 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700156 container_of(table->data, struct net, ipv4.ping_group_range.range);
WANG Cong396a30c2016-10-20 14:19:46 -0700157 write_seqlock(&net->ipv4.ping_group_range.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600158 data[0] = low;
159 data[1] = high;
WANG Cong396a30c2016-10-20 14:19:46 -0700160 write_sequnlock(&net->ipv4.ping_group_range.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000161}
162
163/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700164static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000165 void __user *buffer,
166 size_t *lenp, loff_t *ppos)
167{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600168 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000169 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600170 gid_t urange[2];
171 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700172 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600173 .data = &urange,
174 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000175 .mode = table->mode,
176 .extra1 = &ip_ping_group_range_min,
177 .extra2 = &ip_ping_group_range_max,
178 };
179
Eric W. Biederman7064d162012-05-24 10:34:21 -0600180 inet_get_ping_group_range_table(table, &low, &high);
181 urange[0] = from_kgid_munged(user_ns, low);
182 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000183 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
184
Eric W. Biederman7064d162012-05-24 10:34:21 -0600185 if (write && ret == 0) {
186 low = make_kgid(user_ns, urange[0]);
187 high = make_kgid(user_ns, urange[1]);
188 if (!gid_valid(low) || !gid_valid(high) ||
189 (urange[1] < urange[0]) || gid_lt(high, low)) {
190 low = make_kgid(&init_user_ns, 1);
191 high = make_kgid(&init_user_ns, 0);
192 }
193 set_ping_group_range(table, low, high);
194 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000195
196 return ret;
197}
198
Joe Perchesfe2c6332013-06-11 23:04:25 -0700199static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700200 void __user *buffer, size_t *lenp, loff_t *ppos)
201{
202 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700203 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700204 .data = val,
205 .maxlen = TCP_CA_NAME_MAX,
206 };
207 int ret;
208
209 tcp_get_default_congestion_control(val);
210
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700211 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700212 if (write && ret == 0)
213 ret = tcp_set_default_congestion_control(val);
214 return ret;
215}
216
Joe Perchesfe2c6332013-06-11 23:04:25 -0700217static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700218 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800219 void __user *buffer, size_t *lenp,
220 loff_t *ppos)
221{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700222 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800223 int ret;
224
225 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
226 if (!tbl.data)
227 return -ENOMEM;
228 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700229 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800230 kfree(tbl.data);
231 return ret;
232}
233
Joe Perchesfe2c6332013-06-11 23:04:25 -0700234static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700235 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800236 void __user *buffer, size_t *lenp,
237 loff_t *ppos)
238{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700239 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800240 int ret;
241
242 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
243 if (!tbl.data)
244 return -ENOMEM;
245
246 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700247 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800248 if (write && ret == 0)
249 ret = tcp_set_allowed_congestion_control(tbl.data);
250 kfree(tbl.data);
251 return ret;
252}
253
Joe Perchesfe2c6332013-06-11 23:04:25 -0700254static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
255 void __user *buffer, size_t *lenp,
256 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000257{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700258 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000259 struct tcp_fastopen_context *ctxt;
260 int ret;
261 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
262
263 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
264 if (!tbl.data)
265 return -ENOMEM;
266
267 rcu_read_lock();
268 ctxt = rcu_dereference(tcp_fastopen_ctx);
269 if (ctxt)
270 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000271 else
272 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000273 rcu_read_unlock();
274
275 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
276 user_key[0], user_key[1], user_key[2], user_key[3]);
277 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
278
279 if (write && ret == 0) {
280 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
281 user_key + 2, user_key + 3) != 4) {
282 ret = -EINVAL;
283 goto bad_key;
284 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200285 /* Generate a dummy secret but don't publish it. This
286 * is needed so we don't regenerate a new key on the
287 * first invocation of tcp_fastopen_cookie_gen
288 */
289 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000290 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
291 }
292
293bad_key:
294 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
295 user_key[0], user_key[1], user_key[2], user_key[3],
296 (char *)tbl.data, ret);
297 kfree(tbl.data);
298 return ret;
299}
300
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600301static void proc_configure_early_demux(int enabled, int protocol)
302{
303 struct net_protocol *ipprot;
304#if IS_ENABLED(CONFIG_IPV6)
305 struct inet6_protocol *ip6prot;
306#endif
307
David Ahern58c4c6a2017-04-22 09:33:16 -0700308 rcu_read_lock();
309
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600310 ipprot = rcu_dereference(inet_protos[protocol]);
311 if (ipprot)
312 ipprot->early_demux = enabled ? ipprot->early_demux_handler :
313 NULL;
314
315#if IS_ENABLED(CONFIG_IPV6)
316 ip6prot = rcu_dereference(inet6_protos[protocol]);
317 if (ip6prot)
318 ip6prot->early_demux = enabled ? ip6prot->early_demux_handler :
319 NULL;
320#endif
David Ahern58c4c6a2017-04-22 09:33:16 -0700321 rcu_read_unlock();
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600322}
323
324static int proc_tcp_early_demux(struct ctl_table *table, int write,
325 void __user *buffer, size_t *lenp, loff_t *ppos)
326{
327 int ret = 0;
328
329 ret = proc_dointvec(table, write, buffer, lenp, ppos);
330
331 if (write && !ret) {
332 int enabled = init_net.ipv4.sysctl_tcp_early_demux;
333
334 proc_configure_early_demux(enabled, IPPROTO_TCP);
335 }
336
337 return ret;
338}
339
340static int proc_udp_early_demux(struct ctl_table *table, int write,
341 void __user *buffer, size_t *lenp, loff_t *ppos)
342{
343 int ret = 0;
344
345 ret = proc_dointvec(table, write, buffer, lenp, ppos);
346
347 if (write && !ret) {
348 int enabled = init_net.ipv4.sysctl_udp_early_demux;
349
350 proc_configure_early_demux(enabled, IPPROTO_UDP);
351 }
352
353 return ret;
354}
355
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700356static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
357 int write,
358 void __user *buffer,
359 size_t *lenp, loff_t *ppos)
360{
361 int ret;
362
363 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
364 if (write && ret == 0)
365 tcp_fastopen_active_timeout_reset();
Dave Watson734942c2017-06-14 11:37:14 -0700366
367 return ret;
368}
369
370static int proc_tcp_available_ulp(struct ctl_table *ctl,
371 int write,
372 void __user *buffer, size_t *lenp,
373 loff_t *ppos)
374{
375 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
376 int ret;
377
378 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
379 if (!tbl.data)
380 return -ENOMEM;
381 tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
382 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
383 kfree(tbl.data);
384
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700385 return ret;
386}
387
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800388static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "tcp_retrans_collapse",
391 .data = &sysctl_tcp_retrans_collapse,
392 .maxlen = sizeof(int),
393 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800394 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .procname = "tcp_max_orphans",
398 .data = &sysctl_tcp_max_orphans,
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 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000404 .procname = "tcp_fastopen",
405 .data = &sysctl_tcp_fastopen,
406 .maxlen = sizeof(int),
407 .mode = 0644,
408 .proc_handler = proc_dointvec,
409 },
410 {
Jerry Chu10467162012-08-31 12:29:11 +0000411 .procname = "tcp_fastopen_key",
412 .mode = 0600,
413 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
414 .proc_handler = proc_tcp_fastopen_key,
415 },
416 {
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700417 .procname = "tcp_fastopen_blackhole_timeout_sec",
418 .data = &sysctl_tcp_fastopen_blackhole_timeout,
419 .maxlen = sizeof(int),
420 .mode = 0644,
421 .proc_handler = proc_tfo_blackhole_detect_timeout,
422 .extra1 = &zero,
423 },
424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 .procname = "tcp_abort_on_overflow",
426 .data = &sysctl_tcp_abort_on_overflow,
427 .maxlen = sizeof(int),
428 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800429 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 },
431 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 .procname = "tcp_stdurg",
433 .data = &sysctl_tcp_stdurg,
434 .maxlen = sizeof(int),
435 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800436 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 },
438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 .procname = "tcp_rfc1337",
440 .data = &sysctl_tcp_rfc1337,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800443 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 },
445 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 .procname = "inet_peer_threshold",
447 .data = &inet_peer_threshold,
448 .maxlen = sizeof(int),
449 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800450 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 },
452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 .procname = "inet_peer_minttl",
454 .data = &inet_peer_minttl,
455 .maxlen = sizeof(int),
456 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800457 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 },
459 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 .procname = "inet_peer_maxttl",
461 .data = &inet_peer_maxttl,
462 .maxlen = sizeof(int),
463 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800464 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 },
466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 .procname = "tcp_fack",
468 .data = &sysctl_tcp_fack,
469 .maxlen = sizeof(int),
470 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800471 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 },
473 {
Yuchung Cheng4f41b1c2015-10-16 21:57:47 -0700474 .procname = "tcp_recovery",
475 .data = &sysctl_tcp_recovery,
476 .maxlen = sizeof(int),
477 .mode = 0644,
478 .proc_handler = proc_dointvec,
479 },
480 {
Eric Dumazetdca145f2014-10-27 21:45:24 -0700481 .procname = "tcp_max_reordering",
482 .data = &sysctl_tcp_max_reordering,
483 .maxlen = sizeof(int),
484 .mode = 0644,
485 .proc_handler = proc_dointvec
486 },
487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .procname = "tcp_dsack",
489 .data = &sysctl_tcp_dsack,
490 .maxlen = sizeof(int),
491 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800492 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
494 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700495 .procname = "tcp_mem",
496 .maxlen = sizeof(sysctl_tcp_mem),
497 .data = &sysctl_tcp_mem,
498 .mode = 0644,
499 .proc_handler = proc_doulongvec_minmax,
500 },
501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 .procname = "tcp_wmem",
503 .data = &sysctl_tcp_wmem,
504 .maxlen = sizeof(sysctl_tcp_wmem),
505 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000506 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700507 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "tcp_rmem",
511 .data = &sysctl_tcp_rmem,
512 .maxlen = sizeof(sysctl_tcp_rmem),
513 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000514 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700515 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 },
517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "tcp_app_win",
519 .data = &sysctl_tcp_app_win,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800522 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .procname = "tcp_adv_win_scale",
526 .data = &sysctl_tcp_adv_win_scale,
527 .maxlen = sizeof(int),
528 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000529 .proc_handler = proc_dointvec_minmax,
530 .extra1 = &tcp_adv_win_scale_min,
531 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 },
533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "tcp_frto",
535 .data = &sysctl_tcp_frto,
536 .maxlen = sizeof(int),
537 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800538 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
540 {
Yuchung Chengf6722582015-10-16 21:57:42 -0700541 .procname = "tcp_min_rtt_wlen",
542 .data = &sysctl_tcp_min_rtt_wlen,
543 .maxlen = sizeof(int),
544 .mode = 0644,
545 .proc_handler = proc_dointvec
546 },
547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 .procname = "tcp_low_latency",
549 .data = &sysctl_tcp_low_latency,
550 .maxlen = sizeof(int),
551 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800552 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 },
554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 .procname = "tcp_no_metrics_save",
556 .data = &sysctl_tcp_nometrics_save,
557 .maxlen = sizeof(int),
558 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800559 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 },
561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 .procname = "tcp_moderate_rcvbuf",
563 .data = &sysctl_tcp_moderate_rcvbuf,
564 .maxlen = sizeof(int),
565 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800566 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 },
568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "tcp_tso_win_divisor",
570 .data = &sysctl_tcp_tso_win_divisor,
571 .maxlen = sizeof(int),
572 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700576 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700578 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800579 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800581 {
Rick Jones15d99e02006-03-20 22:40:29 -0800582 .procname = "tcp_workaround_signed_windows",
583 .data = &sysctl_tcp_workaround_signed_windows,
584 .maxlen = sizeof(int),
585 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800586 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800587 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000588 {
589 .procname = "tcp_limit_output_bytes",
590 .data = &sysctl_tcp_limit_output_bytes,
591 .maxlen = sizeof(int),
592 .mode = 0644,
593 .proc_handler = proc_dointvec
594 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200595 {
596 .procname = "tcp_challenge_ack_limit",
597 .data = &sysctl_tcp_challenge_ack_limit,
598 .maxlen = sizeof(int),
599 .mode = 0644,
600 .proc_handler = proc_dointvec
601 },
David S. Miller35089bb2006-06-13 22:33:04 -0700602 {
David S. Miller35089bb2006-06-13 22:33:04 -0700603 .procname = "tcp_slow_start_after_idle",
604 .data = &sysctl_tcp_slow_start_after_idle,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800607 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700608 },
Paul Moore446fda42006-08-03 16:48:06 -0700609#ifdef CONFIG_NETLABEL
610 {
Paul Moore446fda42006-08-03 16:48:06 -0700611 .procname = "cipso_cache_enable",
612 .data = &cipso_v4_cache_enabled,
613 .maxlen = sizeof(int),
614 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800615 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700616 },
617 {
Paul Moore446fda42006-08-03 16:48:06 -0700618 .procname = "cipso_cache_bucket_size",
619 .data = &cipso_v4_cache_bucketsize,
620 .maxlen = sizeof(int),
621 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800622 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700623 },
624 {
Paul Moore446fda42006-08-03 16:48:06 -0700625 .procname = "cipso_rbm_optfmt",
626 .data = &cipso_v4_rbm_optfmt,
627 .maxlen = sizeof(int),
628 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800629 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700630 },
631 {
Paul Moore446fda42006-08-03 16:48:06 -0700632 .procname = "cipso_rbm_strictvalid",
633 .data = &cipso_v4_rbm_strictvalid,
634 .maxlen = sizeof(int),
635 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800636 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700637 },
638#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800639 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800640 .procname = "tcp_available_congestion_control",
641 .maxlen = TCP_CA_BUF_MAX,
642 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800643 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800644 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800645 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800646 .procname = "tcp_allowed_congestion_control",
647 .maxlen = TCP_CA_BUF_MAX,
648 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800649 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800650 },
John Heffner886236c2007-03-25 19:21:45 -0700651 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000652 .procname = "tcp_thin_linear_timeouts",
653 .data = &sysctl_tcp_thin_linear_timeouts,
654 .maxlen = sizeof(int),
655 .mode = 0644,
656 .proc_handler = proc_dointvec
657 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800658 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000659 .procname = "tcp_early_retrans",
660 .data = &sysctl_tcp_early_retrans,
661 .maxlen = sizeof(int),
662 .mode = 0644,
663 .proc_handler = proc_dointvec_minmax,
664 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000665 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000666 },
667 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700668 .procname = "tcp_min_tso_segs",
669 .data = &sysctl_tcp_min_tso_segs,
670 .maxlen = sizeof(int),
671 .mode = 0644,
672 .proc_handler = proc_dointvec_minmax,
Eric Dumazetd6a4e262015-05-26 08:55:28 -0700673 .extra1 = &one,
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700674 .extra2 = &gso_max_segs,
675 },
676 {
Eric Dumazet43e122b2015-08-21 17:38:02 -0700677 .procname = "tcp_pacing_ss_ratio",
678 .data = &sysctl_tcp_pacing_ss_ratio,
679 .maxlen = sizeof(int),
680 .mode = 0644,
681 .proc_handler = proc_dointvec_minmax,
682 .extra1 = &zero,
683 .extra2 = &thousand,
684 },
685 {
686 .procname = "tcp_pacing_ca_ratio",
687 .data = &sysctl_tcp_pacing_ca_ratio,
688 .maxlen = sizeof(int),
689 .mode = 0644,
690 .proc_handler = proc_dointvec_minmax,
691 .extra1 = &zero,
692 .extra2 = &thousand,
693 },
694 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800695 .procname = "tcp_autocorking",
696 .data = &sysctl_tcp_autocorking,
697 .maxlen = sizeof(int),
698 .mode = 0644,
699 .proc_handler = proc_dointvec_minmax,
700 .extra1 = &zero,
701 .extra2 = &one,
702 },
703 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500704 .procname = "tcp_invalid_ratelimit",
705 .data = &sysctl_tcp_invalid_ratelimit,
706 .maxlen = sizeof(int),
707 .mode = 0644,
708 .proc_handler = proc_dointvec_ms_jiffies,
709 },
710 {
Dave Watson734942c2017-06-14 11:37:14 -0700711 .procname = "tcp_available_ulp",
712 .maxlen = TCP_ULP_BUF_MAX,
713 .mode = 0444,
714 .proc_handler = proc_tcp_available_ulp,
715 },
716 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700717 .procname = "icmp_msgs_per_sec",
718 .data = &sysctl_icmp_msgs_per_sec,
719 .maxlen = sizeof(int),
720 .mode = 0644,
721 .proc_handler = proc_dointvec_minmax,
722 .extra1 = &zero,
723 },
724 {
725 .procname = "icmp_msgs_burst",
726 .data = &sysctl_icmp_msgs_burst,
727 .maxlen = sizeof(int),
728 .mode = 0644,
729 .proc_handler = proc_dointvec_minmax,
730 .extra1 = &zero,
731 },
732 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800733 .procname = "udp_mem",
734 .data = &sysctl_udp_mem,
735 .maxlen = sizeof(sysctl_udp_mem),
736 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000737 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800738 },
739 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800740 .procname = "udp_rmem_min",
741 .data = &sysctl_udp_rmem_min,
742 .maxlen = sizeof(sysctl_udp_rmem_min),
743 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800744 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700745 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800746 },
747 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800748 .procname = "udp_wmem_min",
749 .data = &sysctl_udp_wmem_min,
750 .maxlen = sizeof(sysctl_udp_wmem_min),
751 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800752 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700753 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800754 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800755 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800757
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700758static struct ctl_table ipv4_net_table[] = {
759 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700760 .procname = "icmp_echo_ignore_all",
761 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
762 .maxlen = sizeof(int),
763 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800764 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700765 },
766 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700767 .procname = "icmp_echo_ignore_broadcasts",
768 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
769 .maxlen = sizeof(int),
770 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800771 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700772 },
773 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700774 .procname = "icmp_ignore_bogus_error_responses",
775 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
776 .maxlen = sizeof(int),
777 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800778 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700779 },
780 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700781 .procname = "icmp_errors_use_inbound_ifaddr",
782 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
783 .maxlen = sizeof(int),
784 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800785 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700786 },
787 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700788 .procname = "icmp_ratelimit",
789 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
790 .maxlen = sizeof(int),
791 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800792 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700793 },
794 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700795 .procname = "icmp_ratemask",
796 .data = &init_net.ipv4.sysctl_icmp_ratemask,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800799 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700800 },
Neil Horman1080d702008-10-27 12:28:25 -0700801 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000802 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700803 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600804 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000805 .mode = 0644,
806 .proc_handler = ipv4_ping_group_range,
807 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000808 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000809 .procname = "tcp_ecn",
810 .data = &init_net.ipv4.sysctl_tcp_ecn,
811 .maxlen = sizeof(int),
812 .mode = 0644,
813 .proc_handler = proc_dointvec
814 },
815 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200816 .procname = "tcp_ecn_fallback",
817 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
818 .maxlen = sizeof(int),
819 .mode = 0644,
820 .proc_handler = proc_dointvec
821 },
822 {
Nikolay Borisov287b7f32016-02-15 12:11:29 +0200823 .procname = "ip_dynaddr",
824 .data = &init_net.ipv4.sysctl_ip_dynaddr,
825 .maxlen = sizeof(int),
826 .mode = 0644,
827 .proc_handler = proc_dointvec
828 },
829 {
Nikolay Borisove21145a2016-02-15 12:11:30 +0200830 .procname = "ip_early_demux",
831 .data = &init_net.ipv4.sysctl_ip_early_demux,
832 .maxlen = sizeof(int),
833 .mode = 0644,
834 .proc_handler = proc_dointvec
835 },
836 {
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600837 .procname = "udp_early_demux",
838 .data = &init_net.ipv4.sysctl_udp_early_demux,
839 .maxlen = sizeof(int),
840 .mode = 0644,
841 .proc_handler = proc_udp_early_demux
842 },
843 {
844 .procname = "tcp_early_demux",
845 .data = &init_net.ipv4.sysctl_tcp_early_demux,
846 .maxlen = sizeof(int),
847 .mode = 0644,
848 .proc_handler = proc_tcp_early_demux
849 },
850 {
Nikolay Borisovfa50d972016-02-15 12:11:27 +0200851 .procname = "ip_default_ttl",
852 .data = &init_net.ipv4.sysctl_ip_default_ttl,
853 .maxlen = sizeof(int),
854 .mode = 0644,
855 .proc_handler = proc_dointvec_minmax,
856 .extra1 = &ip_ttl_min,
857 .extra2 = &ip_ttl_max,
858 },
859 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700860 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700861 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
862 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700863 .mode = 0644,
864 .proc_handler = ipv4_local_port_range,
865 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100866 {
WANG Cong122ff242014-05-12 16:04:53 -0700867 .procname = "ip_local_reserved_ports",
868 .data = &init_net.ipv4.sysctl_local_reserved_ports,
869 .maxlen = 65536,
870 .mode = 0644,
871 .proc_handler = proc_do_large_bitmap,
872 },
873 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100874 .procname = "ip_no_pmtu_disc",
875 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
876 .maxlen = sizeof(int),
877 .mode = 0644,
878 .proc_handler = proc_dointvec
879 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100880 {
881 .procname = "ip_forward_use_pmtu",
882 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
883 .maxlen = sizeof(int),
884 .mode = 0644,
885 .proc_handler = proc_dointvec,
886 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700887 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200888 .procname = "ip_nonlocal_bind",
889 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
890 .maxlen = sizeof(int),
891 .mode = 0644,
892 .proc_handler = proc_dointvec
893 },
894 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700895 .procname = "fwmark_reflect",
896 .data = &init_net.ipv4.sysctl_fwmark_reflect,
897 .maxlen = sizeof(int),
898 .mode = 0644,
899 .proc_handler = proc_dointvec,
900 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700901 {
902 .procname = "tcp_fwmark_accept",
903 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
904 .maxlen = sizeof(int),
905 .mode = 0644,
906 .proc_handler = proc_dointvec,
907 },
David Ahern6dd9a142015-12-16 13:20:44 -0800908#ifdef CONFIG_NET_L3_MASTER_DEV
909 {
910 .procname = "tcp_l3mdev_accept",
911 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
912 .maxlen = sizeof(int),
913 .mode = 0644,
914 .proc_handler = proc_dointvec_minmax,
915 .extra1 = &zero,
916 .extra2 = &one,
917 },
918#endif
Fan Dub0f9ca52015-02-10 09:53:16 +0800919 {
920 .procname = "tcp_mtu_probing",
921 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
922 .maxlen = sizeof(int),
923 .mode = 0644,
924 .proc_handler = proc_dointvec,
925 },
926 {
927 .procname = "tcp_base_mss",
928 .data = &init_net.ipv4.sysctl_tcp_base_mss,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = proc_dointvec,
932 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800933 {
934 .procname = "tcp_probe_threshold",
935 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
936 .maxlen = sizeof(int),
937 .mode = 0644,
938 .proc_handler = proc_dointvec,
939 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800940 {
941 .procname = "tcp_probe_interval",
942 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
943 .maxlen = sizeof(int),
944 .mode = 0644,
945 .proc_handler = proc_dointvec,
946 },
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100947 {
948 .procname = "igmp_link_local_mcast_reports",
Nikolay Borisov87a8a2a2016-02-09 00:13:50 +0200949 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100950 .maxlen = sizeof(int),
951 .mode = 0644,
952 .proc_handler = proc_dointvec
953 },
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200954 {
Nikolay Borisov815c5272016-02-08 23:29:21 +0200955 .procname = "igmp_max_memberships",
956 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
957 .maxlen = sizeof(int),
958 .mode = 0644,
959 .proc_handler = proc_dointvec
960 },
961 {
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200962 .procname = "igmp_max_msf",
963 .data = &init_net.ipv4.sysctl_igmp_max_msf,
964 .maxlen = sizeof(int),
965 .mode = 0644,
966 .proc_handler = proc_dointvec
967 },
Nikolay Borisov165094a2016-02-08 23:29:24 +0200968#ifdef CONFIG_IP_MULTICAST
969 {
970 .procname = "igmp_qrv",
971 .data = &init_net.ipv4.sysctl_igmp_qrv,
972 .maxlen = sizeof(int),
973 .mode = 0644,
974 .proc_handler = proc_dointvec_minmax,
975 .extra1 = &one
976 },
977#endif
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200978 {
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200979 .procname = "tcp_keepalive_time",
980 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
981 .maxlen = sizeof(int),
982 .mode = 0644,
983 .proc_handler = proc_dointvec_jiffies,
984 },
Nikolay Borisov9bd68612016-01-07 16:38:44 +0200985 {
986 .procname = "tcp_keepalive_probes",
987 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
988 .maxlen = sizeof(int),
989 .mode = 0644,
990 .proc_handler = proc_dointvec
991 },
Nikolay Borisovb840d152016-01-07 16:38:45 +0200992 {
993 .procname = "tcp_keepalive_intvl",
994 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
995 .maxlen = sizeof(int),
996 .mode = 0644,
997 .proc_handler = proc_dointvec_jiffies,
998 },
Nikolay Borisov6fa25162016-02-03 09:46:49 +0200999 {
1000 .procname = "tcp_syn_retries",
1001 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
1002 .maxlen = sizeof(int),
1003 .mode = 0644,
1004 .proc_handler = proc_dointvec_minmax,
1005 .extra1 = &tcp_syn_retries_min,
1006 .extra2 = &tcp_syn_retries_max
1007 },
Nikolay Borisov7c083ec2016-02-03 09:46:50 +02001008 {
1009 .procname = "tcp_synack_retries",
1010 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
1011 .maxlen = sizeof(int),
1012 .mode = 0644,
1013 .proc_handler = proc_dointvec
1014 },
Nikolay Borisov12ed8242016-02-03 09:46:51 +02001015#ifdef CONFIG_SYN_COOKIES
1016 {
1017 .procname = "tcp_syncookies",
1018 .data = &init_net.ipv4.sysctl_tcp_syncookies,
1019 .maxlen = sizeof(int),
1020 .mode = 0644,
1021 .proc_handler = proc_dointvec
1022 },
1023#endif
Nikolay Borisov1043e252016-02-03 09:46:52 +02001024 {
1025 .procname = "tcp_reordering",
1026 .data = &init_net.ipv4.sysctl_tcp_reordering,
1027 .maxlen = sizeof(int),
1028 .mode = 0644,
1029 .proc_handler = proc_dointvec
1030 },
Nikolay Borisovae5c3f42016-02-03 09:46:53 +02001031 {
1032 .procname = "tcp_retries1",
1033 .data = &init_net.ipv4.sysctl_tcp_retries1,
1034 .maxlen = sizeof(int),
1035 .mode = 0644,
1036 .proc_handler = proc_dointvec_minmax,
1037 .extra2 = &tcp_retr1_max
1038 },
Nikolay Borisovc6214a92016-02-03 09:46:54 +02001039 {
1040 .procname = "tcp_retries2",
1041 .data = &init_net.ipv4.sysctl_tcp_retries2,
1042 .maxlen = sizeof(int),
1043 .mode = 0644,
1044 .proc_handler = proc_dointvec
1045 },
Nikolay Borisovc402d9b2016-02-03 09:46:55 +02001046 {
1047 .procname = "tcp_orphan_retries",
1048 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
1049 .maxlen = sizeof(int),
1050 .mode = 0644,
1051 .proc_handler = proc_dointvec
1052 },
Nikolay Borisov1e579ca2016-02-03 09:46:56 +02001053 {
1054 .procname = "tcp_fin_timeout",
1055 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
1058 .proc_handler = proc_dointvec_jiffies,
1059 },
Nikolay Borisov4979f2d2016-02-03 09:46:57 +02001060 {
1061 .procname = "tcp_notsent_lowat",
1062 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
1063 .maxlen = sizeof(unsigned int),
1064 .mode = 0644,
Pavel Tikhomirovb007f092017-01-09 10:45:49 +03001065 .proc_handler = proc_douintvec,
Nikolay Borisov4979f2d2016-02-03 09:46:57 +02001066 },
Haishuang Yan56ab6b92016-12-25 14:33:16 +08001067 {
1068 .procname = "tcp_tw_reuse",
1069 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
1070 .maxlen = sizeof(int),
1071 .mode = 0644,
1072 .proc_handler = proc_dointvec
1073 },
Haishuang Yan1946e672016-12-28 17:52:32 +08001074 {
1075 .procname = "tcp_max_tw_buckets",
1076 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
1077 .maxlen = sizeof(int),
1078 .mode = 0644,
1079 .proc_handler = proc_dointvec
1080 },
1081 {
Haishuang Yanfee83d02016-12-28 17:52:33 +08001082 .procname = "tcp_max_syn_backlog",
1083 .data = &init_net.ipv4.sysctl_max_syn_backlog,
1084 .maxlen = sizeof(int),
1085 .mode = 0644,
1086 .proc_handler = proc_dointvec
1087 },
David Aherna6db4492016-04-07 07:21:00 -07001088#ifdef CONFIG_IP_ROUTE_MULTIPATH
1089 {
1090 .procname = "fib_multipath_use_neigh",
1091 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
1094 .proc_handler = proc_dointvec_minmax,
1095 .extra1 = &zero,
1096 .extra2 = &one,
1097 },
Nikolay Aleksandrovbf4e0a32017-03-16 15:28:00 +02001098 {
1099 .procname = "fib_multipath_hash_policy",
1100 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
1103 .proc_handler = proc_dointvec_minmax,
1104 .extra1 = &zero,
1105 .extra2 = &one,
1106 },
David Aherna6db4492016-04-07 07:21:00 -07001107#endif
Krister Johansen4548b682017-01-20 17:49:11 -08001108 {
1109 .procname = "ip_unprivileged_port_start",
1110 .maxlen = sizeof(int),
1111 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1112 .mode = 0644,
1113 .proc_handler = ipv4_privileged_ports,
1114 },
Robert Shearman63a6fff2017-01-26 18:02:24 +00001115#ifdef CONFIG_NET_L3_MASTER_DEV
1116 {
1117 .procname = "udp_l3mdev_accept",
1118 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1119 .maxlen = sizeof(int),
1120 .mode = 0644,
1121 .proc_handler = proc_dointvec_minmax,
1122 .extra1 = &zero,
1123 .extra2 = &one,
1124 },
1125#endif
Eric Dumazetf9301032017-06-07 10:34:37 -07001126 {
1127 .procname = "tcp_sack",
1128 .data = &init_net.ipv4.sysctl_tcp_sack,
1129 .maxlen = sizeof(int),
1130 .mode = 0644,
1131 .proc_handler = proc_dointvec
1132 },
Eric Dumazet9bb37ef2017-06-07 10:34:38 -07001133 {
1134 .procname = "tcp_window_scaling",
1135 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1136 .maxlen = sizeof(int),
1137 .mode = 0644,
1138 .proc_handler = proc_dointvec
1139 },
Eric Dumazet5d2ed052017-06-07 10:34:39 -07001140 {
1141 .procname = "tcp_timestamps",
1142 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1143 .maxlen = sizeof(int),
1144 .mode = 0644,
1145 .proc_handler = proc_dointvec
1146 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001147 { }
1148};
1149
Pavel Emelyanov15775192008-03-26 01:54:18 -07001150static __net_init int ipv4_sysctl_init_net(struct net *net)
1151{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001152 struct ctl_table *table;
1153
1154 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001155 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001156 int i;
1157
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001158 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +01001159 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001160 goto err_alloc;
1161
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001162 /* Update the variables to point into the current struct net */
1163 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1164 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001165 }
1166
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001167 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +01001168 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001169 goto err_reg;
1170
WANG Cong122ff242014-05-12 16:04:53 -07001171 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1172 if (!net->ipv4.sysctl_local_reserved_ports)
1173 goto err_ports;
1174
Pavel Emelyanov15775192008-03-26 01:54:18 -07001175 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001176
WANG Cong122ff242014-05-12 16:04:53 -07001177err_ports:
1178 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001179err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001180 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001181 kfree(table);
1182err_alloc:
1183 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -07001184}
1185
1186static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1187{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001188 struct ctl_table *table;
1189
WANG Cong122ff242014-05-12 16:04:53 -07001190 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001191 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1192 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1193 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001194}
1195
1196static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1197 .init = ipv4_sysctl_init_net,
1198 .exit = ipv4_sysctl_exit_net,
1199};
1200
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001201static __init int sysctl_ipv4_init(void)
1202{
1203 struct ctl_table_header *hdr;
1204
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001205 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +01001206 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -07001207 return -ENOMEM;
1208
1209 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +00001210 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001211 return -ENOMEM;
1212 }
1213
1214 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001215}
1216
1217__initcall(sysctl_ipv4_init);