xref: /openbmc/linux/net/ipv4/sysctl_net_ipv4.c (revision 15e3ae36)
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 gso_max_segs = GSO_MAX_SEGS;
35 static int tcp_retr1_max = 255;
36 static int ip_local_port_range_min[] = { 1, 1 };
37 static int ip_local_port_range_max[] = { 65535, 65535 };
38 static int tcp_adv_win_scale_min = -31;
39 static int tcp_adv_win_scale_max = 31;
40 static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
41 static int tcp_min_snd_mss_max = 65535;
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 sscanf_key(char *buf, __le32 *key)
281 {
282 	u32 user_key[4];
283 	int i, ret = 0;
284 
285 	if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
286 		   user_key + 2, user_key + 3) != 4) {
287 		ret = -EINVAL;
288 	} else {
289 		for (i = 0; i < ARRAY_SIZE(user_key); i++)
290 			key[i] = cpu_to_le32(user_key[i]);
291 	}
292 	pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
293 		 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
294 
295 	return ret;
296 }
297 
298 static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
299 				 void __user *buffer, size_t *lenp,
300 				 loff_t *ppos)
301 {
302 	struct net *net = container_of(table->data, struct net,
303 	    ipv4.sysctl_tcp_fastopen);
304 	/* maxlen to print the list of keys in hex (*2), with dashes
305 	 * separating doublewords and a comma in between keys.
306 	 */
307 	struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
308 					    2 * TCP_FASTOPEN_KEY_MAX) +
309 					    (TCP_FASTOPEN_KEY_MAX * 5)) };
310 	struct tcp_fastopen_context *ctx;
311 	u32 user_key[TCP_FASTOPEN_KEY_MAX * 4];
312 	__le32 key[TCP_FASTOPEN_KEY_MAX * 4];
313 	char *backup_data;
314 	int ret, i = 0, off = 0, n_keys = 0;
315 
316 	tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
317 	if (!tbl.data)
318 		return -ENOMEM;
319 
320 	rcu_read_lock();
321 	ctx = rcu_dereference(net->ipv4.tcp_fastopen_ctx);
322 	if (ctx) {
323 		n_keys = tcp_fastopen_context_len(ctx);
324 		memcpy(&key[0], &ctx->key[0], TCP_FASTOPEN_KEY_LENGTH * n_keys);
325 	}
326 	rcu_read_unlock();
327 
328 	if (!n_keys) {
329 		memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
330 		n_keys = 1;
331 	}
332 
333 	for (i = 0; i < n_keys * 4; i++)
334 		user_key[i] = le32_to_cpu(key[i]);
335 
336 	for (i = 0; i < n_keys; i++) {
337 		off += snprintf(tbl.data + off, tbl.maxlen - off,
338 				"%08x-%08x-%08x-%08x",
339 				user_key[i * 4],
340 				user_key[i * 4 + 1],
341 				user_key[i * 4 + 2],
342 				user_key[i * 4 + 3]);
343 
344 		if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
345 			break;
346 
347 		if (i + 1 < n_keys)
348 			off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
349 	}
350 
351 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
352 
353 	if (write && ret == 0) {
354 		backup_data = strchr(tbl.data, ',');
355 		if (backup_data) {
356 			*backup_data = '\0';
357 			backup_data++;
358 		}
359 		if (sscanf_key(tbl.data, key)) {
360 			ret = -EINVAL;
361 			goto bad_key;
362 		}
363 		if (backup_data) {
364 			if (sscanf_key(backup_data, key + 4)) {
365 				ret = -EINVAL;
366 				goto bad_key;
367 			}
368 		}
369 		tcp_fastopen_reset_cipher(net, NULL, key,
370 					  backup_data ? key + 4 : NULL);
371 	}
372 
373 bad_key:
374 	kfree(tbl.data);
375 	return ret;
376 }
377 
378 static void proc_configure_early_demux(int enabled, int protocol)
379 {
380 	struct net_protocol *ipprot;
381 #if IS_ENABLED(CONFIG_IPV6)
382 	struct inet6_protocol *ip6prot;
383 #endif
384 
385 	rcu_read_lock();
386 
387 	ipprot = rcu_dereference(inet_protos[protocol]);
388 	if (ipprot)
389 		ipprot->early_demux = enabled ? ipprot->early_demux_handler :
390 						NULL;
391 
392 #if IS_ENABLED(CONFIG_IPV6)
393 	ip6prot = rcu_dereference(inet6_protos[protocol]);
394 	if (ip6prot)
395 		ip6prot->early_demux = enabled ? ip6prot->early_demux_handler :
396 						 NULL;
397 #endif
398 	rcu_read_unlock();
399 }
400 
401 static int proc_tcp_early_demux(struct ctl_table *table, int write,
402 				void __user *buffer, size_t *lenp, loff_t *ppos)
403 {
404 	int ret = 0;
405 
406 	ret = proc_dointvec(table, write, buffer, lenp, ppos);
407 
408 	if (write && !ret) {
409 		int enabled = init_net.ipv4.sysctl_tcp_early_demux;
410 
411 		proc_configure_early_demux(enabled, IPPROTO_TCP);
412 	}
413 
414 	return ret;
415 }
416 
417 static int proc_udp_early_demux(struct ctl_table *table, int write,
418 				void __user *buffer, size_t *lenp, loff_t *ppos)
419 {
420 	int ret = 0;
421 
422 	ret = proc_dointvec(table, write, buffer, lenp, ppos);
423 
424 	if (write && !ret) {
425 		int enabled = init_net.ipv4.sysctl_udp_early_demux;
426 
427 		proc_configure_early_demux(enabled, IPPROTO_UDP);
428 	}
429 
430 	return ret;
431 }
432 
433 static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
434 					     int write,
435 					     void __user *buffer,
436 					     size_t *lenp, loff_t *ppos)
437 {
438 	struct net *net = container_of(table->data, struct net,
439 	    ipv4.sysctl_tcp_fastopen_blackhole_timeout);
440 	int ret;
441 
442 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
443 	if (write && ret == 0)
444 		atomic_set(&net->ipv4.tfo_active_disable_times, 0);
445 
446 	return ret;
447 }
448 
449 static int proc_tcp_available_ulp(struct ctl_table *ctl,
450 				  int write,
451 				  void __user *buffer, size_t *lenp,
452 				  loff_t *ppos)
453 {
454 	struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
455 	int ret;
456 
457 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
458 	if (!tbl.data)
459 		return -ENOMEM;
460 	tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
461 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
462 	kfree(tbl.data);
463 
464 	return ret;
465 }
466 
467 #ifdef CONFIG_IP_ROUTE_MULTIPATH
468 static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
469 					  void __user *buffer, size_t *lenp,
470 					  loff_t *ppos)
471 {
472 	struct net *net = container_of(table->data, struct net,
473 	    ipv4.sysctl_fib_multipath_hash_policy);
474 	int ret;
475 
476 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
477 	if (write && ret == 0)
478 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
479 
480 	return ret;
481 }
482 #endif
483 
484 static struct ctl_table ipv4_table[] = {
485 	{
486 		.procname	= "tcp_max_orphans",
487 		.data		= &sysctl_tcp_max_orphans,
488 		.maxlen		= sizeof(int),
489 		.mode		= 0644,
490 		.proc_handler	= proc_dointvec
491 	},
492 	{
493 		.procname	= "inet_peer_threshold",
494 		.data		= &inet_peer_threshold,
495 		.maxlen		= sizeof(int),
496 		.mode		= 0644,
497 		.proc_handler	= proc_dointvec
498 	},
499 	{
500 		.procname	= "inet_peer_minttl",
501 		.data		= &inet_peer_minttl,
502 		.maxlen		= sizeof(int),
503 		.mode		= 0644,
504 		.proc_handler	= proc_dointvec_jiffies,
505 	},
506 	{
507 		.procname	= "inet_peer_maxttl",
508 		.data		= &inet_peer_maxttl,
509 		.maxlen		= sizeof(int),
510 		.mode		= 0644,
511 		.proc_handler	= proc_dointvec_jiffies,
512 	},
513 	{
514 		.procname	= "tcp_mem",
515 		.maxlen		= sizeof(sysctl_tcp_mem),
516 		.data		= &sysctl_tcp_mem,
517 		.mode		= 0644,
518 		.proc_handler	= proc_doulongvec_minmax,
519 	},
520 	{
521 		.procname	= "tcp_low_latency",
522 		.data		= &sysctl_tcp_low_latency,
523 		.maxlen		= sizeof(int),
524 		.mode		= 0644,
525 		.proc_handler	= proc_dointvec
526 	},
527 #ifdef CONFIG_NETLABEL
528 	{
529 		.procname	= "cipso_cache_enable",
530 		.data		= &cipso_v4_cache_enabled,
531 		.maxlen		= sizeof(int),
532 		.mode		= 0644,
533 		.proc_handler	= proc_dointvec,
534 	},
535 	{
536 		.procname	= "cipso_cache_bucket_size",
537 		.data		= &cipso_v4_cache_bucketsize,
538 		.maxlen		= sizeof(int),
539 		.mode		= 0644,
540 		.proc_handler	= proc_dointvec,
541 	},
542 	{
543 		.procname	= "cipso_rbm_optfmt",
544 		.data		= &cipso_v4_rbm_optfmt,
545 		.maxlen		= sizeof(int),
546 		.mode		= 0644,
547 		.proc_handler	= proc_dointvec,
548 	},
549 	{
550 		.procname	= "cipso_rbm_strictvalid",
551 		.data		= &cipso_v4_rbm_strictvalid,
552 		.maxlen		= sizeof(int),
553 		.mode		= 0644,
554 		.proc_handler	= proc_dointvec,
555 	},
556 #endif /* CONFIG_NETLABEL */
557 	{
558 		.procname	= "tcp_available_ulp",
559 		.maxlen		= TCP_ULP_BUF_MAX,
560 		.mode		= 0444,
561 		.proc_handler   = proc_tcp_available_ulp,
562 	},
563 	{
564 		.procname	= "icmp_msgs_per_sec",
565 		.data		= &sysctl_icmp_msgs_per_sec,
566 		.maxlen		= sizeof(int),
567 		.mode		= 0644,
568 		.proc_handler	= proc_dointvec_minmax,
569 		.extra1		= SYSCTL_ZERO,
570 	},
571 	{
572 		.procname	= "icmp_msgs_burst",
573 		.data		= &sysctl_icmp_msgs_burst,
574 		.maxlen		= sizeof(int),
575 		.mode		= 0644,
576 		.proc_handler	= proc_dointvec_minmax,
577 		.extra1		= SYSCTL_ZERO,
578 	},
579 	{
580 		.procname	= "udp_mem",
581 		.data		= &sysctl_udp_mem,
582 		.maxlen		= sizeof(sysctl_udp_mem),
583 		.mode		= 0644,
584 		.proc_handler	= proc_doulongvec_minmax,
585 	},
586 	{
587 		.procname	= "fib_sync_mem",
588 		.data		= &sysctl_fib_sync_mem,
589 		.maxlen		= sizeof(sysctl_fib_sync_mem),
590 		.mode		= 0644,
591 		.proc_handler	= proc_douintvec_minmax,
592 		.extra1		= &sysctl_fib_sync_mem_min,
593 		.extra2		= &sysctl_fib_sync_mem_max,
594 	},
595 	{
596 		.procname	= "tcp_rx_skb_cache",
597 		.data		= &tcp_rx_skb_cache_key.key,
598 		.mode		= 0644,
599 		.proc_handler	= proc_do_static_key,
600 	},
601 	{
602 		.procname	= "tcp_tx_skb_cache",
603 		.data		= &tcp_tx_skb_cache_key.key,
604 		.mode		= 0644,
605 		.proc_handler	= proc_do_static_key,
606 	},
607 	{ }
608 };
609 
610 static struct ctl_table ipv4_net_table[] = {
611 	{
612 		.procname	= "icmp_echo_ignore_all",
613 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_all,
614 		.maxlen		= sizeof(int),
615 		.mode		= 0644,
616 		.proc_handler	= proc_dointvec
617 	},
618 	{
619 		.procname	= "icmp_echo_ignore_broadcasts",
620 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
621 		.maxlen		= sizeof(int),
622 		.mode		= 0644,
623 		.proc_handler	= proc_dointvec
624 	},
625 	{
626 		.procname	= "icmp_ignore_bogus_error_responses",
627 		.data		= &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
628 		.maxlen		= sizeof(int),
629 		.mode		= 0644,
630 		.proc_handler	= proc_dointvec
631 	},
632 	{
633 		.procname	= "icmp_errors_use_inbound_ifaddr",
634 		.data		= &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
635 		.maxlen		= sizeof(int),
636 		.mode		= 0644,
637 		.proc_handler	= proc_dointvec
638 	},
639 	{
640 		.procname	= "icmp_ratelimit",
641 		.data		= &init_net.ipv4.sysctl_icmp_ratelimit,
642 		.maxlen		= sizeof(int),
643 		.mode		= 0644,
644 		.proc_handler	= proc_dointvec_ms_jiffies,
645 	},
646 	{
647 		.procname	= "icmp_ratemask",
648 		.data		= &init_net.ipv4.sysctl_icmp_ratemask,
649 		.maxlen		= sizeof(int),
650 		.mode		= 0644,
651 		.proc_handler	= proc_dointvec
652 	},
653 	{
654 		.procname	= "ping_group_range",
655 		.data		= &init_net.ipv4.ping_group_range.range,
656 		.maxlen		= sizeof(gid_t)*2,
657 		.mode		= 0644,
658 		.proc_handler	= ipv4_ping_group_range,
659 	},
660 #ifdef CONFIG_NET_L3_MASTER_DEV
661 	{
662 		.procname	= "raw_l3mdev_accept",
663 		.data		= &init_net.ipv4.sysctl_raw_l3mdev_accept,
664 		.maxlen		= sizeof(int),
665 		.mode		= 0644,
666 		.proc_handler	= proc_dointvec_minmax,
667 		.extra1		= SYSCTL_ZERO,
668 		.extra2		= SYSCTL_ONE,
669 	},
670 #endif
671 	{
672 		.procname	= "tcp_ecn",
673 		.data		= &init_net.ipv4.sysctl_tcp_ecn,
674 		.maxlen		= sizeof(int),
675 		.mode		= 0644,
676 		.proc_handler	= proc_dointvec
677 	},
678 	{
679 		.procname	= "tcp_ecn_fallback",
680 		.data		= &init_net.ipv4.sysctl_tcp_ecn_fallback,
681 		.maxlen		= sizeof(int),
682 		.mode		= 0644,
683 		.proc_handler	= proc_dointvec
684 	},
685 	{
686 		.procname	= "ip_dynaddr",
687 		.data		= &init_net.ipv4.sysctl_ip_dynaddr,
688 		.maxlen		= sizeof(int),
689 		.mode		= 0644,
690 		.proc_handler	= proc_dointvec
691 	},
692 	{
693 		.procname	= "ip_early_demux",
694 		.data		= &init_net.ipv4.sysctl_ip_early_demux,
695 		.maxlen		= sizeof(int),
696 		.mode		= 0644,
697 		.proc_handler	= proc_dointvec
698 	},
699 	{
700 		.procname       = "udp_early_demux",
701 		.data           = &init_net.ipv4.sysctl_udp_early_demux,
702 		.maxlen         = sizeof(int),
703 		.mode           = 0644,
704 		.proc_handler   = proc_udp_early_demux
705 	},
706 	{
707 		.procname       = "tcp_early_demux",
708 		.data           = &init_net.ipv4.sysctl_tcp_early_demux,
709 		.maxlen         = sizeof(int),
710 		.mode           = 0644,
711 		.proc_handler   = proc_tcp_early_demux
712 	},
713 	{
714 		.procname	= "ip_default_ttl",
715 		.data		= &init_net.ipv4.sysctl_ip_default_ttl,
716 		.maxlen		= sizeof(int),
717 		.mode		= 0644,
718 		.proc_handler	= proc_dointvec_minmax,
719 		.extra1		= &ip_ttl_min,
720 		.extra2		= &ip_ttl_max,
721 	},
722 	{
723 		.procname	= "ip_local_port_range",
724 		.maxlen		= sizeof(init_net.ipv4.ip_local_ports.range),
725 		.data		= &init_net.ipv4.ip_local_ports.range,
726 		.mode		= 0644,
727 		.proc_handler	= ipv4_local_port_range,
728 	},
729 	{
730 		.procname	= "ip_local_reserved_ports",
731 		.data		= &init_net.ipv4.sysctl_local_reserved_ports,
732 		.maxlen		= 65536,
733 		.mode		= 0644,
734 		.proc_handler	= proc_do_large_bitmap,
735 	},
736 	{
737 		.procname	= "ip_no_pmtu_disc",
738 		.data		= &init_net.ipv4.sysctl_ip_no_pmtu_disc,
739 		.maxlen		= sizeof(int),
740 		.mode		= 0644,
741 		.proc_handler	= proc_dointvec
742 	},
743 	{
744 		.procname	= "ip_forward_use_pmtu",
745 		.data		= &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
746 		.maxlen		= sizeof(int),
747 		.mode		= 0644,
748 		.proc_handler	= proc_dointvec,
749 	},
750 	{
751 		.procname	= "ip_forward_update_priority",
752 		.data		= &init_net.ipv4.sysctl_ip_fwd_update_priority,
753 		.maxlen		= sizeof(int),
754 		.mode		= 0644,
755 		.proc_handler   = ipv4_fwd_update_priority,
756 		.extra1		= SYSCTL_ZERO,
757 		.extra2		= SYSCTL_ONE,
758 	},
759 	{
760 		.procname	= "ip_nonlocal_bind",
761 		.data		= &init_net.ipv4.sysctl_ip_nonlocal_bind,
762 		.maxlen		= sizeof(int),
763 		.mode		= 0644,
764 		.proc_handler	= proc_dointvec
765 	},
766 	{
767 		.procname	= "ip_autobind_reuse",
768 		.data		= &init_net.ipv4.sysctl_ip_autobind_reuse,
769 		.maxlen		= sizeof(int),
770 		.mode		= 0644,
771 		.proc_handler	= proc_dointvec_minmax,
772 		.extra1         = SYSCTL_ZERO,
773 		.extra2         = SYSCTL_ONE,
774 	},
775 	{
776 		.procname	= "fwmark_reflect",
777 		.data		= &init_net.ipv4.sysctl_fwmark_reflect,
778 		.maxlen		= sizeof(int),
779 		.mode		= 0644,
780 		.proc_handler	= proc_dointvec,
781 	},
782 	{
783 		.procname	= "tcp_fwmark_accept",
784 		.data		= &init_net.ipv4.sysctl_tcp_fwmark_accept,
785 		.maxlen		= sizeof(int),
786 		.mode		= 0644,
787 		.proc_handler	= proc_dointvec,
788 	},
789 #ifdef CONFIG_NET_L3_MASTER_DEV
790 	{
791 		.procname	= "tcp_l3mdev_accept",
792 		.data		= &init_net.ipv4.sysctl_tcp_l3mdev_accept,
793 		.maxlen		= sizeof(int),
794 		.mode		= 0644,
795 		.proc_handler	= proc_dointvec_minmax,
796 		.extra1		= SYSCTL_ZERO,
797 		.extra2		= SYSCTL_ONE,
798 	},
799 #endif
800 	{
801 		.procname	= "tcp_mtu_probing",
802 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probing,
803 		.maxlen		= sizeof(int),
804 		.mode		= 0644,
805 		.proc_handler	= proc_dointvec,
806 	},
807 	{
808 		.procname	= "tcp_base_mss",
809 		.data		= &init_net.ipv4.sysctl_tcp_base_mss,
810 		.maxlen		= sizeof(int),
811 		.mode		= 0644,
812 		.proc_handler	= proc_dointvec,
813 	},
814 	{
815 		.procname	= "tcp_min_snd_mss",
816 		.data		= &init_net.ipv4.sysctl_tcp_min_snd_mss,
817 		.maxlen		= sizeof(int),
818 		.mode		= 0644,
819 		.proc_handler	= proc_dointvec_minmax,
820 		.extra1		= &tcp_min_snd_mss_min,
821 		.extra2		= &tcp_min_snd_mss_max,
822 	},
823 	{
824 		.procname	= "tcp_mtu_probe_floor",
825 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
826 		.maxlen		= sizeof(int),
827 		.mode		= 0644,
828 		.proc_handler	= proc_dointvec_minmax,
829 		.extra1		= &tcp_min_snd_mss_min,
830 		.extra2		= &tcp_min_snd_mss_max,
831 	},
832 	{
833 		.procname	= "tcp_probe_threshold",
834 		.data		= &init_net.ipv4.sysctl_tcp_probe_threshold,
835 		.maxlen		= sizeof(int),
836 		.mode		= 0644,
837 		.proc_handler	= proc_dointvec,
838 	},
839 	{
840 		.procname	= "tcp_probe_interval",
841 		.data		= &init_net.ipv4.sysctl_tcp_probe_interval,
842 		.maxlen		= sizeof(u32),
843 		.mode		= 0644,
844 		.proc_handler	= proc_douintvec_minmax,
845 		.extra2		= &u32_max_div_HZ,
846 	},
847 	{
848 		.procname	= "igmp_link_local_mcast_reports",
849 		.data		= &init_net.ipv4.sysctl_igmp_llm_reports,
850 		.maxlen		= sizeof(int),
851 		.mode		= 0644,
852 		.proc_handler	= proc_dointvec
853 	},
854 	{
855 		.procname	= "igmp_max_memberships",
856 		.data		= &init_net.ipv4.sysctl_igmp_max_memberships,
857 		.maxlen		= sizeof(int),
858 		.mode		= 0644,
859 		.proc_handler	= proc_dointvec
860 	},
861 	{
862 		.procname	= "igmp_max_msf",
863 		.data		= &init_net.ipv4.sysctl_igmp_max_msf,
864 		.maxlen		= sizeof(int),
865 		.mode		= 0644,
866 		.proc_handler	= proc_dointvec
867 	},
868 #ifdef CONFIG_IP_MULTICAST
869 	{
870 		.procname	= "igmp_qrv",
871 		.data		= &init_net.ipv4.sysctl_igmp_qrv,
872 		.maxlen		= sizeof(int),
873 		.mode		= 0644,
874 		.proc_handler	= proc_dointvec_minmax,
875 		.extra1		= SYSCTL_ONE
876 	},
877 #endif
878 	{
879 		.procname	= "tcp_congestion_control",
880 		.data		= &init_net.ipv4.tcp_congestion_control,
881 		.mode		= 0644,
882 		.maxlen		= TCP_CA_NAME_MAX,
883 		.proc_handler	= proc_tcp_congestion_control,
884 	},
885 	{
886 		.procname	= "tcp_available_congestion_control",
887 		.maxlen		= TCP_CA_BUF_MAX,
888 		.mode		= 0444,
889 		.proc_handler   = proc_tcp_available_congestion_control,
890 	},
891 	{
892 		.procname	= "tcp_allowed_congestion_control",
893 		.maxlen		= TCP_CA_BUF_MAX,
894 		.mode		= 0644,
895 		.proc_handler   = proc_allowed_congestion_control,
896 	},
897 	{
898 		.procname	= "tcp_keepalive_time",
899 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_time,
900 		.maxlen		= sizeof(int),
901 		.mode		= 0644,
902 		.proc_handler	= proc_dointvec_jiffies,
903 	},
904 	{
905 		.procname	= "tcp_keepalive_probes",
906 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_probes,
907 		.maxlen		= sizeof(int),
908 		.mode		= 0644,
909 		.proc_handler	= proc_dointvec
910 	},
911 	{
912 		.procname	= "tcp_keepalive_intvl",
913 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_intvl,
914 		.maxlen		= sizeof(int),
915 		.mode		= 0644,
916 		.proc_handler	= proc_dointvec_jiffies,
917 	},
918 	{
919 		.procname	= "tcp_syn_retries",
920 		.data		= &init_net.ipv4.sysctl_tcp_syn_retries,
921 		.maxlen		= sizeof(int),
922 		.mode		= 0644,
923 		.proc_handler	= proc_dointvec_minmax,
924 		.extra1		= &tcp_syn_retries_min,
925 		.extra2		= &tcp_syn_retries_max
926 	},
927 	{
928 		.procname	= "tcp_synack_retries",
929 		.data		= &init_net.ipv4.sysctl_tcp_synack_retries,
930 		.maxlen		= sizeof(int),
931 		.mode		= 0644,
932 		.proc_handler	= proc_dointvec
933 	},
934 #ifdef CONFIG_SYN_COOKIES
935 	{
936 		.procname	= "tcp_syncookies",
937 		.data		= &init_net.ipv4.sysctl_tcp_syncookies,
938 		.maxlen		= sizeof(int),
939 		.mode		= 0644,
940 		.proc_handler	= proc_dointvec
941 	},
942 #endif
943 	{
944 		.procname	= "tcp_reordering",
945 		.data		= &init_net.ipv4.sysctl_tcp_reordering,
946 		.maxlen		= sizeof(int),
947 		.mode		= 0644,
948 		.proc_handler	= proc_dointvec
949 	},
950 	{
951 		.procname	= "tcp_retries1",
952 		.data		= &init_net.ipv4.sysctl_tcp_retries1,
953 		.maxlen		= sizeof(int),
954 		.mode		= 0644,
955 		.proc_handler	= proc_dointvec_minmax,
956 		.extra2		= &tcp_retr1_max
957 	},
958 	{
959 		.procname	= "tcp_retries2",
960 		.data		= &init_net.ipv4.sysctl_tcp_retries2,
961 		.maxlen		= sizeof(int),
962 		.mode		= 0644,
963 		.proc_handler	= proc_dointvec
964 	},
965 	{
966 		.procname	= "tcp_orphan_retries",
967 		.data		= &init_net.ipv4.sysctl_tcp_orphan_retries,
968 		.maxlen		= sizeof(int),
969 		.mode		= 0644,
970 		.proc_handler	= proc_dointvec
971 	},
972 	{
973 		.procname	= "tcp_fin_timeout",
974 		.data		= &init_net.ipv4.sysctl_tcp_fin_timeout,
975 		.maxlen		= sizeof(int),
976 		.mode		= 0644,
977 		.proc_handler	= proc_dointvec_jiffies,
978 	},
979 	{
980 		.procname	= "tcp_notsent_lowat",
981 		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
982 		.maxlen		= sizeof(unsigned int),
983 		.mode		= 0644,
984 		.proc_handler	= proc_douintvec,
985 	},
986 	{
987 		.procname	= "tcp_tw_reuse",
988 		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse,
989 		.maxlen		= sizeof(int),
990 		.mode		= 0644,
991 		.proc_handler	= proc_dointvec_minmax,
992 		.extra1		= SYSCTL_ZERO,
993 		.extra2		= &two,
994 	},
995 	{
996 		.procname	= "tcp_max_tw_buckets",
997 		.data		= &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
998 		.maxlen		= sizeof(int),
999 		.mode		= 0644,
1000 		.proc_handler	= proc_dointvec
1001 	},
1002 	{
1003 		.procname	= "tcp_max_syn_backlog",
1004 		.data		= &init_net.ipv4.sysctl_max_syn_backlog,
1005 		.maxlen		= sizeof(int),
1006 		.mode		= 0644,
1007 		.proc_handler	= proc_dointvec
1008 	},
1009 	{
1010 		.procname	= "tcp_fastopen",
1011 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1012 		.maxlen		= sizeof(int),
1013 		.mode		= 0644,
1014 		.proc_handler	= proc_dointvec,
1015 	},
1016 	{
1017 		.procname	= "tcp_fastopen_key",
1018 		.mode		= 0600,
1019 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1020 		/* maxlen to print the list of keys in hex (*2), with dashes
1021 		 * separating doublewords and a comma in between keys.
1022 		 */
1023 		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH *
1024 				   2 * TCP_FASTOPEN_KEY_MAX) +
1025 				   (TCP_FASTOPEN_KEY_MAX * 5)),
1026 		.proc_handler	= proc_tcp_fastopen_key,
1027 	},
1028 	{
1029 		.procname	= "tcp_fastopen_blackhole_timeout_sec",
1030 		.data		= &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1031 		.maxlen		= sizeof(int),
1032 		.mode		= 0644,
1033 		.proc_handler	= proc_tfo_blackhole_detect_timeout,
1034 		.extra1		= SYSCTL_ZERO,
1035 	},
1036 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1037 	{
1038 		.procname	= "fib_multipath_use_neigh",
1039 		.data		= &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1040 		.maxlen		= sizeof(int),
1041 		.mode		= 0644,
1042 		.proc_handler	= proc_dointvec_minmax,
1043 		.extra1		= SYSCTL_ZERO,
1044 		.extra2		= SYSCTL_ONE,
1045 	},
1046 	{
1047 		.procname	= "fib_multipath_hash_policy",
1048 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1049 		.maxlen		= sizeof(int),
1050 		.mode		= 0644,
1051 		.proc_handler	= proc_fib_multipath_hash_policy,
1052 		.extra1		= SYSCTL_ZERO,
1053 		.extra2		= &two,
1054 	},
1055 #endif
1056 	{
1057 		.procname	= "ip_unprivileged_port_start",
1058 		.maxlen		= sizeof(int),
1059 		.data		= &init_net.ipv4.sysctl_ip_prot_sock,
1060 		.mode		= 0644,
1061 		.proc_handler	= ipv4_privileged_ports,
1062 	},
1063 #ifdef CONFIG_NET_L3_MASTER_DEV
1064 	{
1065 		.procname	= "udp_l3mdev_accept",
1066 		.data		= &init_net.ipv4.sysctl_udp_l3mdev_accept,
1067 		.maxlen		= sizeof(int),
1068 		.mode		= 0644,
1069 		.proc_handler	= proc_dointvec_minmax,
1070 		.extra1		= SYSCTL_ZERO,
1071 		.extra2		= SYSCTL_ONE,
1072 	},
1073 #endif
1074 	{
1075 		.procname	= "tcp_sack",
1076 		.data		= &init_net.ipv4.sysctl_tcp_sack,
1077 		.maxlen		= sizeof(int),
1078 		.mode		= 0644,
1079 		.proc_handler	= proc_dointvec
1080 	},
1081 	{
1082 		.procname	= "tcp_window_scaling",
1083 		.data		= &init_net.ipv4.sysctl_tcp_window_scaling,
1084 		.maxlen		= sizeof(int),
1085 		.mode		= 0644,
1086 		.proc_handler	= proc_dointvec
1087 	},
1088 	{
1089 		.procname	= "tcp_timestamps",
1090 		.data		= &init_net.ipv4.sysctl_tcp_timestamps,
1091 		.maxlen		= sizeof(int),
1092 		.mode		= 0644,
1093 		.proc_handler	= proc_dointvec
1094 	},
1095 	{
1096 		.procname	= "tcp_early_retrans",
1097 		.data		= &init_net.ipv4.sysctl_tcp_early_retrans,
1098 		.maxlen		= sizeof(int),
1099 		.mode		= 0644,
1100 		.proc_handler	= proc_dointvec_minmax,
1101 		.extra1		= SYSCTL_ZERO,
1102 		.extra2		= &four,
1103 	},
1104 	{
1105 		.procname	= "tcp_recovery",
1106 		.data		= &init_net.ipv4.sysctl_tcp_recovery,
1107 		.maxlen		= sizeof(int),
1108 		.mode		= 0644,
1109 		.proc_handler	= proc_dointvec,
1110 	},
1111 	{
1112 		.procname       = "tcp_thin_linear_timeouts",
1113 		.data           = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1114 		.maxlen         = sizeof(int),
1115 		.mode           = 0644,
1116 		.proc_handler   = proc_dointvec
1117 	},
1118 	{
1119 		.procname	= "tcp_slow_start_after_idle",
1120 		.data		= &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1121 		.maxlen		= sizeof(int),
1122 		.mode		= 0644,
1123 		.proc_handler	= proc_dointvec
1124 	},
1125 	{
1126 		.procname	= "tcp_retrans_collapse",
1127 		.data		= &init_net.ipv4.sysctl_tcp_retrans_collapse,
1128 		.maxlen		= sizeof(int),
1129 		.mode		= 0644,
1130 		.proc_handler	= proc_dointvec
1131 	},
1132 	{
1133 		.procname	= "tcp_stdurg",
1134 		.data		= &init_net.ipv4.sysctl_tcp_stdurg,
1135 		.maxlen		= sizeof(int),
1136 		.mode		= 0644,
1137 		.proc_handler	= proc_dointvec
1138 	},
1139 	{
1140 		.procname	= "tcp_rfc1337",
1141 		.data		= &init_net.ipv4.sysctl_tcp_rfc1337,
1142 		.maxlen		= sizeof(int),
1143 		.mode		= 0644,
1144 		.proc_handler	= proc_dointvec
1145 	},
1146 	{
1147 		.procname	= "tcp_abort_on_overflow",
1148 		.data		= &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1149 		.maxlen		= sizeof(int),
1150 		.mode		= 0644,
1151 		.proc_handler	= proc_dointvec
1152 	},
1153 	{
1154 		.procname	= "tcp_fack",
1155 		.data		= &init_net.ipv4.sysctl_tcp_fack,
1156 		.maxlen		= sizeof(int),
1157 		.mode		= 0644,
1158 		.proc_handler	= proc_dointvec
1159 	},
1160 	{
1161 		.procname	= "tcp_max_reordering",
1162 		.data		= &init_net.ipv4.sysctl_tcp_max_reordering,
1163 		.maxlen		= sizeof(int),
1164 		.mode		= 0644,
1165 		.proc_handler	= proc_dointvec
1166 	},
1167 	{
1168 		.procname	= "tcp_dsack",
1169 		.data		= &init_net.ipv4.sysctl_tcp_dsack,
1170 		.maxlen		= sizeof(int),
1171 		.mode		= 0644,
1172 		.proc_handler	= proc_dointvec
1173 	},
1174 	{
1175 		.procname	= "tcp_app_win",
1176 		.data		= &init_net.ipv4.sysctl_tcp_app_win,
1177 		.maxlen		= sizeof(int),
1178 		.mode		= 0644,
1179 		.proc_handler	= proc_dointvec
1180 	},
1181 	{
1182 		.procname	= "tcp_adv_win_scale",
1183 		.data		= &init_net.ipv4.sysctl_tcp_adv_win_scale,
1184 		.maxlen		= sizeof(int),
1185 		.mode		= 0644,
1186 		.proc_handler	= proc_dointvec_minmax,
1187 		.extra1		= &tcp_adv_win_scale_min,
1188 		.extra2		= &tcp_adv_win_scale_max,
1189 	},
1190 	{
1191 		.procname	= "tcp_frto",
1192 		.data		= &init_net.ipv4.sysctl_tcp_frto,
1193 		.maxlen		= sizeof(int),
1194 		.mode		= 0644,
1195 		.proc_handler	= proc_dointvec
1196 	},
1197 	{
1198 		.procname	= "tcp_no_metrics_save",
1199 		.data		= &init_net.ipv4.sysctl_tcp_nometrics_save,
1200 		.maxlen		= sizeof(int),
1201 		.mode		= 0644,
1202 		.proc_handler	= proc_dointvec,
1203 	},
1204 	{
1205 		.procname	= "tcp_no_ssthresh_metrics_save",
1206 		.data		= &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1207 		.maxlen		= sizeof(int),
1208 		.mode		= 0644,
1209 		.proc_handler	= proc_dointvec_minmax,
1210 		.extra1		= SYSCTL_ZERO,
1211 		.extra2		= SYSCTL_ONE,
1212 	},
1213 	{
1214 		.procname	= "tcp_moderate_rcvbuf",
1215 		.data		= &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1216 		.maxlen		= sizeof(int),
1217 		.mode		= 0644,
1218 		.proc_handler	= proc_dointvec,
1219 	},
1220 	{
1221 		.procname	= "tcp_tso_win_divisor",
1222 		.data		= &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1223 		.maxlen		= sizeof(int),
1224 		.mode		= 0644,
1225 		.proc_handler	= proc_dointvec,
1226 	},
1227 	{
1228 		.procname	= "tcp_workaround_signed_windows",
1229 		.data		= &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1230 		.maxlen		= sizeof(int),
1231 		.mode		= 0644,
1232 		.proc_handler	= proc_dointvec
1233 	},
1234 	{
1235 		.procname	= "tcp_limit_output_bytes",
1236 		.data		= &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1237 		.maxlen		= sizeof(int),
1238 		.mode		= 0644,
1239 		.proc_handler	= proc_dointvec
1240 	},
1241 	{
1242 		.procname	= "tcp_challenge_ack_limit",
1243 		.data		= &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1244 		.maxlen		= sizeof(int),
1245 		.mode		= 0644,
1246 		.proc_handler	= proc_dointvec
1247 	},
1248 	{
1249 		.procname	= "tcp_min_tso_segs",
1250 		.data		= &init_net.ipv4.sysctl_tcp_min_tso_segs,
1251 		.maxlen		= sizeof(int),
1252 		.mode		= 0644,
1253 		.proc_handler	= proc_dointvec_minmax,
1254 		.extra1		= SYSCTL_ONE,
1255 		.extra2		= &gso_max_segs,
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(int),
1270 		.mode		= 0644,
1271 		.proc_handler	= proc_dointvec_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_nr",
1325 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1326 		.maxlen		= sizeof(int),
1327 		.mode		= 0644,
1328 		.proc_handler	= proc_dointvec_minmax,
1329 		.extra1		= SYSCTL_ZERO,
1330 		.extra2		= &comp_sack_nr_max,
1331 	},
1332 	{
1333 		.procname	= "udp_rmem_min",
1334 		.data		= &init_net.ipv4.sysctl_udp_rmem_min,
1335 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1336 		.mode		= 0644,
1337 		.proc_handler	= proc_dointvec_minmax,
1338 		.extra1		= SYSCTL_ONE
1339 	},
1340 	{
1341 		.procname	= "udp_wmem_min",
1342 		.data		= &init_net.ipv4.sysctl_udp_wmem_min,
1343 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1344 		.mode		= 0644,
1345 		.proc_handler	= proc_dointvec_minmax,
1346 		.extra1		= SYSCTL_ONE
1347 	},
1348 	{ }
1349 };
1350 
1351 static __net_init int ipv4_sysctl_init_net(struct net *net)
1352 {
1353 	struct ctl_table *table;
1354 
1355 	table = ipv4_net_table;
1356 	if (!net_eq(net, &init_net)) {
1357 		int i;
1358 
1359 		table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1360 		if (!table)
1361 			goto err_alloc;
1362 
1363 		/* Update the variables to point into the current struct net */
1364 		for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1365 			table[i].data += (void *)net - (void *)&init_net;
1366 	}
1367 
1368 	net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
1369 	if (!net->ipv4.ipv4_hdr)
1370 		goto err_reg;
1371 
1372 	net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1373 	if (!net->ipv4.sysctl_local_reserved_ports)
1374 		goto err_ports;
1375 
1376 	return 0;
1377 
1378 err_ports:
1379 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1380 err_reg:
1381 	if (!net_eq(net, &init_net))
1382 		kfree(table);
1383 err_alloc:
1384 	return -ENOMEM;
1385 }
1386 
1387 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1388 {
1389 	struct ctl_table *table;
1390 
1391 	kfree(net->ipv4.sysctl_local_reserved_ports);
1392 	table = net->ipv4.ipv4_hdr->ctl_table_arg;
1393 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1394 	kfree(table);
1395 }
1396 
1397 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1398 	.init = ipv4_sysctl_init_net,
1399 	.exit = ipv4_sysctl_exit_net,
1400 };
1401 
1402 static __init int sysctl_ipv4_init(void)
1403 {
1404 	struct ctl_table_header *hdr;
1405 
1406 	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1407 	if (!hdr)
1408 		return -ENOMEM;
1409 
1410 	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1411 		unregister_net_sysctl_table(hdr);
1412 		return -ENOMEM;
1413 	}
1414 
1415 	return 0;
1416 }
1417 
1418 __initcall(sysctl_ipv4_init);
1419