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