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