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