xref: /openbmc/linux/net/ipv4/sysctl_net_ipv4.c (revision 3e30a927)
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_congestion_control",
559 		.maxlen		= TCP_CA_BUF_MAX,
560 		.mode		= 0444,
561 		.proc_handler   = proc_tcp_available_congestion_control,
562 	},
563 	{
564 		.procname	= "tcp_allowed_congestion_control",
565 		.maxlen		= TCP_CA_BUF_MAX,
566 		.mode		= 0644,
567 		.proc_handler   = proc_allowed_congestion_control,
568 	},
569 	{
570 		.procname	= "tcp_available_ulp",
571 		.maxlen		= TCP_ULP_BUF_MAX,
572 		.mode		= 0444,
573 		.proc_handler   = proc_tcp_available_ulp,
574 	},
575 	{
576 		.procname	= "icmp_msgs_per_sec",
577 		.data		= &sysctl_icmp_msgs_per_sec,
578 		.maxlen		= sizeof(int),
579 		.mode		= 0644,
580 		.proc_handler	= proc_dointvec_minmax,
581 		.extra1		= SYSCTL_ZERO,
582 	},
583 	{
584 		.procname	= "icmp_msgs_burst",
585 		.data		= &sysctl_icmp_msgs_burst,
586 		.maxlen		= sizeof(int),
587 		.mode		= 0644,
588 		.proc_handler	= proc_dointvec_minmax,
589 		.extra1		= SYSCTL_ZERO,
590 	},
591 	{
592 		.procname	= "udp_mem",
593 		.data		= &sysctl_udp_mem,
594 		.maxlen		= sizeof(sysctl_udp_mem),
595 		.mode		= 0644,
596 		.proc_handler	= proc_doulongvec_minmax,
597 	},
598 	{
599 		.procname	= "fib_sync_mem",
600 		.data		= &sysctl_fib_sync_mem,
601 		.maxlen		= sizeof(sysctl_fib_sync_mem),
602 		.mode		= 0644,
603 		.proc_handler	= proc_douintvec_minmax,
604 		.extra1		= &sysctl_fib_sync_mem_min,
605 		.extra2		= &sysctl_fib_sync_mem_max,
606 	},
607 	{
608 		.procname	= "tcp_rx_skb_cache",
609 		.data		= &tcp_rx_skb_cache_key.key,
610 		.mode		= 0644,
611 		.proc_handler	= proc_do_static_key,
612 	},
613 	{
614 		.procname	= "tcp_tx_skb_cache",
615 		.data		= &tcp_tx_skb_cache_key.key,
616 		.mode		= 0644,
617 		.proc_handler	= proc_do_static_key,
618 	},
619 	{ }
620 };
621 
622 static struct ctl_table ipv4_net_table[] = {
623 	{
624 		.procname	= "icmp_echo_ignore_all",
625 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_all,
626 		.maxlen		= sizeof(int),
627 		.mode		= 0644,
628 		.proc_handler	= proc_dointvec
629 	},
630 	{
631 		.procname	= "icmp_echo_ignore_broadcasts",
632 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
633 		.maxlen		= sizeof(int),
634 		.mode		= 0644,
635 		.proc_handler	= proc_dointvec
636 	},
637 	{
638 		.procname	= "icmp_ignore_bogus_error_responses",
639 		.data		= &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
640 		.maxlen		= sizeof(int),
641 		.mode		= 0644,
642 		.proc_handler	= proc_dointvec
643 	},
644 	{
645 		.procname	= "icmp_errors_use_inbound_ifaddr",
646 		.data		= &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
647 		.maxlen		= sizeof(int),
648 		.mode		= 0644,
649 		.proc_handler	= proc_dointvec
650 	},
651 	{
652 		.procname	= "icmp_ratelimit",
653 		.data		= &init_net.ipv4.sysctl_icmp_ratelimit,
654 		.maxlen		= sizeof(int),
655 		.mode		= 0644,
656 		.proc_handler	= proc_dointvec_ms_jiffies,
657 	},
658 	{
659 		.procname	= "icmp_ratemask",
660 		.data		= &init_net.ipv4.sysctl_icmp_ratemask,
661 		.maxlen		= sizeof(int),
662 		.mode		= 0644,
663 		.proc_handler	= proc_dointvec
664 	},
665 	{
666 		.procname	= "ping_group_range",
667 		.data		= &init_net.ipv4.ping_group_range.range,
668 		.maxlen		= sizeof(gid_t)*2,
669 		.mode		= 0644,
670 		.proc_handler	= ipv4_ping_group_range,
671 	},
672 #ifdef CONFIG_NET_L3_MASTER_DEV
673 	{
674 		.procname	= "raw_l3mdev_accept",
675 		.data		= &init_net.ipv4.sysctl_raw_l3mdev_accept,
676 		.maxlen		= sizeof(int),
677 		.mode		= 0644,
678 		.proc_handler	= proc_dointvec_minmax,
679 		.extra1		= SYSCTL_ZERO,
680 		.extra2		= SYSCTL_ONE,
681 	},
682 #endif
683 	{
684 		.procname	= "tcp_ecn",
685 		.data		= &init_net.ipv4.sysctl_tcp_ecn,
686 		.maxlen		= sizeof(int),
687 		.mode		= 0644,
688 		.proc_handler	= proc_dointvec
689 	},
690 	{
691 		.procname	= "tcp_ecn_fallback",
692 		.data		= &init_net.ipv4.sysctl_tcp_ecn_fallback,
693 		.maxlen		= sizeof(int),
694 		.mode		= 0644,
695 		.proc_handler	= proc_dointvec
696 	},
697 	{
698 		.procname	= "ip_dynaddr",
699 		.data		= &init_net.ipv4.sysctl_ip_dynaddr,
700 		.maxlen		= sizeof(int),
701 		.mode		= 0644,
702 		.proc_handler	= proc_dointvec
703 	},
704 	{
705 		.procname	= "ip_early_demux",
706 		.data		= &init_net.ipv4.sysctl_ip_early_demux,
707 		.maxlen		= sizeof(int),
708 		.mode		= 0644,
709 		.proc_handler	= proc_dointvec
710 	},
711 	{
712 		.procname       = "udp_early_demux",
713 		.data           = &init_net.ipv4.sysctl_udp_early_demux,
714 		.maxlen         = sizeof(int),
715 		.mode           = 0644,
716 		.proc_handler   = proc_udp_early_demux
717 	},
718 	{
719 		.procname       = "tcp_early_demux",
720 		.data           = &init_net.ipv4.sysctl_tcp_early_demux,
721 		.maxlen         = sizeof(int),
722 		.mode           = 0644,
723 		.proc_handler   = proc_tcp_early_demux
724 	},
725 	{
726 		.procname	= "ip_default_ttl",
727 		.data		= &init_net.ipv4.sysctl_ip_default_ttl,
728 		.maxlen		= sizeof(int),
729 		.mode		= 0644,
730 		.proc_handler	= proc_dointvec_minmax,
731 		.extra1		= &ip_ttl_min,
732 		.extra2		= &ip_ttl_max,
733 	},
734 	{
735 		.procname	= "ip_local_port_range",
736 		.maxlen		= sizeof(init_net.ipv4.ip_local_ports.range),
737 		.data		= &init_net.ipv4.ip_local_ports.range,
738 		.mode		= 0644,
739 		.proc_handler	= ipv4_local_port_range,
740 	},
741 	{
742 		.procname	= "ip_local_reserved_ports",
743 		.data		= &init_net.ipv4.sysctl_local_reserved_ports,
744 		.maxlen		= 65536,
745 		.mode		= 0644,
746 		.proc_handler	= proc_do_large_bitmap,
747 	},
748 	{
749 		.procname	= "ip_no_pmtu_disc",
750 		.data		= &init_net.ipv4.sysctl_ip_no_pmtu_disc,
751 		.maxlen		= sizeof(int),
752 		.mode		= 0644,
753 		.proc_handler	= proc_dointvec
754 	},
755 	{
756 		.procname	= "ip_forward_use_pmtu",
757 		.data		= &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
758 		.maxlen		= sizeof(int),
759 		.mode		= 0644,
760 		.proc_handler	= proc_dointvec,
761 	},
762 	{
763 		.procname	= "ip_forward_update_priority",
764 		.data		= &init_net.ipv4.sysctl_ip_fwd_update_priority,
765 		.maxlen		= sizeof(int),
766 		.mode		= 0644,
767 		.proc_handler   = ipv4_fwd_update_priority,
768 		.extra1		= SYSCTL_ZERO,
769 		.extra2		= SYSCTL_ONE,
770 	},
771 	{
772 		.procname	= "ip_nonlocal_bind",
773 		.data		= &init_net.ipv4.sysctl_ip_nonlocal_bind,
774 		.maxlen		= sizeof(int),
775 		.mode		= 0644,
776 		.proc_handler	= proc_dointvec
777 	},
778 	{
779 		.procname	= "fwmark_reflect",
780 		.data		= &init_net.ipv4.sysctl_fwmark_reflect,
781 		.maxlen		= sizeof(int),
782 		.mode		= 0644,
783 		.proc_handler	= proc_dointvec,
784 	},
785 	{
786 		.procname	= "tcp_fwmark_accept",
787 		.data		= &init_net.ipv4.sysctl_tcp_fwmark_accept,
788 		.maxlen		= sizeof(int),
789 		.mode		= 0644,
790 		.proc_handler	= proc_dointvec,
791 	},
792 #ifdef CONFIG_NET_L3_MASTER_DEV
793 	{
794 		.procname	= "tcp_l3mdev_accept",
795 		.data		= &init_net.ipv4.sysctl_tcp_l3mdev_accept,
796 		.maxlen		= sizeof(int),
797 		.mode		= 0644,
798 		.proc_handler	= proc_dointvec_minmax,
799 		.extra1		= SYSCTL_ZERO,
800 		.extra2		= SYSCTL_ONE,
801 	},
802 #endif
803 	{
804 		.procname	= "tcp_mtu_probing",
805 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probing,
806 		.maxlen		= sizeof(int),
807 		.mode		= 0644,
808 		.proc_handler	= proc_dointvec,
809 	},
810 	{
811 		.procname	= "tcp_base_mss",
812 		.data		= &init_net.ipv4.sysctl_tcp_base_mss,
813 		.maxlen		= sizeof(int),
814 		.mode		= 0644,
815 		.proc_handler	= proc_dointvec,
816 	},
817 	{
818 		.procname	= "tcp_min_snd_mss",
819 		.data		= &init_net.ipv4.sysctl_tcp_min_snd_mss,
820 		.maxlen		= sizeof(int),
821 		.mode		= 0644,
822 		.proc_handler	= proc_dointvec_minmax,
823 		.extra1		= &tcp_min_snd_mss_min,
824 		.extra2		= &tcp_min_snd_mss_max,
825 	},
826 	{
827 		.procname	= "tcp_mtu_probe_floor",
828 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
829 		.maxlen		= sizeof(int),
830 		.mode		= 0644,
831 		.proc_handler	= proc_dointvec_minmax,
832 		.extra1		= &tcp_min_snd_mss_min,
833 		.extra2		= &tcp_min_snd_mss_max,
834 	},
835 	{
836 		.procname	= "tcp_probe_threshold",
837 		.data		= &init_net.ipv4.sysctl_tcp_probe_threshold,
838 		.maxlen		= sizeof(int),
839 		.mode		= 0644,
840 		.proc_handler	= proc_dointvec,
841 	},
842 	{
843 		.procname	= "tcp_probe_interval",
844 		.data		= &init_net.ipv4.sysctl_tcp_probe_interval,
845 		.maxlen		= sizeof(u32),
846 		.mode		= 0644,
847 		.proc_handler	= proc_douintvec_minmax,
848 		.extra2		= &u32_max_div_HZ,
849 	},
850 	{
851 		.procname	= "igmp_link_local_mcast_reports",
852 		.data		= &init_net.ipv4.sysctl_igmp_llm_reports,
853 		.maxlen		= sizeof(int),
854 		.mode		= 0644,
855 		.proc_handler	= proc_dointvec
856 	},
857 	{
858 		.procname	= "igmp_max_memberships",
859 		.data		= &init_net.ipv4.sysctl_igmp_max_memberships,
860 		.maxlen		= sizeof(int),
861 		.mode		= 0644,
862 		.proc_handler	= proc_dointvec
863 	},
864 	{
865 		.procname	= "igmp_max_msf",
866 		.data		= &init_net.ipv4.sysctl_igmp_max_msf,
867 		.maxlen		= sizeof(int),
868 		.mode		= 0644,
869 		.proc_handler	= proc_dointvec
870 	},
871 #ifdef CONFIG_IP_MULTICAST
872 	{
873 		.procname	= "igmp_qrv",
874 		.data		= &init_net.ipv4.sysctl_igmp_qrv,
875 		.maxlen		= sizeof(int),
876 		.mode		= 0644,
877 		.proc_handler	= proc_dointvec_minmax,
878 		.extra1		= SYSCTL_ONE
879 	},
880 #endif
881 	{
882 		.procname	= "tcp_congestion_control",
883 		.data		= &init_net.ipv4.tcp_congestion_control,
884 		.mode		= 0644,
885 		.maxlen		= TCP_CA_NAME_MAX,
886 		.proc_handler	= proc_tcp_congestion_control,
887 	},
888 	{
889 		.procname	= "tcp_keepalive_time",
890 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_time,
891 		.maxlen		= sizeof(int),
892 		.mode		= 0644,
893 		.proc_handler	= proc_dointvec_jiffies,
894 	},
895 	{
896 		.procname	= "tcp_keepalive_probes",
897 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_probes,
898 		.maxlen		= sizeof(int),
899 		.mode		= 0644,
900 		.proc_handler	= proc_dointvec
901 	},
902 	{
903 		.procname	= "tcp_keepalive_intvl",
904 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_intvl,
905 		.maxlen		= sizeof(int),
906 		.mode		= 0644,
907 		.proc_handler	= proc_dointvec_jiffies,
908 	},
909 	{
910 		.procname	= "tcp_syn_retries",
911 		.data		= &init_net.ipv4.sysctl_tcp_syn_retries,
912 		.maxlen		= sizeof(int),
913 		.mode		= 0644,
914 		.proc_handler	= proc_dointvec_minmax,
915 		.extra1		= &tcp_syn_retries_min,
916 		.extra2		= &tcp_syn_retries_max
917 	},
918 	{
919 		.procname	= "tcp_synack_retries",
920 		.data		= &init_net.ipv4.sysctl_tcp_synack_retries,
921 		.maxlen		= sizeof(int),
922 		.mode		= 0644,
923 		.proc_handler	= proc_dointvec
924 	},
925 #ifdef CONFIG_SYN_COOKIES
926 	{
927 		.procname	= "tcp_syncookies",
928 		.data		= &init_net.ipv4.sysctl_tcp_syncookies,
929 		.maxlen		= sizeof(int),
930 		.mode		= 0644,
931 		.proc_handler	= proc_dointvec
932 	},
933 #endif
934 	{
935 		.procname	= "tcp_reordering",
936 		.data		= &init_net.ipv4.sysctl_tcp_reordering,
937 		.maxlen		= sizeof(int),
938 		.mode		= 0644,
939 		.proc_handler	= proc_dointvec
940 	},
941 	{
942 		.procname	= "tcp_retries1",
943 		.data		= &init_net.ipv4.sysctl_tcp_retries1,
944 		.maxlen		= sizeof(int),
945 		.mode		= 0644,
946 		.proc_handler	= proc_dointvec_minmax,
947 		.extra2		= &tcp_retr1_max
948 	},
949 	{
950 		.procname	= "tcp_retries2",
951 		.data		= &init_net.ipv4.sysctl_tcp_retries2,
952 		.maxlen		= sizeof(int),
953 		.mode		= 0644,
954 		.proc_handler	= proc_dointvec
955 	},
956 	{
957 		.procname	= "tcp_orphan_retries",
958 		.data		= &init_net.ipv4.sysctl_tcp_orphan_retries,
959 		.maxlen		= sizeof(int),
960 		.mode		= 0644,
961 		.proc_handler	= proc_dointvec
962 	},
963 	{
964 		.procname	= "tcp_fin_timeout",
965 		.data		= &init_net.ipv4.sysctl_tcp_fin_timeout,
966 		.maxlen		= sizeof(int),
967 		.mode		= 0644,
968 		.proc_handler	= proc_dointvec_jiffies,
969 	},
970 	{
971 		.procname	= "tcp_notsent_lowat",
972 		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
973 		.maxlen		= sizeof(unsigned int),
974 		.mode		= 0644,
975 		.proc_handler	= proc_douintvec,
976 	},
977 	{
978 		.procname	= "tcp_tw_reuse",
979 		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse,
980 		.maxlen		= sizeof(int),
981 		.mode		= 0644,
982 		.proc_handler	= proc_dointvec_minmax,
983 		.extra1		= SYSCTL_ZERO,
984 		.extra2		= &two,
985 	},
986 	{
987 		.procname	= "tcp_max_tw_buckets",
988 		.data		= &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
989 		.maxlen		= sizeof(int),
990 		.mode		= 0644,
991 		.proc_handler	= proc_dointvec
992 	},
993 	{
994 		.procname	= "tcp_max_syn_backlog",
995 		.data		= &init_net.ipv4.sysctl_max_syn_backlog,
996 		.maxlen		= sizeof(int),
997 		.mode		= 0644,
998 		.proc_handler	= proc_dointvec
999 	},
1000 	{
1001 		.procname	= "tcp_fastopen",
1002 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1003 		.maxlen		= sizeof(int),
1004 		.mode		= 0644,
1005 		.proc_handler	= proc_dointvec,
1006 	},
1007 	{
1008 		.procname	= "tcp_fastopen_key",
1009 		.mode		= 0600,
1010 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1011 		/* maxlen to print the list of keys in hex (*2), with dashes
1012 		 * separating doublewords and a comma in between keys.
1013 		 */
1014 		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH *
1015 				   2 * TCP_FASTOPEN_KEY_MAX) +
1016 				   (TCP_FASTOPEN_KEY_MAX * 5)),
1017 		.proc_handler	= proc_tcp_fastopen_key,
1018 	},
1019 	{
1020 		.procname	= "tcp_fastopen_blackhole_timeout_sec",
1021 		.data		= &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1022 		.maxlen		= sizeof(int),
1023 		.mode		= 0644,
1024 		.proc_handler	= proc_tfo_blackhole_detect_timeout,
1025 		.extra1		= SYSCTL_ZERO,
1026 	},
1027 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1028 	{
1029 		.procname	= "fib_multipath_use_neigh",
1030 		.data		= &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1031 		.maxlen		= sizeof(int),
1032 		.mode		= 0644,
1033 		.proc_handler	= proc_dointvec_minmax,
1034 		.extra1		= SYSCTL_ZERO,
1035 		.extra2		= SYSCTL_ONE,
1036 	},
1037 	{
1038 		.procname	= "fib_multipath_hash_policy",
1039 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1040 		.maxlen		= sizeof(int),
1041 		.mode		= 0644,
1042 		.proc_handler	= proc_fib_multipath_hash_policy,
1043 		.extra1		= SYSCTL_ZERO,
1044 		.extra2		= &two,
1045 	},
1046 #endif
1047 	{
1048 		.procname	= "ip_unprivileged_port_start",
1049 		.maxlen		= sizeof(int),
1050 		.data		= &init_net.ipv4.sysctl_ip_prot_sock,
1051 		.mode		= 0644,
1052 		.proc_handler	= ipv4_privileged_ports,
1053 	},
1054 #ifdef CONFIG_NET_L3_MASTER_DEV
1055 	{
1056 		.procname	= "udp_l3mdev_accept",
1057 		.data		= &init_net.ipv4.sysctl_udp_l3mdev_accept,
1058 		.maxlen		= sizeof(int),
1059 		.mode		= 0644,
1060 		.proc_handler	= proc_dointvec_minmax,
1061 		.extra1		= SYSCTL_ZERO,
1062 		.extra2		= SYSCTL_ONE,
1063 	},
1064 #endif
1065 	{
1066 		.procname	= "tcp_sack",
1067 		.data		= &init_net.ipv4.sysctl_tcp_sack,
1068 		.maxlen		= sizeof(int),
1069 		.mode		= 0644,
1070 		.proc_handler	= proc_dointvec
1071 	},
1072 	{
1073 		.procname	= "tcp_window_scaling",
1074 		.data		= &init_net.ipv4.sysctl_tcp_window_scaling,
1075 		.maxlen		= sizeof(int),
1076 		.mode		= 0644,
1077 		.proc_handler	= proc_dointvec
1078 	},
1079 	{
1080 		.procname	= "tcp_timestamps",
1081 		.data		= &init_net.ipv4.sysctl_tcp_timestamps,
1082 		.maxlen		= sizeof(int),
1083 		.mode		= 0644,
1084 		.proc_handler	= proc_dointvec
1085 	},
1086 	{
1087 		.procname	= "tcp_early_retrans",
1088 		.data		= &init_net.ipv4.sysctl_tcp_early_retrans,
1089 		.maxlen		= sizeof(int),
1090 		.mode		= 0644,
1091 		.proc_handler	= proc_dointvec_minmax,
1092 		.extra1		= SYSCTL_ZERO,
1093 		.extra2		= &four,
1094 	},
1095 	{
1096 		.procname	= "tcp_recovery",
1097 		.data		= &init_net.ipv4.sysctl_tcp_recovery,
1098 		.maxlen		= sizeof(int),
1099 		.mode		= 0644,
1100 		.proc_handler	= proc_dointvec,
1101 	},
1102 	{
1103 		.procname       = "tcp_thin_linear_timeouts",
1104 		.data           = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1105 		.maxlen         = sizeof(int),
1106 		.mode           = 0644,
1107 		.proc_handler   = proc_dointvec
1108 	},
1109 	{
1110 		.procname	= "tcp_slow_start_after_idle",
1111 		.data		= &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1112 		.maxlen		= sizeof(int),
1113 		.mode		= 0644,
1114 		.proc_handler	= proc_dointvec
1115 	},
1116 	{
1117 		.procname	= "tcp_retrans_collapse",
1118 		.data		= &init_net.ipv4.sysctl_tcp_retrans_collapse,
1119 		.maxlen		= sizeof(int),
1120 		.mode		= 0644,
1121 		.proc_handler	= proc_dointvec
1122 	},
1123 	{
1124 		.procname	= "tcp_stdurg",
1125 		.data		= &init_net.ipv4.sysctl_tcp_stdurg,
1126 		.maxlen		= sizeof(int),
1127 		.mode		= 0644,
1128 		.proc_handler	= proc_dointvec
1129 	},
1130 	{
1131 		.procname	= "tcp_rfc1337",
1132 		.data		= &init_net.ipv4.sysctl_tcp_rfc1337,
1133 		.maxlen		= sizeof(int),
1134 		.mode		= 0644,
1135 		.proc_handler	= proc_dointvec
1136 	},
1137 	{
1138 		.procname	= "tcp_abort_on_overflow",
1139 		.data		= &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1140 		.maxlen		= sizeof(int),
1141 		.mode		= 0644,
1142 		.proc_handler	= proc_dointvec
1143 	},
1144 	{
1145 		.procname	= "tcp_fack",
1146 		.data		= &init_net.ipv4.sysctl_tcp_fack,
1147 		.maxlen		= sizeof(int),
1148 		.mode		= 0644,
1149 		.proc_handler	= proc_dointvec
1150 	},
1151 	{
1152 		.procname	= "tcp_max_reordering",
1153 		.data		= &init_net.ipv4.sysctl_tcp_max_reordering,
1154 		.maxlen		= sizeof(int),
1155 		.mode		= 0644,
1156 		.proc_handler	= proc_dointvec
1157 	},
1158 	{
1159 		.procname	= "tcp_dsack",
1160 		.data		= &init_net.ipv4.sysctl_tcp_dsack,
1161 		.maxlen		= sizeof(int),
1162 		.mode		= 0644,
1163 		.proc_handler	= proc_dointvec
1164 	},
1165 	{
1166 		.procname	= "tcp_app_win",
1167 		.data		= &init_net.ipv4.sysctl_tcp_app_win,
1168 		.maxlen		= sizeof(int),
1169 		.mode		= 0644,
1170 		.proc_handler	= proc_dointvec
1171 	},
1172 	{
1173 		.procname	= "tcp_adv_win_scale",
1174 		.data		= &init_net.ipv4.sysctl_tcp_adv_win_scale,
1175 		.maxlen		= sizeof(int),
1176 		.mode		= 0644,
1177 		.proc_handler	= proc_dointvec_minmax,
1178 		.extra1		= &tcp_adv_win_scale_min,
1179 		.extra2		= &tcp_adv_win_scale_max,
1180 	},
1181 	{
1182 		.procname	= "tcp_frto",
1183 		.data		= &init_net.ipv4.sysctl_tcp_frto,
1184 		.maxlen		= sizeof(int),
1185 		.mode		= 0644,
1186 		.proc_handler	= proc_dointvec
1187 	},
1188 	{
1189 		.procname	= "tcp_no_metrics_save",
1190 		.data		= &init_net.ipv4.sysctl_tcp_nometrics_save,
1191 		.maxlen		= sizeof(int),
1192 		.mode		= 0644,
1193 		.proc_handler	= proc_dointvec,
1194 	},
1195 	{
1196 		.procname	= "tcp_no_ssthresh_metrics_save",
1197 		.data		= &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1198 		.maxlen		= sizeof(int),
1199 		.mode		= 0644,
1200 		.proc_handler	= proc_dointvec_minmax,
1201 		.extra1		= SYSCTL_ZERO,
1202 		.extra2		= SYSCTL_ONE,
1203 	},
1204 	{
1205 		.procname	= "tcp_moderate_rcvbuf",
1206 		.data		= &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1207 		.maxlen		= sizeof(int),
1208 		.mode		= 0644,
1209 		.proc_handler	= proc_dointvec,
1210 	},
1211 	{
1212 		.procname	= "tcp_tso_win_divisor",
1213 		.data		= &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1214 		.maxlen		= sizeof(int),
1215 		.mode		= 0644,
1216 		.proc_handler	= proc_dointvec,
1217 	},
1218 	{
1219 		.procname	= "tcp_workaround_signed_windows",
1220 		.data		= &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1221 		.maxlen		= sizeof(int),
1222 		.mode		= 0644,
1223 		.proc_handler	= proc_dointvec
1224 	},
1225 	{
1226 		.procname	= "tcp_limit_output_bytes",
1227 		.data		= &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1228 		.maxlen		= sizeof(int),
1229 		.mode		= 0644,
1230 		.proc_handler	= proc_dointvec
1231 	},
1232 	{
1233 		.procname	= "tcp_challenge_ack_limit",
1234 		.data		= &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1235 		.maxlen		= sizeof(int),
1236 		.mode		= 0644,
1237 		.proc_handler	= proc_dointvec
1238 	},
1239 	{
1240 		.procname	= "tcp_min_tso_segs",
1241 		.data		= &init_net.ipv4.sysctl_tcp_min_tso_segs,
1242 		.maxlen		= sizeof(int),
1243 		.mode		= 0644,
1244 		.proc_handler	= proc_dointvec_minmax,
1245 		.extra1		= SYSCTL_ONE,
1246 		.extra2		= &gso_max_segs,
1247 	},
1248 	{
1249 		.procname	= "tcp_min_rtt_wlen",
1250 		.data		= &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1251 		.maxlen		= sizeof(int),
1252 		.mode		= 0644,
1253 		.proc_handler	= proc_dointvec_minmax,
1254 		.extra1		= SYSCTL_ZERO,
1255 		.extra2		= &one_day_secs
1256 	},
1257 	{
1258 		.procname	= "tcp_autocorking",
1259 		.data		= &init_net.ipv4.sysctl_tcp_autocorking,
1260 		.maxlen		= sizeof(int),
1261 		.mode		= 0644,
1262 		.proc_handler	= proc_dointvec_minmax,
1263 		.extra1		= SYSCTL_ZERO,
1264 		.extra2		= SYSCTL_ONE,
1265 	},
1266 	{
1267 		.procname	= "tcp_invalid_ratelimit",
1268 		.data		= &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1269 		.maxlen		= sizeof(int),
1270 		.mode		= 0644,
1271 		.proc_handler	= proc_dointvec_ms_jiffies,
1272 	},
1273 	{
1274 		.procname	= "tcp_pacing_ss_ratio",
1275 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1276 		.maxlen		= sizeof(int),
1277 		.mode		= 0644,
1278 		.proc_handler	= proc_dointvec_minmax,
1279 		.extra1		= SYSCTL_ZERO,
1280 		.extra2		= &thousand,
1281 	},
1282 	{
1283 		.procname	= "tcp_pacing_ca_ratio",
1284 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ca_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_wmem",
1293 		.data		= &init_net.ipv4.sysctl_tcp_wmem,
1294 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_wmem),
1295 		.mode		= 0644,
1296 		.proc_handler	= proc_dointvec_minmax,
1297 		.extra1		= SYSCTL_ONE,
1298 	},
1299 	{
1300 		.procname	= "tcp_rmem",
1301 		.data		= &init_net.ipv4.sysctl_tcp_rmem,
1302 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_rmem),
1303 		.mode		= 0644,
1304 		.proc_handler	= proc_dointvec_minmax,
1305 		.extra1		= SYSCTL_ONE,
1306 	},
1307 	{
1308 		.procname	= "tcp_comp_sack_delay_ns",
1309 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1310 		.maxlen		= sizeof(unsigned long),
1311 		.mode		= 0644,
1312 		.proc_handler	= proc_doulongvec_minmax,
1313 	},
1314 	{
1315 		.procname	= "tcp_comp_sack_nr",
1316 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1317 		.maxlen		= sizeof(int),
1318 		.mode		= 0644,
1319 		.proc_handler	= proc_dointvec_minmax,
1320 		.extra1		= SYSCTL_ZERO,
1321 		.extra2		= &comp_sack_nr_max,
1322 	},
1323 	{
1324 		.procname	= "udp_rmem_min",
1325 		.data		= &init_net.ipv4.sysctl_udp_rmem_min,
1326 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1327 		.mode		= 0644,
1328 		.proc_handler	= proc_dointvec_minmax,
1329 		.extra1		= SYSCTL_ONE
1330 	},
1331 	{
1332 		.procname	= "udp_wmem_min",
1333 		.data		= &init_net.ipv4.sysctl_udp_wmem_min,
1334 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1335 		.mode		= 0644,
1336 		.proc_handler	= proc_dointvec_minmax,
1337 		.extra1		= SYSCTL_ONE
1338 	},
1339 	{ }
1340 };
1341 
1342 static __net_init int ipv4_sysctl_init_net(struct net *net)
1343 {
1344 	struct ctl_table *table;
1345 
1346 	table = ipv4_net_table;
1347 	if (!net_eq(net, &init_net)) {
1348 		int i;
1349 
1350 		table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1351 		if (!table)
1352 			goto err_alloc;
1353 
1354 		/* Update the variables to point into the current struct net */
1355 		for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1356 			table[i].data += (void *)net - (void *)&init_net;
1357 	}
1358 
1359 	net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
1360 	if (!net->ipv4.ipv4_hdr)
1361 		goto err_reg;
1362 
1363 	net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1364 	if (!net->ipv4.sysctl_local_reserved_ports)
1365 		goto err_ports;
1366 
1367 	return 0;
1368 
1369 err_ports:
1370 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1371 err_reg:
1372 	if (!net_eq(net, &init_net))
1373 		kfree(table);
1374 err_alloc:
1375 	return -ENOMEM;
1376 }
1377 
1378 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1379 {
1380 	struct ctl_table *table;
1381 
1382 	kfree(net->ipv4.sysctl_local_reserved_ports);
1383 	table = net->ipv4.ipv4_hdr->ctl_table_arg;
1384 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1385 	kfree(table);
1386 }
1387 
1388 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1389 	.init = ipv4_sysctl_init_net,
1390 	.exit = ipv4_sysctl_exit_net,
1391 };
1392 
1393 static __init int sysctl_ipv4_init(void)
1394 {
1395 	struct ctl_table_header *hdr;
1396 
1397 	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1398 	if (!hdr)
1399 		return -ENOMEM;
1400 
1401 	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1402 		unregister_net_sysctl_table(hdr);
1403 		return -ENOMEM;
1404 	}
1405 
1406 	return 0;
1407 }
1408 
1409 __initcall(sysctl_ipv4_init);
1410