xref: /linux/net/ipv4/sysctl_net_ipv4.c (revision 84b9b44b)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4  *
5  * Begun April 1, 1996, Mike Shaver.
6  * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
7  */
8 
9 #include <linux/sysctl.h>
10 #include <linux/seqlock.h>
11 #include <linux/init.h>
12 #include <linux/slab.h>
13 #include <net/icmp.h>
14 #include <net/ip.h>
15 #include <net/ip_fib.h>
16 #include <net/tcp.h>
17 #include <net/udp.h>
18 #include <net/cipso_ipv4.h>
19 #include <net/ping.h>
20 #include <net/protocol.h>
21 #include <net/netevent.h>
22 
23 static int tcp_retr1_max = 255;
24 static int ip_local_port_range_min[] = { 1, 1 };
25 static int ip_local_port_range_max[] = { 65535, 65535 };
26 static int tcp_adv_win_scale_min = -31;
27 static int tcp_adv_win_scale_max = 31;
28 static int tcp_app_win_max = 31;
29 static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
30 static int tcp_min_snd_mss_max = 65535;
31 static int ip_privileged_port_min;
32 static int ip_privileged_port_max = 65535;
33 static int ip_ttl_min = 1;
34 static int ip_ttl_max = 255;
35 static int tcp_syn_retries_min = 1;
36 static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
37 static int ip_ping_group_range_min[] = { 0, 0 };
38 static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
39 static u32 u32_max_div_HZ = UINT_MAX / HZ;
40 static int one_day_secs = 24 * 3600;
41 static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
42 	FIB_MULTIPATH_HASH_FIELD_ALL_MASK;
43 static unsigned int tcp_child_ehash_entries_max = 16 * 1024 * 1024;
44 static unsigned int udp_child_hash_entries_max = UDP_HTABLE_SIZE_MAX;
45 static int tcp_plb_max_rounds = 31;
46 static int tcp_plb_max_cong_thresh = 256;
47 
48 /* obsolete */
49 static int sysctl_tcp_low_latency __read_mostly;
50 
51 /* Update system visible IP port range */
52 static void set_local_port_range(struct net *net, int range[2])
53 {
54 	bool same_parity = !((range[0] ^ range[1]) & 1);
55 
56 	write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
57 	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 	}
61 	net->ipv4.ip_local_ports.range[0] = range[0];
62 	net->ipv4.ip_local_ports.range[1] = range[1];
63 	write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
64 }
65 
66 /* Validate changes from /proc interface. */
67 static int ipv4_local_port_range(struct ctl_table *table, int write,
68 				 void *buffer, size_t *lenp, loff_t *ppos)
69 {
70 	struct net *net =
71 		container_of(table->data, struct net, ipv4.ip_local_ports.range);
72 	int ret;
73 	int range[2];
74 	struct ctl_table tmp = {
75 		.data = &range,
76 		.maxlen = sizeof(range),
77 		.mode = table->mode,
78 		.extra1 = &ip_local_port_range_min,
79 		.extra2 = &ip_local_port_range_max,
80 	};
81 
82 	inet_get_local_port_range(net, &range[0], &range[1]);
83 
84 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
85 
86 	if (write && ret == 0) {
87 		/* Ensure that the upper limit is not smaller than the lower,
88 		 * and that the lower does not encroach upon the privileged
89 		 * port limit.
90 		 */
91 		if ((range[1] < range[0]) ||
92 		    (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock)))
93 			ret = -EINVAL;
94 		else
95 			set_local_port_range(net, range);
96 	}
97 
98 	return ret;
99 }
100 
101 /* Validate changes from /proc interface. */
102 static int ipv4_privileged_ports(struct ctl_table *table, int write,
103 				void *buffer, size_t *lenp, loff_t *ppos)
104 {
105 	struct net *net = container_of(table->data, struct net,
106 	    ipv4.sysctl_ip_prot_sock);
107 	int ret;
108 	int pports;
109 	int range[2];
110 	struct ctl_table tmp = {
111 		.data = &pports,
112 		.maxlen = sizeof(pports),
113 		.mode = table->mode,
114 		.extra1 = &ip_privileged_port_min,
115 		.extra2 = &ip_privileged_port_max,
116 	};
117 
118 	pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock);
119 
120 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
121 
122 	if (write && ret == 0) {
123 		inet_get_local_port_range(net, &range[0], &range[1]);
124 		/* Ensure that the local port range doesn't overlap with the
125 		 * privileged port range.
126 		 */
127 		if (range[0] < pports)
128 			ret = -EINVAL;
129 		else
130 			WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports);
131 	}
132 
133 	return ret;
134 }
135 
136 static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
137 {
138 	kgid_t *data = table->data;
139 	struct net *net =
140 		container_of(table->data, struct net, ipv4.ping_group_range.range);
141 	unsigned int seq;
142 	do {
143 		seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
144 
145 		*low = data[0];
146 		*high = data[1];
147 	} while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
148 }
149 
150 /* Update system visible IP port range */
151 static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
152 {
153 	kgid_t *data = table->data;
154 	struct net *net =
155 		container_of(table->data, struct net, ipv4.ping_group_range.range);
156 	write_seqlock(&net->ipv4.ping_group_range.lock);
157 	data[0] = low;
158 	data[1] = high;
159 	write_sequnlock(&net->ipv4.ping_group_range.lock);
160 }
161 
162 /* Validate changes from /proc interface. */
163 static int ipv4_ping_group_range(struct ctl_table *table, int write,
164 				 void *buffer, size_t *lenp, loff_t *ppos)
165 {
166 	struct user_namespace *user_ns = current_user_ns();
167 	int ret;
168 	gid_t urange[2];
169 	kgid_t low, high;
170 	struct ctl_table tmp = {
171 		.data = &urange,
172 		.maxlen = sizeof(urange),
173 		.mode = table->mode,
174 		.extra1 = &ip_ping_group_range_min,
175 		.extra2 = &ip_ping_group_range_max,
176 	};
177 
178 	inet_get_ping_group_range_table(table, &low, &high);
179 	urange[0] = from_kgid_munged(user_ns, low);
180 	urange[1] = from_kgid_munged(user_ns, high);
181 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
182 
183 	if (write && ret == 0) {
184 		low = make_kgid(user_ns, urange[0]);
185 		high = make_kgid(user_ns, urange[1]);
186 		if (!gid_valid(low) || !gid_valid(high))
187 			return -EINVAL;
188 		if (urange[1] < urange[0] || gid_lt(high, low)) {
189 			low = make_kgid(&init_user_ns, 1);
190 			high = make_kgid(&init_user_ns, 0);
191 		}
192 		set_ping_group_range(table, low, high);
193 	}
194 
195 	return ret;
196 }
197 
198 static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
199 				    void *buffer, size_t *lenp, loff_t *ppos)
200 {
201 	struct net *net;
202 	int ret;
203 
204 	net = container_of(table->data, struct net,
205 			   ipv4.sysctl_ip_fwd_update_priority);
206 	ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
207 	if (write && ret == 0)
208 		call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
209 					net);
210 
211 	return ret;
212 }
213 
214 static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
215 				       void *buffer, size_t *lenp, loff_t *ppos)
216 {
217 	struct net *net = container_of(ctl->data, struct net,
218 				       ipv4.tcp_congestion_control);
219 	char val[TCP_CA_NAME_MAX];
220 	struct ctl_table tbl = {
221 		.data = val,
222 		.maxlen = TCP_CA_NAME_MAX,
223 	};
224 	int ret;
225 
226 	tcp_get_default_congestion_control(net, val);
227 
228 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
229 	if (write && ret == 0)
230 		ret = tcp_set_default_congestion_control(net, val);
231 	return ret;
232 }
233 
234 static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
235 						 int write, void *buffer,
236 						 size_t *lenp, loff_t *ppos)
237 {
238 	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
239 	int ret;
240 
241 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
242 	if (!tbl.data)
243 		return -ENOMEM;
244 	tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
245 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
246 	kfree(tbl.data);
247 	return ret;
248 }
249 
250 static int proc_allowed_congestion_control(struct ctl_table *ctl,
251 					   int write, void *buffer,
252 					   size_t *lenp, loff_t *ppos)
253 {
254 	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
255 	int ret;
256 
257 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
258 	if (!tbl.data)
259 		return -ENOMEM;
260 
261 	tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
262 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
263 	if (write && ret == 0)
264 		ret = tcp_set_allowed_congestion_control(tbl.data);
265 	kfree(tbl.data);
266 	return ret;
267 }
268 
269 static int sscanf_key(char *buf, __le32 *key)
270 {
271 	u32 user_key[4];
272 	int i, ret = 0;
273 
274 	if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
275 		   user_key + 2, user_key + 3) != 4) {
276 		ret = -EINVAL;
277 	} else {
278 		for (i = 0; i < ARRAY_SIZE(user_key); i++)
279 			key[i] = cpu_to_le32(user_key[i]);
280 	}
281 	pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
282 		 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
283 
284 	return ret;
285 }
286 
287 static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
288 				 void *buffer, size_t *lenp, loff_t *ppos)
289 {
290 	struct net *net = container_of(table->data, struct net,
291 	    ipv4.sysctl_tcp_fastopen);
292 	/* maxlen to print the list of keys in hex (*2), with dashes
293 	 * separating doublewords and a comma in between keys.
294 	 */
295 	struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
296 					    2 * TCP_FASTOPEN_KEY_MAX) +
297 					    (TCP_FASTOPEN_KEY_MAX * 5)) };
298 	u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
299 	__le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
300 	char *backup_data;
301 	int ret, i = 0, off = 0, n_keys;
302 
303 	tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
304 	if (!tbl.data)
305 		return -ENOMEM;
306 
307 	n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
308 	if (!n_keys) {
309 		memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
310 		n_keys = 1;
311 	}
312 
313 	for (i = 0; i < n_keys * 4; i++)
314 		user_key[i] = le32_to_cpu(key[i]);
315 
316 	for (i = 0; i < n_keys; i++) {
317 		off += snprintf(tbl.data + off, tbl.maxlen - off,
318 				"%08x-%08x-%08x-%08x",
319 				user_key[i * 4],
320 				user_key[i * 4 + 1],
321 				user_key[i * 4 + 2],
322 				user_key[i * 4 + 3]);
323 
324 		if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
325 			break;
326 
327 		if (i + 1 < n_keys)
328 			off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
329 	}
330 
331 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
332 
333 	if (write && ret == 0) {
334 		backup_data = strchr(tbl.data, ',');
335 		if (backup_data) {
336 			*backup_data = '\0';
337 			backup_data++;
338 		}
339 		if (sscanf_key(tbl.data, key)) {
340 			ret = -EINVAL;
341 			goto bad_key;
342 		}
343 		if (backup_data) {
344 			if (sscanf_key(backup_data, key + 4)) {
345 				ret = -EINVAL;
346 				goto bad_key;
347 			}
348 		}
349 		tcp_fastopen_reset_cipher(net, NULL, key,
350 					  backup_data ? key + 4 : NULL);
351 	}
352 
353 bad_key:
354 	kfree(tbl.data);
355 	return ret;
356 }
357 
358 static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
359 					     int write, void *buffer,
360 					     size_t *lenp, loff_t *ppos)
361 {
362 	struct net *net = container_of(table->data, struct net,
363 	    ipv4.sysctl_tcp_fastopen_blackhole_timeout);
364 	int ret;
365 
366 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
367 	if (write && ret == 0)
368 		atomic_set(&net->ipv4.tfo_active_disable_times, 0);
369 
370 	return ret;
371 }
372 
373 static int proc_tcp_available_ulp(struct ctl_table *ctl,
374 				  int write, void *buffer, size_t *lenp,
375 				  loff_t *ppos)
376 {
377 	struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
378 	int ret;
379 
380 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
381 	if (!tbl.data)
382 		return -ENOMEM;
383 	tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
384 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
385 	kfree(tbl.data);
386 
387 	return ret;
388 }
389 
390 static int proc_tcp_ehash_entries(struct ctl_table *table, int write,
391 				  void *buffer, size_t *lenp, loff_t *ppos)
392 {
393 	struct net *net = container_of(table->data, struct net,
394 				       ipv4.sysctl_tcp_child_ehash_entries);
395 	struct inet_hashinfo *hinfo = net->ipv4.tcp_death_row.hashinfo;
396 	int tcp_ehash_entries;
397 	struct ctl_table tbl;
398 
399 	tcp_ehash_entries = hinfo->ehash_mask + 1;
400 
401 	/* A negative number indicates that the child netns
402 	 * shares the global ehash.
403 	 */
404 	if (!net_eq(net, &init_net) && !hinfo->pernet)
405 		tcp_ehash_entries *= -1;
406 
407 	memset(&tbl, 0, sizeof(tbl));
408 	tbl.data = &tcp_ehash_entries;
409 	tbl.maxlen = sizeof(int);
410 
411 	return proc_dointvec(&tbl, write, buffer, lenp, ppos);
412 }
413 
414 static int proc_udp_hash_entries(struct ctl_table *table, int write,
415 				 void *buffer, size_t *lenp, loff_t *ppos)
416 {
417 	struct net *net = container_of(table->data, struct net,
418 				       ipv4.sysctl_udp_child_hash_entries);
419 	int udp_hash_entries;
420 	struct ctl_table tbl;
421 
422 	udp_hash_entries = net->ipv4.udp_table->mask + 1;
423 
424 	/* A negative number indicates that the child netns
425 	 * shares the global udp_table.
426 	 */
427 	if (!net_eq(net, &init_net) && net->ipv4.udp_table == &udp_table)
428 		udp_hash_entries *= -1;
429 
430 	memset(&tbl, 0, sizeof(tbl));
431 	tbl.data = &udp_hash_entries;
432 	tbl.maxlen = sizeof(int);
433 
434 	return proc_dointvec(&tbl, write, buffer, lenp, ppos);
435 }
436 
437 #ifdef CONFIG_IP_ROUTE_MULTIPATH
438 static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
439 					  void *buffer, size_t *lenp,
440 					  loff_t *ppos)
441 {
442 	struct net *net = container_of(table->data, struct net,
443 	    ipv4.sysctl_fib_multipath_hash_policy);
444 	int ret;
445 
446 	ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
447 	if (write && ret == 0)
448 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
449 
450 	return ret;
451 }
452 
453 static int proc_fib_multipath_hash_fields(struct ctl_table *table, int write,
454 					  void *buffer, size_t *lenp,
455 					  loff_t *ppos)
456 {
457 	struct net *net;
458 	int ret;
459 
460 	net = container_of(table->data, struct net,
461 			   ipv4.sysctl_fib_multipath_hash_fields);
462 	ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
463 	if (write && ret == 0)
464 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
465 
466 	return ret;
467 }
468 #endif
469 
470 static struct ctl_table ipv4_table[] = {
471 	{
472 		.procname	= "tcp_max_orphans",
473 		.data		= &sysctl_tcp_max_orphans,
474 		.maxlen		= sizeof(int),
475 		.mode		= 0644,
476 		.proc_handler	= proc_dointvec
477 	},
478 	{
479 		.procname	= "inet_peer_threshold",
480 		.data		= &inet_peer_threshold,
481 		.maxlen		= sizeof(int),
482 		.mode		= 0644,
483 		.proc_handler	= proc_dointvec
484 	},
485 	{
486 		.procname	= "inet_peer_minttl",
487 		.data		= &inet_peer_minttl,
488 		.maxlen		= sizeof(int),
489 		.mode		= 0644,
490 		.proc_handler	= proc_dointvec_jiffies,
491 	},
492 	{
493 		.procname	= "inet_peer_maxttl",
494 		.data		= &inet_peer_maxttl,
495 		.maxlen		= sizeof(int),
496 		.mode		= 0644,
497 		.proc_handler	= proc_dointvec_jiffies,
498 	},
499 	{
500 		.procname	= "tcp_mem",
501 		.maxlen		= sizeof(sysctl_tcp_mem),
502 		.data		= &sysctl_tcp_mem,
503 		.mode		= 0644,
504 		.proc_handler	= proc_doulongvec_minmax,
505 	},
506 	{
507 		.procname	= "tcp_low_latency",
508 		.data		= &sysctl_tcp_low_latency,
509 		.maxlen		= sizeof(int),
510 		.mode		= 0644,
511 		.proc_handler	= proc_dointvec
512 	},
513 #ifdef CONFIG_NETLABEL
514 	{
515 		.procname	= "cipso_cache_enable",
516 		.data		= &cipso_v4_cache_enabled,
517 		.maxlen		= sizeof(int),
518 		.mode		= 0644,
519 		.proc_handler	= proc_dointvec,
520 	},
521 	{
522 		.procname	= "cipso_cache_bucket_size",
523 		.data		= &cipso_v4_cache_bucketsize,
524 		.maxlen		= sizeof(int),
525 		.mode		= 0644,
526 		.proc_handler	= proc_dointvec,
527 	},
528 	{
529 		.procname	= "cipso_rbm_optfmt",
530 		.data		= &cipso_v4_rbm_optfmt,
531 		.maxlen		= sizeof(int),
532 		.mode		= 0644,
533 		.proc_handler	= proc_dointvec,
534 	},
535 	{
536 		.procname	= "cipso_rbm_strictvalid",
537 		.data		= &cipso_v4_rbm_strictvalid,
538 		.maxlen		= sizeof(int),
539 		.mode		= 0644,
540 		.proc_handler	= proc_dointvec,
541 	},
542 #endif /* CONFIG_NETLABEL */
543 	{
544 		.procname	= "tcp_available_ulp",
545 		.maxlen		= TCP_ULP_BUF_MAX,
546 		.mode		= 0444,
547 		.proc_handler   = proc_tcp_available_ulp,
548 	},
549 	{
550 		.procname	= "icmp_msgs_per_sec",
551 		.data		= &sysctl_icmp_msgs_per_sec,
552 		.maxlen		= sizeof(int),
553 		.mode		= 0644,
554 		.proc_handler	= proc_dointvec_minmax,
555 		.extra1		= SYSCTL_ZERO,
556 	},
557 	{
558 		.procname	= "icmp_msgs_burst",
559 		.data		= &sysctl_icmp_msgs_burst,
560 		.maxlen		= sizeof(int),
561 		.mode		= 0644,
562 		.proc_handler	= proc_dointvec_minmax,
563 		.extra1		= SYSCTL_ZERO,
564 	},
565 	{
566 		.procname	= "udp_mem",
567 		.data		= &sysctl_udp_mem,
568 		.maxlen		= sizeof(sysctl_udp_mem),
569 		.mode		= 0644,
570 		.proc_handler	= proc_doulongvec_minmax,
571 	},
572 	{
573 		.procname	= "fib_sync_mem",
574 		.data		= &sysctl_fib_sync_mem,
575 		.maxlen		= sizeof(sysctl_fib_sync_mem),
576 		.mode		= 0644,
577 		.proc_handler	= proc_douintvec_minmax,
578 		.extra1		= &sysctl_fib_sync_mem_min,
579 		.extra2		= &sysctl_fib_sync_mem_max,
580 	},
581 	{ }
582 };
583 
584 static struct ctl_table ipv4_net_table[] = {
585 	{
586 		.procname	= "tcp_max_tw_buckets",
587 		.data		= &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
588 		.maxlen		= sizeof(int),
589 		.mode		= 0644,
590 		.proc_handler	= proc_dointvec
591 	},
592 	{
593 		.procname	= "icmp_echo_ignore_all",
594 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_all,
595 		.maxlen		= sizeof(u8),
596 		.mode		= 0644,
597 		.proc_handler	= proc_dou8vec_minmax,
598 		.extra1		= SYSCTL_ZERO,
599 		.extra2		= SYSCTL_ONE
600 	},
601 	{
602 		.procname	= "icmp_echo_enable_probe",
603 		.data		= &init_net.ipv4.sysctl_icmp_echo_enable_probe,
604 		.maxlen		= sizeof(u8),
605 		.mode		= 0644,
606 		.proc_handler	= proc_dou8vec_minmax,
607 		.extra1		= SYSCTL_ZERO,
608 		.extra2		= SYSCTL_ONE
609 	},
610 	{
611 		.procname	= "icmp_echo_ignore_broadcasts",
612 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
613 		.maxlen		= sizeof(u8),
614 		.mode		= 0644,
615 		.proc_handler	= proc_dou8vec_minmax,
616 		.extra1		= SYSCTL_ZERO,
617 		.extra2		= SYSCTL_ONE
618 	},
619 	{
620 		.procname	= "icmp_ignore_bogus_error_responses",
621 		.data		= &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
622 		.maxlen		= sizeof(u8),
623 		.mode		= 0644,
624 		.proc_handler	= proc_dou8vec_minmax,
625 		.extra1		= SYSCTL_ZERO,
626 		.extra2		= SYSCTL_ONE
627 	},
628 	{
629 		.procname	= "icmp_errors_use_inbound_ifaddr",
630 		.data		= &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
631 		.maxlen		= sizeof(u8),
632 		.mode		= 0644,
633 		.proc_handler	= proc_dou8vec_minmax,
634 		.extra1		= SYSCTL_ZERO,
635 		.extra2		= SYSCTL_ONE
636 	},
637 	{
638 		.procname	= "icmp_ratelimit",
639 		.data		= &init_net.ipv4.sysctl_icmp_ratelimit,
640 		.maxlen		= sizeof(int),
641 		.mode		= 0644,
642 		.proc_handler	= proc_dointvec_ms_jiffies,
643 	},
644 	{
645 		.procname	= "icmp_ratemask",
646 		.data		= &init_net.ipv4.sysctl_icmp_ratemask,
647 		.maxlen		= sizeof(int),
648 		.mode		= 0644,
649 		.proc_handler	= proc_dointvec
650 	},
651 	{
652 		.procname	= "ping_group_range",
653 		.data		= &init_net.ipv4.ping_group_range.range,
654 		.maxlen		= sizeof(gid_t)*2,
655 		.mode		= 0644,
656 		.proc_handler	= ipv4_ping_group_range,
657 	},
658 #ifdef CONFIG_NET_L3_MASTER_DEV
659 	{
660 		.procname	= "raw_l3mdev_accept",
661 		.data		= &init_net.ipv4.sysctl_raw_l3mdev_accept,
662 		.maxlen		= sizeof(u8),
663 		.mode		= 0644,
664 		.proc_handler	= proc_dou8vec_minmax,
665 		.extra1		= SYSCTL_ZERO,
666 		.extra2		= SYSCTL_ONE,
667 	},
668 #endif
669 	{
670 		.procname	= "tcp_ecn",
671 		.data		= &init_net.ipv4.sysctl_tcp_ecn,
672 		.maxlen		= sizeof(u8),
673 		.mode		= 0644,
674 		.proc_handler	= proc_dou8vec_minmax,
675 		.extra1		= SYSCTL_ZERO,
676 		.extra2		= SYSCTL_TWO,
677 	},
678 	{
679 		.procname	= "tcp_ecn_fallback",
680 		.data		= &init_net.ipv4.sysctl_tcp_ecn_fallback,
681 		.maxlen		= sizeof(u8),
682 		.mode		= 0644,
683 		.proc_handler	= proc_dou8vec_minmax,
684 		.extra1		= SYSCTL_ZERO,
685 		.extra2		= SYSCTL_ONE,
686 	},
687 	{
688 		.procname	= "ip_dynaddr",
689 		.data		= &init_net.ipv4.sysctl_ip_dynaddr,
690 		.maxlen		= sizeof(u8),
691 		.mode		= 0644,
692 		.proc_handler	= proc_dou8vec_minmax,
693 	},
694 	{
695 		.procname	= "ip_early_demux",
696 		.data		= &init_net.ipv4.sysctl_ip_early_demux,
697 		.maxlen		= sizeof(u8),
698 		.mode		= 0644,
699 		.proc_handler	= proc_dou8vec_minmax,
700 	},
701 	{
702 		.procname       = "udp_early_demux",
703 		.data           = &init_net.ipv4.sysctl_udp_early_demux,
704 		.maxlen         = sizeof(u8),
705 		.mode           = 0644,
706 		.proc_handler   = proc_dou8vec_minmax,
707 	},
708 	{
709 		.procname       = "tcp_early_demux",
710 		.data           = &init_net.ipv4.sysctl_tcp_early_demux,
711 		.maxlen         = sizeof(u8),
712 		.mode           = 0644,
713 		.proc_handler   = proc_dou8vec_minmax,
714 	},
715 	{
716 		.procname       = "nexthop_compat_mode",
717 		.data           = &init_net.ipv4.sysctl_nexthop_compat_mode,
718 		.maxlen         = sizeof(u8),
719 		.mode           = 0644,
720 		.proc_handler   = proc_dou8vec_minmax,
721 		.extra1		= SYSCTL_ZERO,
722 		.extra2		= SYSCTL_ONE,
723 	},
724 	{
725 		.procname	= "ip_default_ttl",
726 		.data		= &init_net.ipv4.sysctl_ip_default_ttl,
727 		.maxlen		= sizeof(u8),
728 		.mode		= 0644,
729 		.proc_handler	= proc_dou8vec_minmax,
730 		.extra1		= &ip_ttl_min,
731 		.extra2		= &ip_ttl_max,
732 	},
733 	{
734 		.procname	= "ip_local_port_range",
735 		.maxlen		= sizeof(init_net.ipv4.ip_local_ports.range),
736 		.data		= &init_net.ipv4.ip_local_ports.range,
737 		.mode		= 0644,
738 		.proc_handler	= ipv4_local_port_range,
739 	},
740 	{
741 		.procname	= "ip_local_reserved_ports",
742 		.data		= &init_net.ipv4.sysctl_local_reserved_ports,
743 		.maxlen		= 65536,
744 		.mode		= 0644,
745 		.proc_handler	= proc_do_large_bitmap,
746 	},
747 	{
748 		.procname	= "ip_no_pmtu_disc",
749 		.data		= &init_net.ipv4.sysctl_ip_no_pmtu_disc,
750 		.maxlen		= sizeof(u8),
751 		.mode		= 0644,
752 		.proc_handler	= proc_dou8vec_minmax,
753 	},
754 	{
755 		.procname	= "ip_forward_use_pmtu",
756 		.data		= &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
757 		.maxlen		= sizeof(u8),
758 		.mode		= 0644,
759 		.proc_handler	= proc_dou8vec_minmax,
760 	},
761 	{
762 		.procname	= "ip_forward_update_priority",
763 		.data		= &init_net.ipv4.sysctl_ip_fwd_update_priority,
764 		.maxlen		= sizeof(u8),
765 		.mode		= 0644,
766 		.proc_handler   = ipv4_fwd_update_priority,
767 		.extra1		= SYSCTL_ZERO,
768 		.extra2		= SYSCTL_ONE,
769 	},
770 	{
771 		.procname	= "ip_nonlocal_bind",
772 		.data		= &init_net.ipv4.sysctl_ip_nonlocal_bind,
773 		.maxlen		= sizeof(u8),
774 		.mode		= 0644,
775 		.proc_handler	= proc_dou8vec_minmax,
776 	},
777 	{
778 		.procname	= "ip_autobind_reuse",
779 		.data		= &init_net.ipv4.sysctl_ip_autobind_reuse,
780 		.maxlen		= sizeof(u8),
781 		.mode		= 0644,
782 		.proc_handler	= proc_dou8vec_minmax,
783 		.extra1         = SYSCTL_ZERO,
784 		.extra2         = SYSCTL_ONE,
785 	},
786 	{
787 		.procname	= "fwmark_reflect",
788 		.data		= &init_net.ipv4.sysctl_fwmark_reflect,
789 		.maxlen		= sizeof(u8),
790 		.mode		= 0644,
791 		.proc_handler	= proc_dou8vec_minmax,
792 	},
793 	{
794 		.procname	= "tcp_fwmark_accept",
795 		.data		= &init_net.ipv4.sysctl_tcp_fwmark_accept,
796 		.maxlen		= sizeof(u8),
797 		.mode		= 0644,
798 		.proc_handler	= proc_dou8vec_minmax,
799 	},
800 #ifdef CONFIG_NET_L3_MASTER_DEV
801 	{
802 		.procname	= "tcp_l3mdev_accept",
803 		.data		= &init_net.ipv4.sysctl_tcp_l3mdev_accept,
804 		.maxlen		= sizeof(u8),
805 		.mode		= 0644,
806 		.proc_handler	= proc_dou8vec_minmax,
807 		.extra1		= SYSCTL_ZERO,
808 		.extra2		= SYSCTL_ONE,
809 	},
810 #endif
811 	{
812 		.procname	= "tcp_mtu_probing",
813 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probing,
814 		.maxlen		= sizeof(u8),
815 		.mode		= 0644,
816 		.proc_handler	= proc_dou8vec_minmax,
817 	},
818 	{
819 		.procname	= "tcp_base_mss",
820 		.data		= &init_net.ipv4.sysctl_tcp_base_mss,
821 		.maxlen		= sizeof(int),
822 		.mode		= 0644,
823 		.proc_handler	= proc_dointvec,
824 	},
825 	{
826 		.procname	= "tcp_min_snd_mss",
827 		.data		= &init_net.ipv4.sysctl_tcp_min_snd_mss,
828 		.maxlen		= sizeof(int),
829 		.mode		= 0644,
830 		.proc_handler	= proc_dointvec_minmax,
831 		.extra1		= &tcp_min_snd_mss_min,
832 		.extra2		= &tcp_min_snd_mss_max,
833 	},
834 	{
835 		.procname	= "tcp_mtu_probe_floor",
836 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
837 		.maxlen		= sizeof(int),
838 		.mode		= 0644,
839 		.proc_handler	= proc_dointvec_minmax,
840 		.extra1		= &tcp_min_snd_mss_min,
841 		.extra2		= &tcp_min_snd_mss_max,
842 	},
843 	{
844 		.procname	= "tcp_probe_threshold",
845 		.data		= &init_net.ipv4.sysctl_tcp_probe_threshold,
846 		.maxlen		= sizeof(int),
847 		.mode		= 0644,
848 		.proc_handler	= proc_dointvec,
849 	},
850 	{
851 		.procname	= "tcp_probe_interval",
852 		.data		= &init_net.ipv4.sysctl_tcp_probe_interval,
853 		.maxlen		= sizeof(u32),
854 		.mode		= 0644,
855 		.proc_handler	= proc_douintvec_minmax,
856 		.extra2		= &u32_max_div_HZ,
857 	},
858 	{
859 		.procname	= "igmp_link_local_mcast_reports",
860 		.data		= &init_net.ipv4.sysctl_igmp_llm_reports,
861 		.maxlen		= sizeof(u8),
862 		.mode		= 0644,
863 		.proc_handler	= proc_dou8vec_minmax,
864 	},
865 	{
866 		.procname	= "igmp_max_memberships",
867 		.data		= &init_net.ipv4.sysctl_igmp_max_memberships,
868 		.maxlen		= sizeof(int),
869 		.mode		= 0644,
870 		.proc_handler	= proc_dointvec
871 	},
872 	{
873 		.procname	= "igmp_max_msf",
874 		.data		= &init_net.ipv4.sysctl_igmp_max_msf,
875 		.maxlen		= sizeof(int),
876 		.mode		= 0644,
877 		.proc_handler	= proc_dointvec
878 	},
879 #ifdef CONFIG_IP_MULTICAST
880 	{
881 		.procname	= "igmp_qrv",
882 		.data		= &init_net.ipv4.sysctl_igmp_qrv,
883 		.maxlen		= sizeof(int),
884 		.mode		= 0644,
885 		.proc_handler	= proc_dointvec_minmax,
886 		.extra1		= SYSCTL_ONE
887 	},
888 #endif
889 	{
890 		.procname	= "tcp_congestion_control",
891 		.data		= &init_net.ipv4.tcp_congestion_control,
892 		.mode		= 0644,
893 		.maxlen		= TCP_CA_NAME_MAX,
894 		.proc_handler	= proc_tcp_congestion_control,
895 	},
896 	{
897 		.procname	= "tcp_available_congestion_control",
898 		.maxlen		= TCP_CA_BUF_MAX,
899 		.mode		= 0444,
900 		.proc_handler   = proc_tcp_available_congestion_control,
901 	},
902 	{
903 		.procname	= "tcp_allowed_congestion_control",
904 		.maxlen		= TCP_CA_BUF_MAX,
905 		.mode		= 0644,
906 		.proc_handler   = proc_allowed_congestion_control,
907 	},
908 	{
909 		.procname	= "tcp_keepalive_time",
910 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_time,
911 		.maxlen		= sizeof(int),
912 		.mode		= 0644,
913 		.proc_handler	= proc_dointvec_jiffies,
914 	},
915 	{
916 		.procname	= "tcp_keepalive_probes",
917 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_probes,
918 		.maxlen		= sizeof(u8),
919 		.mode		= 0644,
920 		.proc_handler	= proc_dou8vec_minmax,
921 	},
922 	{
923 		.procname	= "tcp_keepalive_intvl",
924 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_intvl,
925 		.maxlen		= sizeof(int),
926 		.mode		= 0644,
927 		.proc_handler	= proc_dointvec_jiffies,
928 	},
929 	{
930 		.procname	= "tcp_syn_retries",
931 		.data		= &init_net.ipv4.sysctl_tcp_syn_retries,
932 		.maxlen		= sizeof(u8),
933 		.mode		= 0644,
934 		.proc_handler	= proc_dou8vec_minmax,
935 		.extra1		= &tcp_syn_retries_min,
936 		.extra2		= &tcp_syn_retries_max
937 	},
938 	{
939 		.procname	= "tcp_synack_retries",
940 		.data		= &init_net.ipv4.sysctl_tcp_synack_retries,
941 		.maxlen		= sizeof(u8),
942 		.mode		= 0644,
943 		.proc_handler	= proc_dou8vec_minmax,
944 	},
945 #ifdef CONFIG_SYN_COOKIES
946 	{
947 		.procname	= "tcp_syncookies",
948 		.data		= &init_net.ipv4.sysctl_tcp_syncookies,
949 		.maxlen		= sizeof(u8),
950 		.mode		= 0644,
951 		.proc_handler	= proc_dou8vec_minmax,
952 	},
953 #endif
954 	{
955 		.procname	= "tcp_migrate_req",
956 		.data		= &init_net.ipv4.sysctl_tcp_migrate_req,
957 		.maxlen		= sizeof(u8),
958 		.mode		= 0644,
959 		.proc_handler	= proc_dou8vec_minmax,
960 		.extra1		= SYSCTL_ZERO,
961 		.extra2		= SYSCTL_ONE
962 	},
963 	{
964 		.procname	= "tcp_reordering",
965 		.data		= &init_net.ipv4.sysctl_tcp_reordering,
966 		.maxlen		= sizeof(int),
967 		.mode		= 0644,
968 		.proc_handler	= proc_dointvec
969 	},
970 	{
971 		.procname	= "tcp_retries1",
972 		.data		= &init_net.ipv4.sysctl_tcp_retries1,
973 		.maxlen		= sizeof(u8),
974 		.mode		= 0644,
975 		.proc_handler	= proc_dou8vec_minmax,
976 		.extra2		= &tcp_retr1_max
977 	},
978 	{
979 		.procname	= "tcp_retries2",
980 		.data		= &init_net.ipv4.sysctl_tcp_retries2,
981 		.maxlen		= sizeof(u8),
982 		.mode		= 0644,
983 		.proc_handler	= proc_dou8vec_minmax,
984 	},
985 	{
986 		.procname	= "tcp_orphan_retries",
987 		.data		= &init_net.ipv4.sysctl_tcp_orphan_retries,
988 		.maxlen		= sizeof(u8),
989 		.mode		= 0644,
990 		.proc_handler	= proc_dou8vec_minmax,
991 	},
992 	{
993 		.procname	= "tcp_fin_timeout",
994 		.data		= &init_net.ipv4.sysctl_tcp_fin_timeout,
995 		.maxlen		= sizeof(int),
996 		.mode		= 0644,
997 		.proc_handler	= proc_dointvec_jiffies,
998 	},
999 	{
1000 		.procname	= "tcp_notsent_lowat",
1001 		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
1002 		.maxlen		= sizeof(unsigned int),
1003 		.mode		= 0644,
1004 		.proc_handler	= proc_douintvec,
1005 	},
1006 	{
1007 		.procname	= "tcp_tw_reuse",
1008 		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse,
1009 		.maxlen		= sizeof(u8),
1010 		.mode		= 0644,
1011 		.proc_handler	= proc_dou8vec_minmax,
1012 		.extra1		= SYSCTL_ZERO,
1013 		.extra2		= SYSCTL_TWO,
1014 	},
1015 	{
1016 		.procname	= "tcp_max_syn_backlog",
1017 		.data		= &init_net.ipv4.sysctl_max_syn_backlog,
1018 		.maxlen		= sizeof(int),
1019 		.mode		= 0644,
1020 		.proc_handler	= proc_dointvec
1021 	},
1022 	{
1023 		.procname	= "tcp_fastopen",
1024 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1025 		.maxlen		= sizeof(int),
1026 		.mode		= 0644,
1027 		.proc_handler	= proc_dointvec,
1028 	},
1029 	{
1030 		.procname	= "tcp_fastopen_key",
1031 		.mode		= 0600,
1032 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1033 		/* maxlen to print the list of keys in hex (*2), with dashes
1034 		 * separating doublewords and a comma in between keys.
1035 		 */
1036 		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH *
1037 				   2 * TCP_FASTOPEN_KEY_MAX) +
1038 				   (TCP_FASTOPEN_KEY_MAX * 5)),
1039 		.proc_handler	= proc_tcp_fastopen_key,
1040 	},
1041 	{
1042 		.procname	= "tcp_fastopen_blackhole_timeout_sec",
1043 		.data		= &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1044 		.maxlen		= sizeof(int),
1045 		.mode		= 0644,
1046 		.proc_handler	= proc_tfo_blackhole_detect_timeout,
1047 		.extra1		= SYSCTL_ZERO,
1048 	},
1049 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1050 	{
1051 		.procname	= "fib_multipath_use_neigh",
1052 		.data		= &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1053 		.maxlen		= sizeof(u8),
1054 		.mode		= 0644,
1055 		.proc_handler	= proc_dou8vec_minmax,
1056 		.extra1		= SYSCTL_ZERO,
1057 		.extra2		= SYSCTL_ONE,
1058 	},
1059 	{
1060 		.procname	= "fib_multipath_hash_policy",
1061 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1062 		.maxlen		= sizeof(u8),
1063 		.mode		= 0644,
1064 		.proc_handler	= proc_fib_multipath_hash_policy,
1065 		.extra1		= SYSCTL_ZERO,
1066 		.extra2		= SYSCTL_THREE,
1067 	},
1068 	{
1069 		.procname	= "fib_multipath_hash_fields",
1070 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_fields,
1071 		.maxlen		= sizeof(u32),
1072 		.mode		= 0644,
1073 		.proc_handler	= proc_fib_multipath_hash_fields,
1074 		.extra1		= SYSCTL_ONE,
1075 		.extra2		= &fib_multipath_hash_fields_all_mask,
1076 	},
1077 #endif
1078 	{
1079 		.procname	= "ip_unprivileged_port_start",
1080 		.maxlen		= sizeof(int),
1081 		.data		= &init_net.ipv4.sysctl_ip_prot_sock,
1082 		.mode		= 0644,
1083 		.proc_handler	= ipv4_privileged_ports,
1084 	},
1085 #ifdef CONFIG_NET_L3_MASTER_DEV
1086 	{
1087 		.procname	= "udp_l3mdev_accept",
1088 		.data		= &init_net.ipv4.sysctl_udp_l3mdev_accept,
1089 		.maxlen		= sizeof(u8),
1090 		.mode		= 0644,
1091 		.proc_handler	= proc_dou8vec_minmax,
1092 		.extra1		= SYSCTL_ZERO,
1093 		.extra2		= SYSCTL_ONE,
1094 	},
1095 #endif
1096 	{
1097 		.procname	= "tcp_sack",
1098 		.data		= &init_net.ipv4.sysctl_tcp_sack,
1099 		.maxlen		= sizeof(u8),
1100 		.mode		= 0644,
1101 		.proc_handler	= proc_dou8vec_minmax,
1102 	},
1103 	{
1104 		.procname	= "tcp_window_scaling",
1105 		.data		= &init_net.ipv4.sysctl_tcp_window_scaling,
1106 		.maxlen		= sizeof(u8),
1107 		.mode		= 0644,
1108 		.proc_handler	= proc_dou8vec_minmax,
1109 	},
1110 	{
1111 		.procname	= "tcp_timestamps",
1112 		.data		= &init_net.ipv4.sysctl_tcp_timestamps,
1113 		.maxlen		= sizeof(u8),
1114 		.mode		= 0644,
1115 		.proc_handler	= proc_dou8vec_minmax,
1116 	},
1117 	{
1118 		.procname	= "tcp_early_retrans",
1119 		.data		= &init_net.ipv4.sysctl_tcp_early_retrans,
1120 		.maxlen		= sizeof(u8),
1121 		.mode		= 0644,
1122 		.proc_handler	= proc_dou8vec_minmax,
1123 		.extra1		= SYSCTL_ZERO,
1124 		.extra2		= SYSCTL_FOUR,
1125 	},
1126 	{
1127 		.procname	= "tcp_recovery",
1128 		.data		= &init_net.ipv4.sysctl_tcp_recovery,
1129 		.maxlen		= sizeof(u8),
1130 		.mode		= 0644,
1131 		.proc_handler	= proc_dou8vec_minmax,
1132 	},
1133 	{
1134 		.procname       = "tcp_thin_linear_timeouts",
1135 		.data           = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1136 		.maxlen         = sizeof(u8),
1137 		.mode           = 0644,
1138 		.proc_handler   = proc_dou8vec_minmax,
1139 	},
1140 	{
1141 		.procname	= "tcp_slow_start_after_idle",
1142 		.data		= &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1143 		.maxlen		= sizeof(u8),
1144 		.mode		= 0644,
1145 		.proc_handler	= proc_dou8vec_minmax,
1146 	},
1147 	{
1148 		.procname	= "tcp_retrans_collapse",
1149 		.data		= &init_net.ipv4.sysctl_tcp_retrans_collapse,
1150 		.maxlen		= sizeof(u8),
1151 		.mode		= 0644,
1152 		.proc_handler	= proc_dou8vec_minmax,
1153 	},
1154 	{
1155 		.procname	= "tcp_stdurg",
1156 		.data		= &init_net.ipv4.sysctl_tcp_stdurg,
1157 		.maxlen		= sizeof(u8),
1158 		.mode		= 0644,
1159 		.proc_handler	= proc_dou8vec_minmax,
1160 	},
1161 	{
1162 		.procname	= "tcp_rfc1337",
1163 		.data		= &init_net.ipv4.sysctl_tcp_rfc1337,
1164 		.maxlen		= sizeof(u8),
1165 		.mode		= 0644,
1166 		.proc_handler	= proc_dou8vec_minmax,
1167 	},
1168 	{
1169 		.procname	= "tcp_abort_on_overflow",
1170 		.data		= &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1171 		.maxlen		= sizeof(u8),
1172 		.mode		= 0644,
1173 		.proc_handler	= proc_dou8vec_minmax,
1174 	},
1175 	{
1176 		.procname	= "tcp_fack",
1177 		.data		= &init_net.ipv4.sysctl_tcp_fack,
1178 		.maxlen		= sizeof(u8),
1179 		.mode		= 0644,
1180 		.proc_handler	= proc_dou8vec_minmax,
1181 	},
1182 	{
1183 		.procname	= "tcp_max_reordering",
1184 		.data		= &init_net.ipv4.sysctl_tcp_max_reordering,
1185 		.maxlen		= sizeof(int),
1186 		.mode		= 0644,
1187 		.proc_handler	= proc_dointvec
1188 	},
1189 	{
1190 		.procname	= "tcp_dsack",
1191 		.data		= &init_net.ipv4.sysctl_tcp_dsack,
1192 		.maxlen		= sizeof(u8),
1193 		.mode		= 0644,
1194 		.proc_handler	= proc_dou8vec_minmax,
1195 	},
1196 	{
1197 		.procname	= "tcp_app_win",
1198 		.data		= &init_net.ipv4.sysctl_tcp_app_win,
1199 		.maxlen		= sizeof(u8),
1200 		.mode		= 0644,
1201 		.proc_handler	= proc_dou8vec_minmax,
1202 		.extra1		= SYSCTL_ZERO,
1203 		.extra2		= &tcp_app_win_max,
1204 	},
1205 	{
1206 		.procname	= "tcp_adv_win_scale",
1207 		.data		= &init_net.ipv4.sysctl_tcp_adv_win_scale,
1208 		.maxlen		= sizeof(int),
1209 		.mode		= 0644,
1210 		.proc_handler	= proc_dointvec_minmax,
1211 		.extra1		= &tcp_adv_win_scale_min,
1212 		.extra2		= &tcp_adv_win_scale_max,
1213 	},
1214 	{
1215 		.procname	= "tcp_frto",
1216 		.data		= &init_net.ipv4.sysctl_tcp_frto,
1217 		.maxlen		= sizeof(u8),
1218 		.mode		= 0644,
1219 		.proc_handler	= proc_dou8vec_minmax,
1220 	},
1221 	{
1222 		.procname	= "tcp_no_metrics_save",
1223 		.data		= &init_net.ipv4.sysctl_tcp_nometrics_save,
1224 		.maxlen		= sizeof(u8),
1225 		.mode		= 0644,
1226 		.proc_handler	= proc_dou8vec_minmax,
1227 	},
1228 	{
1229 		.procname	= "tcp_no_ssthresh_metrics_save",
1230 		.data		= &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1231 		.maxlen		= sizeof(u8),
1232 		.mode		= 0644,
1233 		.proc_handler	= proc_dou8vec_minmax,
1234 		.extra1		= SYSCTL_ZERO,
1235 		.extra2		= SYSCTL_ONE,
1236 	},
1237 	{
1238 		.procname	= "tcp_moderate_rcvbuf",
1239 		.data		= &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1240 		.maxlen		= sizeof(u8),
1241 		.mode		= 0644,
1242 		.proc_handler	= proc_dou8vec_minmax,
1243 	},
1244 	{
1245 		.procname	= "tcp_tso_win_divisor",
1246 		.data		= &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1247 		.maxlen		= sizeof(u8),
1248 		.mode		= 0644,
1249 		.proc_handler	= proc_dou8vec_minmax,
1250 	},
1251 	{
1252 		.procname	= "tcp_workaround_signed_windows",
1253 		.data		= &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1254 		.maxlen		= sizeof(u8),
1255 		.mode		= 0644,
1256 		.proc_handler	= proc_dou8vec_minmax,
1257 	},
1258 	{
1259 		.procname	= "tcp_limit_output_bytes",
1260 		.data		= &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1261 		.maxlen		= sizeof(int),
1262 		.mode		= 0644,
1263 		.proc_handler	= proc_dointvec
1264 	},
1265 	{
1266 		.procname	= "tcp_challenge_ack_limit",
1267 		.data		= &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1268 		.maxlen		= sizeof(int),
1269 		.mode		= 0644,
1270 		.proc_handler	= proc_dointvec
1271 	},
1272 	{
1273 		.procname	= "tcp_min_tso_segs",
1274 		.data		= &init_net.ipv4.sysctl_tcp_min_tso_segs,
1275 		.maxlen		= sizeof(u8),
1276 		.mode		= 0644,
1277 		.proc_handler	= proc_dou8vec_minmax,
1278 		.extra1		= SYSCTL_ONE,
1279 	},
1280 	{
1281 		.procname	= "tcp_tso_rtt_log",
1282 		.data		= &init_net.ipv4.sysctl_tcp_tso_rtt_log,
1283 		.maxlen		= sizeof(u8),
1284 		.mode		= 0644,
1285 		.proc_handler	= proc_dou8vec_minmax,
1286 	},
1287 	{
1288 		.procname	= "tcp_min_rtt_wlen",
1289 		.data		= &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1290 		.maxlen		= sizeof(int),
1291 		.mode		= 0644,
1292 		.proc_handler	= proc_dointvec_minmax,
1293 		.extra1		= SYSCTL_ZERO,
1294 		.extra2		= &one_day_secs
1295 	},
1296 	{
1297 		.procname	= "tcp_autocorking",
1298 		.data		= &init_net.ipv4.sysctl_tcp_autocorking,
1299 		.maxlen		= sizeof(u8),
1300 		.mode		= 0644,
1301 		.proc_handler	= proc_dou8vec_minmax,
1302 		.extra1		= SYSCTL_ZERO,
1303 		.extra2		= SYSCTL_ONE,
1304 	},
1305 	{
1306 		.procname	= "tcp_invalid_ratelimit",
1307 		.data		= &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1308 		.maxlen		= sizeof(int),
1309 		.mode		= 0644,
1310 		.proc_handler	= proc_dointvec_ms_jiffies,
1311 	},
1312 	{
1313 		.procname	= "tcp_pacing_ss_ratio",
1314 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1315 		.maxlen		= sizeof(int),
1316 		.mode		= 0644,
1317 		.proc_handler	= proc_dointvec_minmax,
1318 		.extra1		= SYSCTL_ZERO,
1319 		.extra2		= SYSCTL_ONE_THOUSAND,
1320 	},
1321 	{
1322 		.procname	= "tcp_pacing_ca_ratio",
1323 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1324 		.maxlen		= sizeof(int),
1325 		.mode		= 0644,
1326 		.proc_handler	= proc_dointvec_minmax,
1327 		.extra1		= SYSCTL_ZERO,
1328 		.extra2		= SYSCTL_ONE_THOUSAND,
1329 	},
1330 	{
1331 		.procname	= "tcp_wmem",
1332 		.data		= &init_net.ipv4.sysctl_tcp_wmem,
1333 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_wmem),
1334 		.mode		= 0644,
1335 		.proc_handler	= proc_dointvec_minmax,
1336 		.extra1		= SYSCTL_ONE,
1337 	},
1338 	{
1339 		.procname	= "tcp_rmem",
1340 		.data		= &init_net.ipv4.sysctl_tcp_rmem,
1341 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_rmem),
1342 		.mode		= 0644,
1343 		.proc_handler	= proc_dointvec_minmax,
1344 		.extra1		= SYSCTL_ONE,
1345 	},
1346 	{
1347 		.procname	= "tcp_comp_sack_delay_ns",
1348 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1349 		.maxlen		= sizeof(unsigned long),
1350 		.mode		= 0644,
1351 		.proc_handler	= proc_doulongvec_minmax,
1352 	},
1353 	{
1354 		.procname	= "tcp_comp_sack_slack_ns",
1355 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1356 		.maxlen		= sizeof(unsigned long),
1357 		.mode		= 0644,
1358 		.proc_handler	= proc_doulongvec_minmax,
1359 	},
1360 	{
1361 		.procname	= "tcp_comp_sack_nr",
1362 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1363 		.maxlen		= sizeof(u8),
1364 		.mode		= 0644,
1365 		.proc_handler	= proc_dou8vec_minmax,
1366 		.extra1		= SYSCTL_ZERO,
1367 	},
1368 	{
1369 		.procname       = "tcp_reflect_tos",
1370 		.data           = &init_net.ipv4.sysctl_tcp_reflect_tos,
1371 		.maxlen         = sizeof(u8),
1372 		.mode           = 0644,
1373 		.proc_handler   = proc_dou8vec_minmax,
1374 		.extra1         = SYSCTL_ZERO,
1375 		.extra2         = SYSCTL_ONE,
1376 	},
1377 	{
1378 		.procname	= "tcp_ehash_entries",
1379 		.data		= &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1380 		.mode		= 0444,
1381 		.proc_handler	= proc_tcp_ehash_entries,
1382 	},
1383 	{
1384 		.procname	= "tcp_child_ehash_entries",
1385 		.data		= &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1386 		.maxlen		= sizeof(unsigned int),
1387 		.mode		= 0644,
1388 		.proc_handler	= proc_douintvec_minmax,
1389 		.extra1		= SYSCTL_ZERO,
1390 		.extra2		= &tcp_child_ehash_entries_max,
1391 	},
1392 	{
1393 		.procname	= "udp_hash_entries",
1394 		.data		= &init_net.ipv4.sysctl_udp_child_hash_entries,
1395 		.mode		= 0444,
1396 		.proc_handler	= proc_udp_hash_entries,
1397 	},
1398 	{
1399 		.procname	= "udp_child_hash_entries",
1400 		.data		= &init_net.ipv4.sysctl_udp_child_hash_entries,
1401 		.maxlen		= sizeof(unsigned int),
1402 		.mode		= 0644,
1403 		.proc_handler	= proc_douintvec_minmax,
1404 		.extra1		= SYSCTL_ZERO,
1405 		.extra2		= &udp_child_hash_entries_max,
1406 	},
1407 	{
1408 		.procname	= "udp_rmem_min",
1409 		.data		= &init_net.ipv4.sysctl_udp_rmem_min,
1410 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1411 		.mode		= 0644,
1412 		.proc_handler	= proc_dointvec_minmax,
1413 		.extra1		= SYSCTL_ONE
1414 	},
1415 	{
1416 		.procname	= "udp_wmem_min",
1417 		.data		= &init_net.ipv4.sysctl_udp_wmem_min,
1418 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1419 		.mode		= 0644,
1420 		.proc_handler	= proc_dointvec_minmax,
1421 		.extra1		= SYSCTL_ONE
1422 	},
1423 	{
1424 		.procname	= "fib_notify_on_flag_change",
1425 		.data		= &init_net.ipv4.sysctl_fib_notify_on_flag_change,
1426 		.maxlen		= sizeof(u8),
1427 		.mode		= 0644,
1428 		.proc_handler	= proc_dou8vec_minmax,
1429 		.extra1		= SYSCTL_ZERO,
1430 		.extra2		= SYSCTL_TWO,
1431 	},
1432 	{
1433 		.procname       = "tcp_plb_enabled",
1434 		.data           = &init_net.ipv4.sysctl_tcp_plb_enabled,
1435 		.maxlen         = sizeof(u8),
1436 		.mode           = 0644,
1437 		.proc_handler   = proc_dou8vec_minmax,
1438 		.extra1         = SYSCTL_ZERO,
1439 		.extra2         = SYSCTL_ONE,
1440 	},
1441 	{
1442 		.procname       = "tcp_plb_idle_rehash_rounds",
1443 		.data           = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds,
1444 		.maxlen         = sizeof(u8),
1445 		.mode           = 0644,
1446 		.proc_handler   = proc_dou8vec_minmax,
1447 		.extra2		= &tcp_plb_max_rounds,
1448 	},
1449 	{
1450 		.procname       = "tcp_plb_rehash_rounds",
1451 		.data           = &init_net.ipv4.sysctl_tcp_plb_rehash_rounds,
1452 		.maxlen         = sizeof(u8),
1453 		.mode           = 0644,
1454 		.proc_handler   = proc_dou8vec_minmax,
1455 		.extra2         = &tcp_plb_max_rounds,
1456 	},
1457 	{
1458 		.procname       = "tcp_plb_suspend_rto_sec",
1459 		.data           = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec,
1460 		.maxlen         = sizeof(u8),
1461 		.mode           = 0644,
1462 		.proc_handler   = proc_dou8vec_minmax,
1463 	},
1464 	{
1465 		.procname       = "tcp_plb_cong_thresh",
1466 		.data           = &init_net.ipv4.sysctl_tcp_plb_cong_thresh,
1467 		.maxlen         = sizeof(int),
1468 		.mode           = 0644,
1469 		.proc_handler   = proc_dointvec_minmax,
1470 		.extra1         = SYSCTL_ZERO,
1471 		.extra2         = &tcp_plb_max_cong_thresh,
1472 	},
1473 	{ }
1474 };
1475 
1476 static __net_init int ipv4_sysctl_init_net(struct net *net)
1477 {
1478 	struct ctl_table *table;
1479 
1480 	table = ipv4_net_table;
1481 	if (!net_eq(net, &init_net)) {
1482 		int i;
1483 
1484 		table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1485 		if (!table)
1486 			goto err_alloc;
1487 
1488 		for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) {
1489 			if (table[i].data) {
1490 				/* Update the variables to point into
1491 				 * the current struct net
1492 				 */
1493 				table[i].data += (void *)net - (void *)&init_net;
1494 			} else {
1495 				/* Entries without data pointer are global;
1496 				 * Make them read-only in non-init_net ns
1497 				 */
1498 				table[i].mode &= ~0222;
1499 			}
1500 		}
1501 	}
1502 
1503 	net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
1504 	if (!net->ipv4.ipv4_hdr)
1505 		goto err_reg;
1506 
1507 	net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1508 	if (!net->ipv4.sysctl_local_reserved_ports)
1509 		goto err_ports;
1510 
1511 	return 0;
1512 
1513 err_ports:
1514 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1515 err_reg:
1516 	if (!net_eq(net, &init_net))
1517 		kfree(table);
1518 err_alloc:
1519 	return -ENOMEM;
1520 }
1521 
1522 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1523 {
1524 	struct ctl_table *table;
1525 
1526 	kfree(net->ipv4.sysctl_local_reserved_ports);
1527 	table = net->ipv4.ipv4_hdr->ctl_table_arg;
1528 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1529 	kfree(table);
1530 }
1531 
1532 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1533 	.init = ipv4_sysctl_init_net,
1534 	.exit = ipv4_sysctl_exit_net,
1535 };
1536 
1537 static __init int sysctl_ipv4_init(void)
1538 {
1539 	struct ctl_table_header *hdr;
1540 
1541 	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1542 	if (!hdr)
1543 		return -ENOMEM;
1544 
1545 	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1546 		unregister_net_sysctl_table(hdr);
1547 		return -ENOMEM;
1548 	}
1549 
1550 	return 0;
1551 }
1552 
1553 __initcall(sysctl_ipv4_init);
1554