blob: 8dcc2b185fccb9a1b93a7e5587cc73b7798361f9 [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>
Ido Schimmel3ae6ec02017-11-02 17:14:05 +010028#include <net/netevent.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Herbert Xu89cee8b2005-12-13 23:14:27 -080030static int zero;
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +000031static int one = 1;
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +000032static int four = 4;
Eric Dumazet43e122b2015-08-21 17:38:02 -070033static int thousand = 1000;
Eric Dumazet95bd09e2013-08-27 05:46:32 -070034static int gso_max_segs = GSO_MAX_SEGS;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090035static int tcp_retr1_max = 255;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036static int ip_local_port_range_min[] = { 1, 1 };
37static int ip_local_port_range_max[] = { 65535, 65535 };
Alexey Dobriyan0147fc02010-11-22 12:54:21 +000038static int tcp_adv_win_scale_min = -31;
39static int tcp_adv_win_scale_max = 31;
Krister Johansen4548b682017-01-20 17:49:11 -080040static int ip_privileged_port_min;
41static int ip_privileged_port_max = 65535;
Eric Dumazet249fab72010-12-13 12:16:14 -080042static int ip_ttl_min = 1;
43static int ip_ttl_max = 255;
Michal Tesar651e9272013-07-19 14:09:01 +020044static int tcp_syn_retries_min = 1;
45static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000046static int ip_ping_group_range_min[] = { 0, 0 };
47static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Florian Westphalb6690b12017-07-30 03:57:20 +020049/* obsolete */
50static int sysctl_tcp_low_latency __read_mostly;
51
Stephen Hemminger227b60f2007-10-10 17:30:46 -070052/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070053static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070054{
Eric Dumazeted2dfd92015-05-27 11:34:37 -070055 bool same_parity = !((range[0] ^ range[1]) & 1);
56
WANG Cong4ee3bd42015-11-03 14:32:57 -080057 write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
Eric Dumazeted2dfd92015-05-27 11:34:37 -070058 if (same_parity && !net->ipv4.ip_local_ports.warned) {
59 net->ipv4.ip_local_ports.warned = true;
60 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
61 }
Cong Wangc9d8f1a2014-05-06 11:02:49 -070062 net->ipv4.ip_local_ports.range[0] = range[0];
63 net->ipv4.ip_local_ports.range[1] = range[1];
WANG Cong4ee3bd42015-11-03 14:32:57 -080064 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070065}
66
67/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070068static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070069 void __user *buffer,
70 size_t *lenp, loff_t *ppos)
71{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070072 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070073 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070074 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070075 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070076 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070077 .data = &range,
78 .maxlen = sizeof(range),
79 .mode = table->mode,
80 .extra1 = &ip_local_port_range_min,
81 .extra2 = &ip_local_port_range_max,
82 };
83
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070084 inet_get_local_port_range(net, &range[0], &range[1]);
85
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070086 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070087
88 if (write && ret == 0) {
Krister Johansen4548b682017-01-20 17:49:11 -080089 /* Ensure that the upper limit is not smaller than the lower,
90 * and that the lower does not encroach upon the privileged
91 * port limit.
92 */
93 if ((range[1] < range[0]) ||
94 (range[0] < net->ipv4.sysctl_ip_prot_sock))
Stephen Hemminger227b60f2007-10-10 17:30:46 -070095 ret = -EINVAL;
96 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070097 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070098 }
99
100 return ret;
101}
102
Krister Johansen4548b682017-01-20 17:49:11 -0800103/* Validate changes from /proc interface. */
104static int ipv4_privileged_ports(struct ctl_table *table, int write,
105 void __user *buffer, size_t *lenp, loff_t *ppos)
106{
107 struct net *net = container_of(table->data, struct net,
108 ipv4.sysctl_ip_prot_sock);
109 int ret;
110 int pports;
111 int range[2];
112 struct ctl_table tmp = {
113 .data = &pports,
114 .maxlen = sizeof(pports),
115 .mode = table->mode,
116 .extra1 = &ip_privileged_port_min,
117 .extra2 = &ip_privileged_port_max,
118 };
119
120 pports = net->ipv4.sysctl_ip_prot_sock;
121
122 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
123
124 if (write && ret == 0) {
125 inet_get_local_port_range(net, &range[0], &range[1]);
126 /* Ensure that the local port range doesn't overlap with the
127 * privileged port range.
128 */
129 if (range[0] < pports)
130 ret = -EINVAL;
131 else
132 net->ipv4.sysctl_ip_prot_sock = pports;
133 }
134
135 return ret;
136}
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000137
Eric W. Biederman7064d162012-05-24 10:34:21 -0600138static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000139{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600140 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700141 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700142 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +0000143 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000144 do {
WANG Cong396a30c2016-10-20 14:19:46 -0700145 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000146
147 *low = data[0];
148 *high = data[1];
WANG Cong396a30c2016-10-20 14:19:46 -0700149 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000150}
151
152/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600153static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000154{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600155 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700156 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700157 container_of(table->data, struct net, ipv4.ping_group_range.range);
WANG Cong396a30c2016-10-20 14:19:46 -0700158 write_seqlock(&net->ipv4.ping_group_range.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600159 data[0] = low;
160 data[1] = high;
WANG Cong396a30c2016-10-20 14:19:46 -0700161 write_sequnlock(&net->ipv4.ping_group_range.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000162}
163
164/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700165static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000166 void __user *buffer,
167 size_t *lenp, loff_t *ppos)
168{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600169 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000170 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600171 gid_t urange[2];
172 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700173 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600174 .data = &urange,
175 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000176 .mode = table->mode,
177 .extra1 = &ip_ping_group_range_min,
178 .extra2 = &ip_ping_group_range_max,
179 };
180
Eric W. Biederman7064d162012-05-24 10:34:21 -0600181 inet_get_ping_group_range_table(table, &low, &high);
182 urange[0] = from_kgid_munged(user_ns, low);
183 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000184 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
185
Eric W. Biederman7064d162012-05-24 10:34:21 -0600186 if (write && ret == 0) {
187 low = make_kgid(user_ns, urange[0]);
188 high = make_kgid(user_ns, urange[1]);
189 if (!gid_valid(low) || !gid_valid(high) ||
190 (urange[1] < urange[0]) || gid_lt(high, low)) {
191 low = make_kgid(&init_user_ns, 1);
192 high = make_kgid(&init_user_ns, 0);
193 }
194 set_ping_group_range(table, low, high);
195 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000196
197 return ret;
198}
199
Joe Perchesfe2c6332013-06-11 23:04:25 -0700200static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700201 void __user *buffer, size_t *lenp, loff_t *ppos)
202{
203 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700204 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700205 .data = val,
206 .maxlen = TCP_CA_NAME_MAX,
207 };
208 int ret;
209
210 tcp_get_default_congestion_control(val);
211
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700212 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700213 if (write && ret == 0)
214 ret = tcp_set_default_congestion_control(val);
215 return ret;
216}
217
Joe Perchesfe2c6332013-06-11 23:04:25 -0700218static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700219 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800220 void __user *buffer, size_t *lenp,
221 loff_t *ppos)
222{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700223 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800224 int ret;
225
226 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
227 if (!tbl.data)
228 return -ENOMEM;
229 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700230 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800231 kfree(tbl.data);
232 return ret;
233}
234
Joe Perchesfe2c6332013-06-11 23:04:25 -0700235static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700236 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800237 void __user *buffer, size_t *lenp,
238 loff_t *ppos)
239{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700240 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800241 int ret;
242
243 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
244 if (!tbl.data)
245 return -ENOMEM;
246
247 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700248 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800249 if (write && ret == 0)
250 ret = tcp_set_allowed_congestion_control(tbl.data);
251 kfree(tbl.data);
252 return ret;
253}
254
Haishuang Yan43713842017-09-27 11:35:42 +0800255static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
Joe Perchesfe2c6332013-06-11 23:04:25 -0700256 void __user *buffer, size_t *lenp,
257 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000258{
Haishuang Yan43713842017-09-27 11:35:42 +0800259 struct net *net = container_of(table->data, struct net,
260 ipv4.sysctl_tcp_fastopen);
Joe Perchesfe2c6332013-06-11 23:04:25 -0700261 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000262 struct tcp_fastopen_context *ctxt;
263 int ret;
264 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
265
266 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
267 if (!tbl.data)
268 return -ENOMEM;
269
270 rcu_read_lock();
Haishuang Yan43713842017-09-27 11:35:42 +0800271 ctxt = rcu_dereference(net->ipv4.tcp_fastopen_ctx);
Jerry Chu10467162012-08-31 12:29:11 +0000272 if (ctxt)
273 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000274 else
275 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000276 rcu_read_unlock();
277
278 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
279 user_key[0], user_key[1], user_key[2], user_key[3]);
280 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
281
282 if (write && ret == 0) {
283 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
284 user_key + 2, user_key + 3) != 4) {
285 ret = -EINVAL;
286 goto bad_key;
287 }
Yuchung Cheng1fba70e2017-10-18 11:22:51 -0700288 tcp_fastopen_reset_cipher(net, NULL, user_key,
289 TCP_FASTOPEN_KEY_LENGTH);
Jerry Chu10467162012-08-31 12:29:11 +0000290 }
291
292bad_key:
293 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
294 user_key[0], user_key[1], user_key[2], user_key[3],
295 (char *)tbl.data, ret);
296 kfree(tbl.data);
297 return ret;
298}
299
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600300static void proc_configure_early_demux(int enabled, int protocol)
301{
302 struct net_protocol *ipprot;
303#if IS_ENABLED(CONFIG_IPV6)
304 struct inet6_protocol *ip6prot;
305#endif
306
David Ahern58c4c6a2017-04-22 09:33:16 -0700307 rcu_read_lock();
308
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600309 ipprot = rcu_dereference(inet_protos[protocol]);
310 if (ipprot)
311 ipprot->early_demux = enabled ? ipprot->early_demux_handler :
312 NULL;
313
314#if IS_ENABLED(CONFIG_IPV6)
315 ip6prot = rcu_dereference(inet6_protos[protocol]);
316 if (ip6prot)
317 ip6prot->early_demux = enabled ? ip6prot->early_demux_handler :
318 NULL;
319#endif
David Ahern58c4c6a2017-04-22 09:33:16 -0700320 rcu_read_unlock();
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600321}
322
323static int proc_tcp_early_demux(struct ctl_table *table, int write,
324 void __user *buffer, size_t *lenp, loff_t *ppos)
325{
326 int ret = 0;
327
328 ret = proc_dointvec(table, write, buffer, lenp, ppos);
329
330 if (write && !ret) {
331 int enabled = init_net.ipv4.sysctl_tcp_early_demux;
332
333 proc_configure_early_demux(enabled, IPPROTO_TCP);
334 }
335
336 return ret;
337}
338
339static int proc_udp_early_demux(struct ctl_table *table, int write,
340 void __user *buffer, size_t *lenp, loff_t *ppos)
341{
342 int ret = 0;
343
344 ret = proc_dointvec(table, write, buffer, lenp, ppos);
345
346 if (write && !ret) {
347 int enabled = init_net.ipv4.sysctl_udp_early_demux;
348
349 proc_configure_early_demux(enabled, IPPROTO_UDP);
350 }
351
352 return ret;
353}
354
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700355static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
356 int write,
357 void __user *buffer,
358 size_t *lenp, loff_t *ppos)
359{
Haishuang Yan3733be12017-09-27 11:35:43 +0800360 struct net *net = container_of(table->data, struct net,
361 ipv4.sysctl_tcp_fastopen_blackhole_timeout);
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700362 int ret;
363
364 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
365 if (write && ret == 0)
Haishuang Yan3733be12017-09-27 11:35:43 +0800366 atomic_set(&net->ipv4.tfo_active_disable_times, 0);
Dave Watson734942c2017-06-14 11:37:14 -0700367
368 return ret;
369}
370
371static int proc_tcp_available_ulp(struct ctl_table *ctl,
372 int write,
373 void __user *buffer, size_t *lenp,
374 loff_t *ppos)
375{
376 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
377 int ret;
378
379 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
380 if (!tbl.data)
381 return -ENOMEM;
382 tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
383 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
384 kfree(tbl.data);
385
Wei Wangcf1ef3f2017-04-20 14:45:46 -0700386 return ret;
387}
388
Ido Schimmel3ae6ec02017-11-02 17:14:05 +0100389#ifdef CONFIG_IP_ROUTE_MULTIPATH
390static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
391 void __user *buffer, size_t *lenp,
392 loff_t *ppos)
393{
394 struct net *net = container_of(table->data, struct net,
395 ipv4.sysctl_fib_multipath_hash_policy);
396 int ret;
397
398 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
399 if (write && ret == 0)
400 call_netevent_notifiers(NETEVENT_MULTIPATH_HASH_UPDATE, net);
401
402 return ret;
403}
404#endif
405
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800406static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900407 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 .procname = "tcp_max_orphans",
409 .data = &sysctl_tcp_max_orphans,
410 .maxlen = sizeof(int),
411 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800412 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 },
414 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 .procname = "inet_peer_threshold",
416 .data = &inet_peer_threshold,
417 .maxlen = sizeof(int),
418 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800419 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 },
421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 .procname = "inet_peer_minttl",
423 .data = &inet_peer_minttl,
424 .maxlen = sizeof(int),
425 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800426 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 },
428 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 .procname = "inet_peer_maxttl",
430 .data = &inet_peer_maxttl,
431 .maxlen = sizeof(int),
432 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800433 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 },
435 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700436 .procname = "tcp_mem",
437 .maxlen = sizeof(sysctl_tcp_mem),
438 .data = &sysctl_tcp_mem,
439 .mode = 0644,
440 .proc_handler = proc_doulongvec_minmax,
441 },
442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 .procname = "tcp_wmem",
444 .data = &sysctl_tcp_wmem,
445 .maxlen = sizeof(sysctl_tcp_wmem),
446 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000447 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700448 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 },
450 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 .procname = "tcp_rmem",
452 .data = &sysctl_tcp_rmem,
453 .maxlen = sizeof(sysctl_tcp_rmem),
454 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000455 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700456 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 },
458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "tcp_low_latency",
460 .data = &sysctl_tcp_low_latency,
461 .maxlen = sizeof(int),
462 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800463 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
465 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700466 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700468 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800469 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
Paul Moore446fda42006-08-03 16:48:06 -0700471#ifdef CONFIG_NETLABEL
472 {
Paul Moore446fda42006-08-03 16:48:06 -0700473 .procname = "cipso_cache_enable",
474 .data = &cipso_v4_cache_enabled,
475 .maxlen = sizeof(int),
476 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800477 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700478 },
479 {
Paul Moore446fda42006-08-03 16:48:06 -0700480 .procname = "cipso_cache_bucket_size",
481 .data = &cipso_v4_cache_bucketsize,
482 .maxlen = sizeof(int),
483 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800484 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700485 },
486 {
Paul Moore446fda42006-08-03 16:48:06 -0700487 .procname = "cipso_rbm_optfmt",
488 .data = &cipso_v4_rbm_optfmt,
489 .maxlen = sizeof(int),
490 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800491 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700492 },
493 {
Paul Moore446fda42006-08-03 16:48:06 -0700494 .procname = "cipso_rbm_strictvalid",
495 .data = &cipso_v4_rbm_strictvalid,
496 .maxlen = sizeof(int),
497 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800498 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700499 },
500#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800501 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800502 .procname = "tcp_available_congestion_control",
503 .maxlen = TCP_CA_BUF_MAX,
504 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800505 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800506 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800507 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800508 .procname = "tcp_allowed_congestion_control",
509 .maxlen = TCP_CA_BUF_MAX,
510 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800511 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800512 },
John Heffner886236c2007-03-25 19:21:45 -0700513 {
Dave Watson734942c2017-06-14 11:37:14 -0700514 .procname = "tcp_available_ulp",
515 .maxlen = TCP_ULP_BUF_MAX,
516 .mode = 0444,
517 .proc_handler = proc_tcp_available_ulp,
518 },
519 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700520 .procname = "icmp_msgs_per_sec",
521 .data = &sysctl_icmp_msgs_per_sec,
522 .maxlen = sizeof(int),
523 .mode = 0644,
524 .proc_handler = proc_dointvec_minmax,
525 .extra1 = &zero,
526 },
527 {
528 .procname = "icmp_msgs_burst",
529 .data = &sysctl_icmp_msgs_burst,
530 .maxlen = sizeof(int),
531 .mode = 0644,
532 .proc_handler = proc_dointvec_minmax,
533 .extra1 = &zero,
534 },
535 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800536 .procname = "udp_mem",
537 .data = &sysctl_udp_mem,
538 .maxlen = sizeof(sysctl_udp_mem),
539 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000540 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800541 },
542 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800543 .procname = "udp_rmem_min",
544 .data = &sysctl_udp_rmem_min,
545 .maxlen = sizeof(sysctl_udp_rmem_min),
546 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800547 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700548 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800549 },
550 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800551 .procname = "udp_wmem_min",
552 .data = &sysctl_udp_wmem_min,
553 .maxlen = sizeof(sysctl_udp_wmem_min),
554 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800555 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700556 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800557 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800558 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800560
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700561static struct ctl_table ipv4_net_table[] = {
562 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700563 .procname = "icmp_echo_ignore_all",
564 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
565 .maxlen = sizeof(int),
566 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800567 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700568 },
569 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700570 .procname = "icmp_echo_ignore_broadcasts",
571 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
572 .maxlen = sizeof(int),
573 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800574 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700575 },
576 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700577 .procname = "icmp_ignore_bogus_error_responses",
578 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800581 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700582 },
583 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700584 .procname = "icmp_errors_use_inbound_ifaddr",
585 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
586 .maxlen = sizeof(int),
587 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800588 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700589 },
590 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700591 .procname = "icmp_ratelimit",
592 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
593 .maxlen = sizeof(int),
594 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800595 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700596 },
597 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700598 .procname = "icmp_ratemask",
599 .data = &init_net.ipv4.sysctl_icmp_ratemask,
600 .maxlen = sizeof(int),
601 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800602 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700603 },
Neil Horman1080d702008-10-27 12:28:25 -0700604 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000605 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700606 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600607 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000608 .mode = 0644,
609 .proc_handler = ipv4_ping_group_range,
610 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000611 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000612 .procname = "tcp_ecn",
613 .data = &init_net.ipv4.sysctl_tcp_ecn,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 .proc_handler = proc_dointvec
617 },
618 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200619 .procname = "tcp_ecn_fallback",
620 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
621 .maxlen = sizeof(int),
622 .mode = 0644,
623 .proc_handler = proc_dointvec
624 },
625 {
Nikolay Borisov287b7f32016-02-15 12:11:29 +0200626 .procname = "ip_dynaddr",
627 .data = &init_net.ipv4.sysctl_ip_dynaddr,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = proc_dointvec
631 },
632 {
Nikolay Borisove21145a2016-02-15 12:11:30 +0200633 .procname = "ip_early_demux",
634 .data = &init_net.ipv4.sysctl_ip_early_demux,
635 .maxlen = sizeof(int),
636 .mode = 0644,
637 .proc_handler = proc_dointvec
638 },
639 {
subashab@codeaurora.orgdddb64b2017-03-23 13:34:16 -0600640 .procname = "udp_early_demux",
641 .data = &init_net.ipv4.sysctl_udp_early_demux,
642 .maxlen = sizeof(int),
643 .mode = 0644,
644 .proc_handler = proc_udp_early_demux
645 },
646 {
647 .procname = "tcp_early_demux",
648 .data = &init_net.ipv4.sysctl_tcp_early_demux,
649 .maxlen = sizeof(int),
650 .mode = 0644,
651 .proc_handler = proc_tcp_early_demux
652 },
653 {
Nikolay Borisovfa50d972016-02-15 12:11:27 +0200654 .procname = "ip_default_ttl",
655 .data = &init_net.ipv4.sysctl_ip_default_ttl,
656 .maxlen = sizeof(int),
657 .mode = 0644,
658 .proc_handler = proc_dointvec_minmax,
659 .extra1 = &ip_ttl_min,
660 .extra2 = &ip_ttl_max,
661 },
662 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700663 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700664 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
665 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700666 .mode = 0644,
667 .proc_handler = ipv4_local_port_range,
668 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100669 {
WANG Cong122ff242014-05-12 16:04:53 -0700670 .procname = "ip_local_reserved_ports",
671 .data = &init_net.ipv4.sysctl_local_reserved_ports,
672 .maxlen = 65536,
673 .mode = 0644,
674 .proc_handler = proc_do_large_bitmap,
675 },
676 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100677 .procname = "ip_no_pmtu_disc",
678 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
679 .maxlen = sizeof(int),
680 .mode = 0644,
681 .proc_handler = proc_dointvec
682 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100683 {
684 .procname = "ip_forward_use_pmtu",
685 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
686 .maxlen = sizeof(int),
687 .mode = 0644,
688 .proc_handler = proc_dointvec,
689 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700690 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200691 .procname = "ip_nonlocal_bind",
692 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
693 .maxlen = sizeof(int),
694 .mode = 0644,
695 .proc_handler = proc_dointvec
696 },
697 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700698 .procname = "fwmark_reflect",
699 .data = &init_net.ipv4.sysctl_fwmark_reflect,
700 .maxlen = sizeof(int),
701 .mode = 0644,
702 .proc_handler = proc_dointvec,
703 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700704 {
705 .procname = "tcp_fwmark_accept",
706 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
707 .maxlen = sizeof(int),
708 .mode = 0644,
709 .proc_handler = proc_dointvec,
710 },
David Ahern6dd9a142015-12-16 13:20:44 -0800711#ifdef CONFIG_NET_L3_MASTER_DEV
712 {
713 .procname = "tcp_l3mdev_accept",
714 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
715 .maxlen = sizeof(int),
716 .mode = 0644,
717 .proc_handler = proc_dointvec_minmax,
718 .extra1 = &zero,
719 .extra2 = &one,
720 },
721#endif
Fan Dub0f9ca52015-02-10 09:53:16 +0800722 {
723 .procname = "tcp_mtu_probing",
724 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
725 .maxlen = sizeof(int),
726 .mode = 0644,
727 .proc_handler = proc_dointvec,
728 },
729 {
730 .procname = "tcp_base_mss",
731 .data = &init_net.ipv4.sysctl_tcp_base_mss,
732 .maxlen = sizeof(int),
733 .mode = 0644,
734 .proc_handler = proc_dointvec,
735 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800736 {
737 .procname = "tcp_probe_threshold",
738 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
739 .maxlen = sizeof(int),
740 .mode = 0644,
741 .proc_handler = proc_dointvec,
742 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800743 {
744 .procname = "tcp_probe_interval",
745 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
746 .maxlen = sizeof(int),
747 .mode = 0644,
748 .proc_handler = proc_dointvec,
749 },
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100750 {
751 .procname = "igmp_link_local_mcast_reports",
Nikolay Borisov87a8a2a2016-02-09 00:13:50 +0200752 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = proc_dointvec
756 },
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200757 {
Nikolay Borisov815c5272016-02-08 23:29:21 +0200758 .procname = "igmp_max_memberships",
759 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
760 .maxlen = sizeof(int),
761 .mode = 0644,
762 .proc_handler = proc_dointvec
763 },
764 {
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200765 .procname = "igmp_max_msf",
766 .data = &init_net.ipv4.sysctl_igmp_max_msf,
767 .maxlen = sizeof(int),
768 .mode = 0644,
769 .proc_handler = proc_dointvec
770 },
Nikolay Borisov165094a2016-02-08 23:29:24 +0200771#ifdef CONFIG_IP_MULTICAST
772 {
773 .procname = "igmp_qrv",
774 .data = &init_net.ipv4.sysctl_igmp_qrv,
775 .maxlen = sizeof(int),
776 .mode = 0644,
777 .proc_handler = proc_dointvec_minmax,
778 .extra1 = &one
779 },
780#endif
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200781 {
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200782 .procname = "tcp_keepalive_time",
783 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
784 .maxlen = sizeof(int),
785 .mode = 0644,
786 .proc_handler = proc_dointvec_jiffies,
787 },
Nikolay Borisov9bd68612016-01-07 16:38:44 +0200788 {
789 .procname = "tcp_keepalive_probes",
790 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
791 .maxlen = sizeof(int),
792 .mode = 0644,
793 .proc_handler = proc_dointvec
794 },
Nikolay Borisovb840d152016-01-07 16:38:45 +0200795 {
796 .procname = "tcp_keepalive_intvl",
797 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
798 .maxlen = sizeof(int),
799 .mode = 0644,
800 .proc_handler = proc_dointvec_jiffies,
801 },
Nikolay Borisov6fa25162016-02-03 09:46:49 +0200802 {
803 .procname = "tcp_syn_retries",
804 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
805 .maxlen = sizeof(int),
806 .mode = 0644,
807 .proc_handler = proc_dointvec_minmax,
808 .extra1 = &tcp_syn_retries_min,
809 .extra2 = &tcp_syn_retries_max
810 },
Nikolay Borisov7c083ec2016-02-03 09:46:50 +0200811 {
812 .procname = "tcp_synack_retries",
813 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
814 .maxlen = sizeof(int),
815 .mode = 0644,
816 .proc_handler = proc_dointvec
817 },
Nikolay Borisov12ed8242016-02-03 09:46:51 +0200818#ifdef CONFIG_SYN_COOKIES
819 {
820 .procname = "tcp_syncookies",
821 .data = &init_net.ipv4.sysctl_tcp_syncookies,
822 .maxlen = sizeof(int),
823 .mode = 0644,
824 .proc_handler = proc_dointvec
825 },
826#endif
Nikolay Borisov1043e252016-02-03 09:46:52 +0200827 {
828 .procname = "tcp_reordering",
829 .data = &init_net.ipv4.sysctl_tcp_reordering,
830 .maxlen = sizeof(int),
831 .mode = 0644,
832 .proc_handler = proc_dointvec
833 },
Nikolay Borisovae5c3f42016-02-03 09:46:53 +0200834 {
835 .procname = "tcp_retries1",
836 .data = &init_net.ipv4.sysctl_tcp_retries1,
837 .maxlen = sizeof(int),
838 .mode = 0644,
839 .proc_handler = proc_dointvec_minmax,
840 .extra2 = &tcp_retr1_max
841 },
Nikolay Borisovc6214a92016-02-03 09:46:54 +0200842 {
843 .procname = "tcp_retries2",
844 .data = &init_net.ipv4.sysctl_tcp_retries2,
845 .maxlen = sizeof(int),
846 .mode = 0644,
847 .proc_handler = proc_dointvec
848 },
Nikolay Borisovc402d9b2016-02-03 09:46:55 +0200849 {
850 .procname = "tcp_orphan_retries",
851 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
852 .maxlen = sizeof(int),
853 .mode = 0644,
854 .proc_handler = proc_dointvec
855 },
Nikolay Borisov1e579ca2016-02-03 09:46:56 +0200856 {
857 .procname = "tcp_fin_timeout",
858 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
859 .maxlen = sizeof(int),
860 .mode = 0644,
861 .proc_handler = proc_dointvec_jiffies,
862 },
Nikolay Borisov4979f2d2016-02-03 09:46:57 +0200863 {
864 .procname = "tcp_notsent_lowat",
865 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
866 .maxlen = sizeof(unsigned int),
867 .mode = 0644,
Pavel Tikhomirovb007f092017-01-09 10:45:49 +0300868 .proc_handler = proc_douintvec,
Nikolay Borisov4979f2d2016-02-03 09:46:57 +0200869 },
Haishuang Yan56ab6b92016-12-25 14:33:16 +0800870 {
871 .procname = "tcp_tw_reuse",
872 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
873 .maxlen = sizeof(int),
874 .mode = 0644,
875 .proc_handler = proc_dointvec
876 },
Haishuang Yan1946e672016-12-28 17:52:32 +0800877 {
878 .procname = "tcp_max_tw_buckets",
879 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
880 .maxlen = sizeof(int),
881 .mode = 0644,
882 .proc_handler = proc_dointvec
883 },
884 {
Haishuang Yanfee83d02016-12-28 17:52:33 +0800885 .procname = "tcp_max_syn_backlog",
886 .data = &init_net.ipv4.sysctl_max_syn_backlog,
887 .maxlen = sizeof(int),
888 .mode = 0644,
889 .proc_handler = proc_dointvec
890 },
Haishuang Yane1cfcbe2017-09-27 11:35:40 +0800891 {
892 .procname = "tcp_fastopen",
893 .data = &init_net.ipv4.sysctl_tcp_fastopen,
894 .maxlen = sizeof(int),
895 .mode = 0644,
896 .proc_handler = proc_dointvec,
897 },
Haishuang Yan43713842017-09-27 11:35:42 +0800898 {
899 .procname = "tcp_fastopen_key",
900 .mode = 0600,
901 .data = &init_net.ipv4.sysctl_tcp_fastopen,
902 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
903 .proc_handler = proc_tcp_fastopen_key,
904 },
Haishuang Yan3733be12017-09-27 11:35:43 +0800905 {
906 .procname = "tcp_fastopen_blackhole_timeout_sec",
907 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
908 .maxlen = sizeof(int),
909 .mode = 0644,
910 .proc_handler = proc_tfo_blackhole_detect_timeout,
911 .extra1 = &zero,
912 },
David Aherna6db4492016-04-07 07:21:00 -0700913#ifdef CONFIG_IP_ROUTE_MULTIPATH
914 {
915 .procname = "fib_multipath_use_neigh",
916 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = proc_dointvec_minmax,
920 .extra1 = &zero,
921 .extra2 = &one,
922 },
Nikolay Aleksandrovbf4e0a32017-03-16 15:28:00 +0200923 {
924 .procname = "fib_multipath_hash_policy",
925 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
926 .maxlen = sizeof(int),
927 .mode = 0644,
Ido Schimmel3ae6ec02017-11-02 17:14:05 +0100928 .proc_handler = proc_fib_multipath_hash_policy,
Nikolay Aleksandrovbf4e0a32017-03-16 15:28:00 +0200929 .extra1 = &zero,
930 .extra2 = &one,
931 },
David Aherna6db4492016-04-07 07:21:00 -0700932#endif
Krister Johansen4548b682017-01-20 17:49:11 -0800933 {
934 .procname = "ip_unprivileged_port_start",
935 .maxlen = sizeof(int),
936 .data = &init_net.ipv4.sysctl_ip_prot_sock,
937 .mode = 0644,
938 .proc_handler = ipv4_privileged_ports,
939 },
Robert Shearman63a6fff2017-01-26 18:02:24 +0000940#ifdef CONFIG_NET_L3_MASTER_DEV
941 {
942 .procname = "udp_l3mdev_accept",
943 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
944 .maxlen = sizeof(int),
945 .mode = 0644,
946 .proc_handler = proc_dointvec_minmax,
947 .extra1 = &zero,
948 .extra2 = &one,
949 },
950#endif
Eric Dumazetf9301032017-06-07 10:34:37 -0700951 {
952 .procname = "tcp_sack",
953 .data = &init_net.ipv4.sysctl_tcp_sack,
954 .maxlen = sizeof(int),
955 .mode = 0644,
956 .proc_handler = proc_dointvec
957 },
Eric Dumazet9bb37ef2017-06-07 10:34:38 -0700958 {
959 .procname = "tcp_window_scaling",
960 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
961 .maxlen = sizeof(int),
962 .mode = 0644,
963 .proc_handler = proc_dointvec
964 },
Eric Dumazet5d2ed052017-06-07 10:34:39 -0700965 {
966 .procname = "tcp_timestamps",
967 .data = &init_net.ipv4.sysctl_tcp_timestamps,
968 .maxlen = sizeof(int),
969 .mode = 0644,
970 .proc_handler = proc_dointvec
971 },
Eric Dumazet2ae21cf2017-10-26 21:54:56 -0700972 {
973 .procname = "tcp_early_retrans",
974 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
975 .maxlen = sizeof(int),
976 .mode = 0644,
977 .proc_handler = proc_dointvec_minmax,
978 .extra1 = &zero,
979 .extra2 = &four,
980 },
Eric Dumazete20223f2017-10-26 21:54:57 -0700981 {
982 .procname = "tcp_recovery",
983 .data = &init_net.ipv4.sysctl_tcp_recovery,
984 .maxlen = sizeof(int),
985 .mode = 0644,
986 .proc_handler = proc_dointvec,
987 },
Eric Dumazet2c04ac82017-10-26 21:54:58 -0700988 {
989 .procname = "tcp_thin_linear_timeouts",
990 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
991 .maxlen = sizeof(int),
992 .mode = 0644,
993 .proc_handler = proc_dointvec
994 },
Eric Dumazetb510f0d2017-10-26 21:54:59 -0700995 {
996 .procname = "tcp_slow_start_after_idle",
997 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
998 .maxlen = sizeof(int),
999 .mode = 0644,
1000 .proc_handler = proc_dointvec
1001 },
Eric Dumazete0a1e5b2017-10-26 21:55:00 -07001002 {
1003 .procname = "tcp_retrans_collapse",
1004 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1005 .maxlen = sizeof(int),
1006 .mode = 0644,
1007 .proc_handler = proc_dointvec
1008 },
Eric Dumazet3f4c7c62017-10-26 21:55:01 -07001009 {
1010 .procname = "tcp_stdurg",
1011 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1012 .maxlen = sizeof(int),
1013 .mode = 0644,
1014 .proc_handler = proc_dointvec
1015 },
Eric Dumazet625357a2017-10-26 21:55:02 -07001016 {
1017 .procname = "tcp_rfc1337",
1018 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1019 .maxlen = sizeof(int),
1020 .mode = 0644,
1021 .proc_handler = proc_dointvec
1022 },
Eric Dumazet65c94102017-10-26 21:55:03 -07001023 {
1024 .procname = "tcp_abort_on_overflow",
1025 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1026 .maxlen = sizeof(int),
1027 .mode = 0644,
1028 .proc_handler = proc_dointvec
1029 },
Eric Dumazet0bc65a22017-10-26 21:55:04 -07001030 {
1031 .procname = "tcp_fack",
1032 .data = &init_net.ipv4.sysctl_tcp_fack,
1033 .maxlen = sizeof(int),
1034 .mode = 0644,
1035 .proc_handler = proc_dointvec
1036 },
Eric Dumazetc6e21802017-10-26 21:55:06 -07001037 {
1038 .procname = "tcp_max_reordering",
1039 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
1042 .proc_handler = proc_dointvec
1043 },
Eric Dumazet6496f6b2017-10-26 21:55:07 -07001044 {
1045 .procname = "tcp_dsack",
1046 .data = &init_net.ipv4.sysctl_tcp_dsack,
1047 .maxlen = sizeof(int),
1048 .mode = 0644,
1049 .proc_handler = proc_dointvec
1050 },
Eric Dumazet0c126542017-10-26 21:55:08 -07001051 {
1052 .procname = "tcp_app_win",
1053 .data = &init_net.ipv4.sysctl_tcp_app_win,
1054 .maxlen = sizeof(int),
1055 .mode = 0644,
1056 .proc_handler = proc_dointvec
1057 },
Eric Dumazet94f08932017-10-26 21:55:09 -07001058 {
1059 .procname = "tcp_adv_win_scale",
1060 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1061 .maxlen = sizeof(int),
1062 .mode = 0644,
1063 .proc_handler = proc_dointvec_minmax,
1064 .extra1 = &tcp_adv_win_scale_min,
1065 .extra2 = &tcp_adv_win_scale_max,
1066 },
Eric Dumazetaf9b69a2017-10-26 21:55:10 -07001067 {
1068 .procname = "tcp_frto",
1069 .data = &init_net.ipv4.sysctl_tcp_frto,
1070 .maxlen = sizeof(int),
1071 .mode = 0644,
1072 .proc_handler = proc_dointvec
1073 },
Eric Dumazetec36e412017-10-27 07:47:21 -07001074 {
1075 .procname = "tcp_no_metrics_save",
1076 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1077 .maxlen = sizeof(int),
1078 .mode = 0644,
1079 .proc_handler = proc_dointvec,
1080 },
Eric Dumazet4540c0c2017-10-27 07:47:22 -07001081 {
1082 .procname = "tcp_moderate_rcvbuf",
1083 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1084 .maxlen = sizeof(int),
1085 .mode = 0644,
1086 .proc_handler = proc_dointvec,
1087 },
Eric Dumazetd06a9902017-10-27 07:47:23 -07001088 {
1089 .procname = "tcp_tso_win_divisor",
1090 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1091 .maxlen = sizeof(int),
1092 .mode = 0644,
1093 .proc_handler = proc_dointvec,
1094 },
Eric Dumazetceef9ab2017-10-27 07:47:24 -07001095 {
1096 .procname = "tcp_workaround_signed_windows",
1097 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
1100 .proc_handler = proc_dointvec
1101 },
Eric Dumazet9184d8b2017-10-27 07:47:25 -07001102 {
1103 .procname = "tcp_limit_output_bytes",
1104 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1105 .maxlen = sizeof(int),
1106 .mode = 0644,
1107 .proc_handler = proc_dointvec
1108 },
Eric Dumazetb530b682017-10-27 07:47:26 -07001109 {
1110 .procname = "tcp_challenge_ack_limit",
1111 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1112 .maxlen = sizeof(int),
1113 .mode = 0644,
1114 .proc_handler = proc_dointvec
1115 },
Eric Dumazet26e95962017-10-27 07:47:27 -07001116 {
1117 .procname = "tcp_min_tso_segs",
1118 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1119 .maxlen = sizeof(int),
1120 .mode = 0644,
1121 .proc_handler = proc_dointvec_minmax,
1122 .extra1 = &one,
1123 .extra2 = &gso_max_segs,
1124 },
Eric Dumazetbd239702017-10-27 07:47:28 -07001125 {
1126 .procname = "tcp_min_rtt_wlen",
1127 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1128 .maxlen = sizeof(int),
1129 .mode = 0644,
1130 .proc_handler = proc_dointvec
1131 },
Eric Dumazet790f00e2017-10-27 07:47:29 -07001132 {
1133 .procname = "tcp_autocorking",
1134 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1135 .maxlen = sizeof(int),
1136 .mode = 0644,
1137 .proc_handler = proc_dointvec_minmax,
1138 .extra1 = &zero,
1139 .extra2 = &one,
1140 },
Eric Dumazet4170ba62017-10-27 07:47:30 -07001141 {
1142 .procname = "tcp_invalid_ratelimit",
1143 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1144 .maxlen = sizeof(int),
1145 .mode = 0644,
1146 .proc_handler = proc_dointvec_ms_jiffies,
1147 },
Eric Dumazet23a7102a2017-10-27 07:47:31 -07001148 {
1149 .procname = "tcp_pacing_ss_ratio",
1150 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1151 .maxlen = sizeof(int),
1152 .mode = 0644,
1153 .proc_handler = proc_dointvec_minmax,
1154 .extra1 = &zero,
1155 .extra2 = &thousand,
1156 },
Eric Dumazetc26e91f2017-10-27 07:47:32 -07001157 {
1158 .procname = "tcp_pacing_ca_ratio",
1159 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1160 .maxlen = sizeof(int),
1161 .mode = 0644,
1162 .proc_handler = proc_dointvec_minmax,
1163 .extra1 = &zero,
1164 .extra2 = &thousand,
1165 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001166 { }
1167};
1168
Pavel Emelyanov15775192008-03-26 01:54:18 -07001169static __net_init int ipv4_sysctl_init_net(struct net *net)
1170{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001171 struct ctl_table *table;
1172
1173 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001174 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001175 int i;
1176
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001177 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +01001178 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001179 goto err_alloc;
1180
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001181 /* Update the variables to point into the current struct net */
1182 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1183 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001184 }
1185
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001186 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +01001187 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001188 goto err_reg;
1189
WANG Cong122ff242014-05-12 16:04:53 -07001190 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1191 if (!net->ipv4.sysctl_local_reserved_ports)
1192 goto err_ports;
1193
Pavel Emelyanov15775192008-03-26 01:54:18 -07001194 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001195
WANG Cong122ff242014-05-12 16:04:53 -07001196err_ports:
1197 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001198err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001199 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001200 kfree(table);
1201err_alloc:
1202 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -07001203}
1204
1205static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1206{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001207 struct ctl_table *table;
1208
WANG Cong122ff242014-05-12 16:04:53 -07001209 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001210 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1211 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1212 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001213}
1214
1215static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1216 .init = ipv4_sysctl_init_net,
1217 .exit = ipv4_sysctl_exit_net,
1218};
1219
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001220static __init int sysctl_ipv4_init(void)
1221{
1222 struct ctl_table_header *hdr;
1223
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001224 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +01001225 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -07001226 return -ENOMEM;
1227
1228 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +00001229 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001230 return -ENOMEM;
1231 }
1232
1233 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001234}
1235
1236__initcall(sysctl_ipv4_init);