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