xref: /linux/net/ipv4/sysctl_net_ipv4.c (revision 850a7225bc61cdfaf0c4b02ff341ae7cb54902f5)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4  *
5  * Begun April 1, 1996, Mike Shaver.
6  * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
7  */
8 
9 #include <linux/sysctl.h>
10 #include <linux/seqlock.h>
11 #include <linux/init.h>
12 #include <linux/slab.h>
13 #include <net/icmp.h>
14 #include <net/ip.h>
15 #include <net/ip_fib.h>
16 #include <net/tcp.h>
17 #include <net/udp.h>
18 #include <net/cipso_ipv4.h>
19 #include <net/ping.h>
20 #include <net/protocol.h>
21 #include <net/netevent.h>
22 
23 static int tcp_retr1_max = 255;
24 static int ip_local_port_range_min[] = { 1, 1 };
25 static int ip_local_port_range_max[] = { 65535, 65535 };
26 static int tcp_adv_win_scale_min = -31;
27 static int tcp_adv_win_scale_max = 31;
28 static int tcp_app_win_max = 31;
29 static int tcp_tso_rtt_log_max = 31;
30 static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
31 static int tcp_min_snd_mss_max = 65535;
32 static int tcp_rto_max_max = TCP_RTO_MAX_SEC * MSEC_PER_SEC;
33 static int ip_privileged_port_min;
34 static int ip_privileged_port_max = 65535;
35 static int ip_ttl_min = 1;
36 static int ip_ttl_max = 255;
37 static int tcp_syn_retries_min = 1;
38 static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
39 static int tcp_syn_linear_timeouts_max = MAX_TCP_SYNCNT;
40 static unsigned long ip_ping_group_range_min[] = { 0, 0 };
41 static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
42 static u32 u32_max_div_HZ = UINT_MAX / HZ;
43 static int one_day_secs = 24 * 3600;
44 static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
45 	FIB_MULTIPATH_HASH_FIELD_ALL_MASK;
46 static unsigned int tcp_child_ehash_entries_max = 16 * 1024 * 1024;
47 static unsigned int udp_child_hash_entries_max = UDP_HTABLE_SIZE_MAX;
48 static int tcp_plb_max_rounds = 31;
49 static int tcp_plb_max_cong_thresh = 256;
50 static unsigned int tcp_tw_reuse_delay_max = TCP_PAWS_MSL * MSEC_PER_SEC;
51 static int tcp_ecn_mode_max = 5;
52 static u32 icmp_errors_extension_mask_all =
53 	GENMASK_U8(ICMP_ERR_EXT_COUNT - 1, 0);
54 
55 static int tcp_min_rcvbuf = 4096;
56 
57 /* obsolete */
58 static int sysctl_tcp_low_latency __read_mostly;
59 
60 /* Update system visible IP port range */
61 static void set_local_port_range(struct net *net, unsigned int low, unsigned int high)
62 {
63 	bool same_parity = !((low ^ high) & 1);
64 
65 	if (same_parity && !net->ipv4.ip_local_ports.warned) {
66 		net->ipv4.ip_local_ports.warned = true;
67 		pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
68 	}
69 	WRITE_ONCE(net->ipv4.ip_local_ports.range, high << 16 | low);
70 }
71 
72 /* Validate changes from /proc interface. */
73 static int ipv4_local_port_range(const struct ctl_table *table, int write,
74 				 void *buffer, size_t *lenp, loff_t *ppos)
75 {
76 	struct net *net = table->data;
77 	int ret;
78 	int range[2];
79 	struct ctl_table tmp = {
80 		.data = &range,
81 		.maxlen = sizeof(range),
82 		.mode = table->mode,
83 		.extra1 = &ip_local_port_range_min,
84 		.extra2 = &ip_local_port_range_max,
85 	};
86 
87 	inet_get_local_port_range(net, &range[0], &range[1]);
88 
89 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
90 
91 	if (write && ret == 0) {
92 		/* Ensure that the upper limit is not smaller than the lower,
93 		 * and that the lower does not encroach upon the privileged
94 		 * port limit.
95 		 */
96 		if ((range[1] < range[0]) ||
97 		    (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock)))
98 			ret = -EINVAL;
99 		else
100 			set_local_port_range(net, range[0], range[1]);
101 	}
102 
103 	return ret;
104 }
105 
106 /* Validate changes from /proc interface. */
107 static int ipv4_privileged_ports(const struct ctl_table *table, int write,
108 				void *buffer, size_t *lenp, loff_t *ppos)
109 {
110 	struct net *net = container_of(table->data, struct net,
111 	    ipv4.sysctl_ip_prot_sock);
112 	int ret;
113 	int pports;
114 	int range[2];
115 	struct ctl_table tmp = {
116 		.data = &pports,
117 		.maxlen = sizeof(pports),
118 		.mode = table->mode,
119 		.extra1 = &ip_privileged_port_min,
120 		.extra2 = &ip_privileged_port_max,
121 	};
122 
123 	pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock);
124 
125 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
126 
127 	if (write && ret == 0) {
128 		inet_get_local_port_range(net, &range[0], &range[1]);
129 		/* Ensure that the local port range doesn't overlap with the
130 		 * privileged port range.
131 		 */
132 		if (range[0] < pports)
133 			ret = -EINVAL;
134 		else
135 			WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports);
136 	}
137 
138 	return ret;
139 }
140 
141 static void inet_get_ping_group_range_table(const struct ctl_table *table,
142 					    kgid_t *low, kgid_t *high)
143 {
144 	kgid_t *data = table->data;
145 	struct net *net =
146 		container_of(table->data, struct net, ipv4.ping_group_range.range);
147 	unsigned int seq;
148 	do {
149 		seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
150 
151 		*low = data[0];
152 		*high = data[1];
153 	} while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
154 }
155 
156 /* Update system visible IP port range */
157 static void set_ping_group_range(const struct ctl_table *table,
158 				 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(const struct ctl_table *table, int write,
171 				 void *buffer, size_t *lenp, loff_t *ppos)
172 {
173 	struct user_namespace *user_ns = current_user_ns();
174 	int ret;
175 	unsigned long urange[2];
176 	kgid_t low, high;
177 	struct ctl_table tmp = {
178 		.data = &urange,
179 		.maxlen = sizeof(urange),
180 		.mode = table->mode,
181 		.extra1 = &ip_ping_group_range_min,
182 		.extra2 = &ip_ping_group_range_max,
183 	};
184 
185 	inet_get_ping_group_range_table(table, &low, &high);
186 	urange[0] = from_kgid_munged(user_ns, low);
187 	urange[1] = from_kgid_munged(user_ns, high);
188 	ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
189 
190 	if (write && ret == 0) {
191 		low = make_kgid(user_ns, urange[0]);
192 		high = make_kgid(user_ns, urange[1]);
193 		if (!gid_valid(low) || !gid_valid(high))
194 			return -EINVAL;
195 		if (urange[1] < urange[0] || gid_lt(high, low)) {
196 			low = make_kgid(&init_user_ns, 1);
197 			high = make_kgid(&init_user_ns, 0);
198 		}
199 		set_ping_group_range(table, low, high);
200 	}
201 
202 	return ret;
203 }
204 
205 static int ipv4_fwd_update_priority(const struct ctl_table *table, int write,
206 				    void *buffer, size_t *lenp, loff_t *ppos)
207 {
208 	struct net *net;
209 	int ret;
210 
211 	net = container_of(table->data, struct net,
212 			   ipv4.sysctl_ip_fwd_update_priority);
213 	ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
214 	if (write && ret == 0)
215 		call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
216 					net);
217 
218 	return ret;
219 }
220 
221 static int proc_tcp_congestion_control(const struct ctl_table *ctl, int write,
222 				       void *buffer, size_t *lenp, loff_t *ppos)
223 {
224 	struct net *net = container_of(ctl->data, struct net,
225 				       ipv4.tcp_congestion_control);
226 	char val[TCP_CA_NAME_MAX];
227 	struct ctl_table tbl = {
228 		.data = val,
229 		.maxlen = TCP_CA_NAME_MAX,
230 	};
231 	int ret;
232 
233 	tcp_get_default_congestion_control(net, val);
234 
235 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
236 	if (write && ret == 0)
237 		ret = tcp_set_default_congestion_control(net, val);
238 	return ret;
239 }
240 
241 static int proc_tcp_available_congestion_control(const struct ctl_table *ctl,
242 						 int write, void *buffer,
243 						 size_t *lenp, loff_t *ppos)
244 {
245 	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
246 	int ret;
247 
248 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
249 	if (!tbl.data)
250 		return -ENOMEM;
251 	tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
252 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
253 	kfree(tbl.data);
254 	return ret;
255 }
256 
257 static int proc_allowed_congestion_control(const struct ctl_table *ctl,
258 					   int write, void *buffer,
259 					   size_t *lenp, loff_t *ppos)
260 {
261 	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
262 	int ret;
263 
264 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
265 	if (!tbl.data)
266 		return -ENOMEM;
267 
268 	tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
269 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
270 	if (write && ret == 0)
271 		ret = tcp_set_allowed_congestion_control(tbl.data);
272 	kfree(tbl.data);
273 	return ret;
274 }
275 
276 static int sscanf_key(char *buf, __le32 *key)
277 {
278 	u32 user_key[4];
279 	int i, ret = 0;
280 
281 	if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
282 		   user_key + 2, user_key + 3) != 4) {
283 		ret = -EINVAL;
284 	} else {
285 		for (i = 0; i < ARRAY_SIZE(user_key); i++)
286 			key[i] = cpu_to_le32(user_key[i]);
287 	}
288 	pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
289 		 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
290 
291 	return ret;
292 }
293 
294 static int proc_tcp_fastopen_key(const struct ctl_table *table, int write,
295 				 void *buffer, size_t *lenp, loff_t *ppos)
296 {
297 	struct net *net = container_of(table->data, struct net,
298 	    ipv4.sysctl_tcp_fastopen);
299 	/* maxlen to print the list of keys in hex (*2), with dashes
300 	 * separating doublewords and a comma in between keys.
301 	 */
302 	struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
303 					    2 * TCP_FASTOPEN_KEY_MAX) +
304 					    (TCP_FASTOPEN_KEY_MAX * 5)) };
305 	u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
306 	__le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
307 	char *backup_data;
308 	int ret, i = 0, off = 0, n_keys;
309 
310 	tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
311 	if (!tbl.data)
312 		return -ENOMEM;
313 
314 	n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
315 	if (!n_keys) {
316 		memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
317 		n_keys = 1;
318 	}
319 
320 	for (i = 0; i < n_keys * 4; i++)
321 		user_key[i] = le32_to_cpu(key[i]);
322 
323 	for (i = 0; i < n_keys; i++) {
324 		off += snprintf(tbl.data + off, tbl.maxlen - off,
325 				"%08x-%08x-%08x-%08x",
326 				user_key[i * 4],
327 				user_key[i * 4 + 1],
328 				user_key[i * 4 + 2],
329 				user_key[i * 4 + 3]);
330 
331 		if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
332 			break;
333 
334 		if (i + 1 < n_keys)
335 			off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
336 	}
337 
338 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
339 
340 	if (write && ret == 0) {
341 		backup_data = strchr(tbl.data, ',');
342 		if (backup_data) {
343 			*backup_data = '\0';
344 			backup_data++;
345 		}
346 		if (sscanf_key(tbl.data, key)) {
347 			ret = -EINVAL;
348 			goto bad_key;
349 		}
350 		if (backup_data) {
351 			if (sscanf_key(backup_data, key + 4)) {
352 				ret = -EINVAL;
353 				goto bad_key;
354 			}
355 		}
356 		tcp_fastopen_reset_cipher(net, NULL, key,
357 					  backup_data ? key + 4 : NULL);
358 	}
359 
360 bad_key:
361 	kfree(tbl.data);
362 	return ret;
363 }
364 
365 static int proc_tfo_blackhole_detect_timeout(const struct ctl_table *table,
366 					     int write, void *buffer,
367 					     size_t *lenp, loff_t *ppos)
368 {
369 	struct net *net = container_of(table->data, struct net,
370 	    ipv4.sysctl_tcp_fastopen_blackhole_timeout);
371 	int ret;
372 
373 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
374 	if (write && ret == 0)
375 		atomic_set(&net->ipv4.tfo_active_disable_times, 0);
376 
377 	return ret;
378 }
379 
380 static int proc_tcp_available_ulp(const struct ctl_table *ctl,
381 				  int write, void *buffer, size_t *lenp,
382 				  loff_t *ppos)
383 {
384 	struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
385 	int ret;
386 
387 	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
388 	if (!tbl.data)
389 		return -ENOMEM;
390 	tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
391 	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
392 	kfree(tbl.data);
393 
394 	return ret;
395 }
396 
397 static int proc_tcp_ehash_entries(const struct ctl_table *table, int write,
398 				  void *buffer, size_t *lenp, loff_t *ppos)
399 {
400 	struct net *net = container_of(table->data, struct net,
401 				       ipv4.sysctl_tcp_child_ehash_entries);
402 	struct inet_hashinfo *hinfo = net->ipv4.tcp_death_row.hashinfo;
403 	int tcp_ehash_entries;
404 	struct ctl_table tbl;
405 
406 	tcp_ehash_entries = hinfo->ehash_mask + 1;
407 
408 	/* A negative number indicates that the child netns
409 	 * shares the global ehash.
410 	 */
411 	if (!net_eq(net, &init_net) && !hinfo->pernet)
412 		tcp_ehash_entries *= -1;
413 
414 	memset(&tbl, 0, sizeof(tbl));
415 	tbl.data = &tcp_ehash_entries;
416 	tbl.maxlen = sizeof(int);
417 
418 	return proc_dointvec(&tbl, write, buffer, lenp, ppos);
419 }
420 
421 static int proc_udp_hash_entries(const struct ctl_table *table, int write,
422 				 void *buffer, size_t *lenp, loff_t *ppos)
423 {
424 	struct net *net = container_of(table->data, struct net,
425 				       ipv4.sysctl_udp_child_hash_entries);
426 	int udp_hash_entries;
427 	struct ctl_table tbl;
428 
429 	udp_hash_entries = net->ipv4.udp_table->mask + 1;
430 
431 	/* A negative number indicates that the child netns
432 	 * shares the global udp_table.
433 	 */
434 	if (!net_eq(net, &init_net) && net->ipv4.udp_table == &udp_table)
435 		udp_hash_entries *= -1;
436 
437 	memset(&tbl, 0, sizeof(tbl));
438 	tbl.data = &udp_hash_entries;
439 	tbl.maxlen = sizeof(int);
440 
441 	return proc_dointvec(&tbl, write, buffer, lenp, ppos);
442 }
443 
444 #ifdef CONFIG_IP_ROUTE_MULTIPATH
445 static int proc_fib_multipath_hash_policy(const struct ctl_table *table, int write,
446 					  void *buffer, size_t *lenp,
447 					  loff_t *ppos)
448 {
449 	struct net *net = container_of(table->data, struct net,
450 	    ipv4.sysctl_fib_multipath_hash_policy);
451 	int ret;
452 
453 	ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
454 	if (write && ret == 0)
455 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
456 
457 	return ret;
458 }
459 
460 static int proc_fib_multipath_hash_fields(const struct ctl_table *table, int write,
461 					  void *buffer, size_t *lenp,
462 					  loff_t *ppos)
463 {
464 	struct net *net;
465 	int ret;
466 
467 	net = container_of(table->data, struct net,
468 			   ipv4.sysctl_fib_multipath_hash_fields);
469 	ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
470 	if (write && ret == 0)
471 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
472 
473 	return ret;
474 }
475 
476 static u32 proc_fib_multipath_hash_rand_seed __ro_after_init;
477 
478 static void proc_fib_multipath_hash_init_rand_seed(void)
479 {
480 	get_random_bytes(&proc_fib_multipath_hash_rand_seed,
481 			 sizeof(proc_fib_multipath_hash_rand_seed));
482 }
483 
484 static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)
485 {
486 	struct sysctl_fib_multipath_hash_seed new = {
487 		.user_seed = user_seed,
488 		.mp_seed = (user_seed ? user_seed :
489 			    proc_fib_multipath_hash_rand_seed),
490 	};
491 
492 	WRITE_ONCE(net->ipv4.sysctl_fib_multipath_hash_seed.user_seed, new.user_seed);
493 	WRITE_ONCE(net->ipv4.sysctl_fib_multipath_hash_seed.mp_seed, new.mp_seed);
494 }
495 
496 static int proc_fib_multipath_hash_seed(const struct ctl_table *table, int write,
497 					void *buffer, size_t *lenp,
498 					loff_t *ppos)
499 {
500 	struct sysctl_fib_multipath_hash_seed *mphs;
501 	struct net *net = table->data;
502 	struct ctl_table tmp;
503 	u32 user_seed;
504 	int ret;
505 
506 	mphs = &net->ipv4.sysctl_fib_multipath_hash_seed;
507 	user_seed = READ_ONCE(mphs->user_seed);
508 
509 	tmp = *table;
510 	tmp.data = &user_seed;
511 
512 	ret = proc_douintvec_minmax(&tmp, write, buffer, lenp, ppos);
513 
514 	if (write && ret == 0) {
515 		proc_fib_multipath_hash_set_seed(net, user_seed);
516 		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
517 	}
518 
519 	return ret;
520 }
521 #else
522 
523 static void proc_fib_multipath_hash_init_rand_seed(void)
524 {
525 }
526 
527 static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)
528 {
529 }
530 
531 #endif
532 
533 static struct ctl_table ipv4_table[] = {
534 	{
535 		.procname	= "tcp_max_orphans",
536 		.data		= &sysctl_tcp_max_orphans,
537 		.maxlen		= sizeof(int),
538 		.mode		= 0644,
539 		.proc_handler	= proc_dointvec
540 	},
541 	{
542 		.procname	= "inet_peer_threshold",
543 		.data		= &inet_peer_threshold,
544 		.maxlen		= sizeof(int),
545 		.mode		= 0644,
546 		.proc_handler	= proc_dointvec
547 	},
548 	{
549 		.procname	= "inet_peer_minttl",
550 		.data		= &inet_peer_minttl,
551 		.maxlen		= sizeof(int),
552 		.mode		= 0644,
553 		.proc_handler	= proc_dointvec_jiffies,
554 	},
555 	{
556 		.procname	= "inet_peer_maxttl",
557 		.data		= &inet_peer_maxttl,
558 		.maxlen		= sizeof(int),
559 		.mode		= 0644,
560 		.proc_handler	= proc_dointvec_jiffies,
561 	},
562 	{
563 		.procname	= "tcp_mem",
564 		.maxlen		= sizeof(sysctl_tcp_mem),
565 		.data		= &sysctl_tcp_mem,
566 		.mode		= 0644,
567 		.proc_handler	= proc_doulongvec_minmax,
568 	},
569 	{
570 		.procname	= "tcp_low_latency",
571 		.data		= &sysctl_tcp_low_latency,
572 		.maxlen		= sizeof(int),
573 		.mode		= 0644,
574 		.proc_handler	= proc_dointvec
575 	},
576 #ifdef CONFIG_NETLABEL
577 	{
578 		.procname	= "cipso_cache_enable",
579 		.data		= &cipso_v4_cache_enabled,
580 		.maxlen		= sizeof(int),
581 		.mode		= 0644,
582 		.proc_handler	= proc_dointvec,
583 	},
584 	{
585 		.procname	= "cipso_cache_bucket_size",
586 		.data		= &cipso_v4_cache_bucketsize,
587 		.maxlen		= sizeof(int),
588 		.mode		= 0644,
589 		.proc_handler	= proc_dointvec,
590 	},
591 	{
592 		.procname	= "cipso_rbm_optfmt",
593 		.data		= &cipso_v4_rbm_optfmt,
594 		.maxlen		= sizeof(int),
595 		.mode		= 0644,
596 		.proc_handler	= proc_dointvec,
597 	},
598 	{
599 		.procname	= "cipso_rbm_strictvalid",
600 		.data		= &cipso_v4_rbm_strictvalid,
601 		.maxlen		= sizeof(int),
602 		.mode		= 0644,
603 		.proc_handler	= proc_dointvec,
604 	},
605 #endif /* CONFIG_NETLABEL */
606 	{
607 		.procname	= "tcp_available_ulp",
608 		.maxlen		= TCP_ULP_BUF_MAX,
609 		.mode		= 0444,
610 		.proc_handler   = proc_tcp_available_ulp,
611 	},
612 	{
613 		.procname	= "udp_mem",
614 		.data		= &sysctl_udp_mem,
615 		.maxlen		= sizeof(sysctl_udp_mem),
616 		.mode		= 0644,
617 		.proc_handler	= proc_doulongvec_minmax,
618 	},
619 	{
620 		.procname	= "fib_sync_mem",
621 		.data		= &sysctl_fib_sync_mem,
622 		.maxlen		= sizeof(sysctl_fib_sync_mem),
623 		.mode		= 0644,
624 		.proc_handler	= proc_douintvec_minmax,
625 		.extra1		= &sysctl_fib_sync_mem_min,
626 		.extra2		= &sysctl_fib_sync_mem_max,
627 	},
628 };
629 
630 static const struct ctl_table ipv4_net_table[] = {
631 	{
632 		.procname	= "tcp_max_tw_buckets",
633 		.data		= &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
634 		.maxlen		= sizeof(int),
635 		.mode		= 0644,
636 		.proc_handler	= proc_dointvec
637 	},
638 	{
639 		.procname	= "icmp_echo_ignore_all",
640 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_all,
641 		.maxlen		= sizeof(u8),
642 		.mode		= 0644,
643 		.proc_handler	= proc_dou8vec_minmax,
644 		.extra1		= SYSCTL_ZERO,
645 		.extra2		= SYSCTL_ONE
646 	},
647 	{
648 		.procname	= "icmp_echo_enable_probe",
649 		.data		= &init_net.ipv4.sysctl_icmp_echo_enable_probe,
650 		.maxlen		= sizeof(u8),
651 		.mode		= 0644,
652 		.proc_handler	= proc_dou8vec_minmax,
653 		.extra1		= SYSCTL_ZERO,
654 		.extra2		= SYSCTL_ONE
655 	},
656 	{
657 		.procname	= "icmp_echo_ignore_broadcasts",
658 		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
659 		.maxlen		= sizeof(u8),
660 		.mode		= 0644,
661 		.proc_handler	= proc_dou8vec_minmax,
662 		.extra1		= SYSCTL_ZERO,
663 		.extra2		= SYSCTL_ONE
664 	},
665 	{
666 		.procname	= "icmp_ignore_bogus_error_responses",
667 		.data		= &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
668 		.maxlen		= sizeof(u8),
669 		.mode		= 0644,
670 		.proc_handler	= proc_dou8vec_minmax,
671 		.extra1		= SYSCTL_ZERO,
672 		.extra2		= SYSCTL_ONE
673 	},
674 	{
675 		.procname	= "icmp_errors_use_inbound_ifaddr",
676 		.data		= &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
677 		.maxlen		= sizeof(u8),
678 		.mode		= 0644,
679 		.proc_handler	= proc_dou8vec_minmax,
680 		.extra1		= SYSCTL_ZERO,
681 		.extra2		= SYSCTL_ONE
682 	},
683 	{
684 		.procname	= "icmp_errors_extension_mask",
685 		.data		= &init_net.ipv4.sysctl_icmp_errors_extension_mask,
686 		.maxlen		= sizeof(u8),
687 		.mode		= 0644,
688 		.proc_handler	= proc_dou8vec_minmax,
689 		.extra1		= SYSCTL_ZERO,
690 		.extra2		= &icmp_errors_extension_mask_all,
691 	},
692 	{
693 		.procname	= "icmp_ratelimit",
694 		.data		= &init_net.ipv4.sysctl_icmp_ratelimit,
695 		.maxlen		= sizeof(int),
696 		.mode		= 0644,
697 		.proc_handler	= proc_dointvec_ms_jiffies,
698 	},
699 	{
700 		.procname	= "icmp_ratemask",
701 		.data		= &init_net.ipv4.sysctl_icmp_ratemask,
702 		.maxlen		= sizeof(int),
703 		.mode		= 0644,
704 		.proc_handler	= proc_dointvec
705 	},
706 	{
707 		.procname	= "icmp_msgs_per_sec",
708 		.data		= &init_net.ipv4.sysctl_icmp_msgs_per_sec,
709 		.maxlen		= sizeof(int),
710 		.mode		= 0644,
711 		.proc_handler	= proc_dointvec_minmax,
712 		.extra1		= SYSCTL_ZERO,
713 	},
714 	{
715 		.procname	= "icmp_msgs_burst",
716 		.data		= &init_net.ipv4.sysctl_icmp_msgs_burst,
717 		.maxlen		= sizeof(int),
718 		.mode		= 0644,
719 		.proc_handler	= proc_dointvec_minmax,
720 		.extra1		= SYSCTL_ZERO,
721 	},
722 	{
723 		.procname	= "ping_group_range",
724 		.data		= &init_net.ipv4.ping_group_range.range,
725 		.maxlen		= sizeof(gid_t)*2,
726 		.mode		= 0644,
727 		.proc_handler	= ipv4_ping_group_range,
728 	},
729 #ifdef CONFIG_NET_L3_MASTER_DEV
730 	{
731 		.procname	= "raw_l3mdev_accept",
732 		.data		= &init_net.ipv4.sysctl_raw_l3mdev_accept,
733 		.maxlen		= sizeof(u8),
734 		.mode		= 0644,
735 		.proc_handler	= proc_dou8vec_minmax,
736 		.extra1		= SYSCTL_ZERO,
737 		.extra2		= SYSCTL_ONE,
738 	},
739 #endif
740 	{
741 		.procname	= "tcp_ecn",
742 		.data		= &init_net.ipv4.sysctl_tcp_ecn,
743 		.maxlen		= sizeof(u8),
744 		.mode		= 0644,
745 		.proc_handler	= proc_dou8vec_minmax,
746 		.extra1		= SYSCTL_ZERO,
747 		.extra2		= &tcp_ecn_mode_max,
748 	},
749 	{
750 		.procname	= "tcp_ecn_option",
751 		.data		= &init_net.ipv4.sysctl_tcp_ecn_option,
752 		.maxlen		= sizeof(u8),
753 		.mode		= 0644,
754 		.proc_handler	= proc_dou8vec_minmax,
755 		.extra1		= SYSCTL_ZERO,
756 		.extra2		= SYSCTL_THREE,
757 	},
758 	{
759 		.procname	= "tcp_ecn_option_beacon",
760 		.data		= &init_net.ipv4.sysctl_tcp_ecn_option_beacon,
761 		.maxlen		= sizeof(u8),
762 		.mode		= 0644,
763 		.proc_handler	= proc_dou8vec_minmax,
764 		.extra1		= SYSCTL_ZERO,
765 		.extra2		= SYSCTL_THREE,
766 	},
767 	{
768 		.procname	= "tcp_ecn_fallback",
769 		.data		= &init_net.ipv4.sysctl_tcp_ecn_fallback,
770 		.maxlen		= sizeof(u8),
771 		.mode		= 0644,
772 		.proc_handler	= proc_dou8vec_minmax,
773 		.extra1		= SYSCTL_ZERO,
774 		.extra2		= SYSCTL_ONE,
775 	},
776 	{
777 		.procname	= "ip_dynaddr",
778 		.data		= &init_net.ipv4.sysctl_ip_dynaddr,
779 		.maxlen		= sizeof(u8),
780 		.mode		= 0644,
781 		.proc_handler	= proc_dou8vec_minmax,
782 	},
783 	{
784 		.procname	= "ip_early_demux",
785 		.data		= &init_net.ipv4.sysctl_ip_early_demux,
786 		.maxlen		= sizeof(u8),
787 		.mode		= 0644,
788 		.proc_handler	= proc_dou8vec_minmax,
789 	},
790 	{
791 		.procname       = "udp_early_demux",
792 		.data           = &init_net.ipv4.sysctl_udp_early_demux,
793 		.maxlen         = sizeof(u8),
794 		.mode           = 0644,
795 		.proc_handler   = proc_dou8vec_minmax,
796 	},
797 	{
798 		.procname       = "tcp_early_demux",
799 		.data           = &init_net.ipv4.sysctl_tcp_early_demux,
800 		.maxlen         = sizeof(u8),
801 		.mode           = 0644,
802 		.proc_handler   = proc_dou8vec_minmax,
803 	},
804 	{
805 		.procname       = "nexthop_compat_mode",
806 		.data           = &init_net.ipv4.sysctl_nexthop_compat_mode,
807 		.maxlen         = sizeof(u8),
808 		.mode           = 0644,
809 		.proc_handler   = proc_dou8vec_minmax,
810 		.extra1		= SYSCTL_ZERO,
811 		.extra2		= SYSCTL_ONE,
812 	},
813 	{
814 		.procname	= "ip_default_ttl",
815 		.data		= &init_net.ipv4.sysctl_ip_default_ttl,
816 		.maxlen		= sizeof(u8),
817 		.mode		= 0644,
818 		.proc_handler	= proc_dou8vec_minmax,
819 		.extra1		= &ip_ttl_min,
820 		.extra2		= &ip_ttl_max,
821 	},
822 	{
823 		.procname	= "ip_local_port_range",
824 		.maxlen		= 0,
825 		.data		= &init_net,
826 		.mode		= 0644,
827 		.proc_handler	= ipv4_local_port_range,
828 	},
829 	{
830 		.procname	= "ip_local_port_step_width",
831 		.maxlen		= sizeof(u32),
832 		.data		= &init_net.ipv4.sysctl_ip_local_port_step_width,
833 		.mode		= 0644,
834 		.proc_handler	= proc_douintvec,
835 	},
836 	{
837 		.procname	= "ip_local_reserved_ports",
838 		.data		= &init_net.ipv4.sysctl_local_reserved_ports,
839 		.maxlen		= 65536,
840 		.mode		= 0644,
841 		.proc_handler	= proc_do_large_bitmap,
842 	},
843 	{
844 		.procname	= "ip_no_pmtu_disc",
845 		.data		= &init_net.ipv4.sysctl_ip_no_pmtu_disc,
846 		.maxlen		= sizeof(u8),
847 		.mode		= 0644,
848 		.proc_handler	= proc_dou8vec_minmax,
849 	},
850 	{
851 		.procname	= "ip_forward_use_pmtu",
852 		.data		= &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
853 		.maxlen		= sizeof(u8),
854 		.mode		= 0644,
855 		.proc_handler	= proc_dou8vec_minmax,
856 	},
857 	{
858 		.procname	= "ip_forward_update_priority",
859 		.data		= &init_net.ipv4.sysctl_ip_fwd_update_priority,
860 		.maxlen		= sizeof(u8),
861 		.mode		= 0644,
862 		.proc_handler   = ipv4_fwd_update_priority,
863 		.extra1		= SYSCTL_ZERO,
864 		.extra2		= SYSCTL_ONE,
865 	},
866 	{
867 		.procname	= "ip_nonlocal_bind",
868 		.data		= &init_net.ipv4.sysctl_ip_nonlocal_bind,
869 		.maxlen		= sizeof(u8),
870 		.mode		= 0644,
871 		.proc_handler	= proc_dou8vec_minmax,
872 	},
873 	{
874 		.procname	= "ip_autobind_reuse",
875 		.data		= &init_net.ipv4.sysctl_ip_autobind_reuse,
876 		.maxlen		= sizeof(u8),
877 		.mode		= 0644,
878 		.proc_handler	= proc_dou8vec_minmax,
879 		.extra1         = SYSCTL_ZERO,
880 		.extra2         = SYSCTL_ONE,
881 	},
882 	{
883 		.procname	= "fwmark_reflect",
884 		.data		= &init_net.ipv4.sysctl_fwmark_reflect,
885 		.maxlen		= sizeof(u8),
886 		.mode		= 0644,
887 		.proc_handler	= proc_dou8vec_minmax,
888 	},
889 	{
890 		.procname	= "tcp_fwmark_accept",
891 		.data		= &init_net.ipv4.sysctl_tcp_fwmark_accept,
892 		.maxlen		= sizeof(u8),
893 		.mode		= 0644,
894 		.proc_handler	= proc_dou8vec_minmax,
895 	},
896 #ifdef CONFIG_NET_L3_MASTER_DEV
897 	{
898 		.procname	= "tcp_l3mdev_accept",
899 		.data		= &init_net.ipv4.sysctl_tcp_l3mdev_accept,
900 		.maxlen		= sizeof(u8),
901 		.mode		= 0644,
902 		.proc_handler	= proc_dou8vec_minmax,
903 		.extra1		= SYSCTL_ZERO,
904 		.extra2		= SYSCTL_ONE,
905 	},
906 #endif
907 	{
908 		.procname	= "tcp_mtu_probing",
909 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probing,
910 		.maxlen		= sizeof(u8),
911 		.mode		= 0644,
912 		.proc_handler	= proc_dou8vec_minmax,
913 	},
914 	{
915 		.procname	= "tcp_base_mss",
916 		.data		= &init_net.ipv4.sysctl_tcp_base_mss,
917 		.maxlen		= sizeof(int),
918 		.mode		= 0644,
919 		.proc_handler	= proc_dointvec,
920 	},
921 	{
922 		.procname	= "tcp_min_snd_mss",
923 		.data		= &init_net.ipv4.sysctl_tcp_min_snd_mss,
924 		.maxlen		= sizeof(int),
925 		.mode		= 0644,
926 		.proc_handler	= proc_dointvec_minmax,
927 		.extra1		= &tcp_min_snd_mss_min,
928 		.extra2		= &tcp_min_snd_mss_max,
929 	},
930 	{
931 		.procname	= "tcp_mtu_probe_floor",
932 		.data		= &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
933 		.maxlen		= sizeof(int),
934 		.mode		= 0644,
935 		.proc_handler	= proc_dointvec_minmax,
936 		.extra1		= &tcp_min_snd_mss_min,
937 		.extra2		= &tcp_min_snd_mss_max,
938 	},
939 	{
940 		.procname	= "tcp_probe_threshold",
941 		.data		= &init_net.ipv4.sysctl_tcp_probe_threshold,
942 		.maxlen		= sizeof(int),
943 		.mode		= 0644,
944 		.proc_handler	= proc_dointvec,
945 	},
946 	{
947 		.procname	= "tcp_probe_interval",
948 		.data		= &init_net.ipv4.sysctl_tcp_probe_interval,
949 		.maxlen		= sizeof(u32),
950 		.mode		= 0644,
951 		.proc_handler	= proc_douintvec_minmax,
952 		.extra2		= &u32_max_div_HZ,
953 	},
954 	{
955 		.procname	= "igmp_link_local_mcast_reports",
956 		.data		= &init_net.ipv4.sysctl_igmp_llm_reports,
957 		.maxlen		= sizeof(u8),
958 		.mode		= 0644,
959 		.proc_handler	= proc_dou8vec_minmax,
960 	},
961 	{
962 		.procname	= "igmp_max_memberships",
963 		.data		= &init_net.ipv4.sysctl_igmp_max_memberships,
964 		.maxlen		= sizeof(int),
965 		.mode		= 0644,
966 		.proc_handler	= proc_dointvec
967 	},
968 	{
969 		.procname	= "igmp_max_msf",
970 		.data		= &init_net.ipv4.sysctl_igmp_max_msf,
971 		.maxlen		= sizeof(int),
972 		.mode		= 0644,
973 		.proc_handler	= proc_dointvec
974 	},
975 #ifdef CONFIG_IP_MULTICAST
976 	{
977 		.procname	= "igmp_qrv",
978 		.data		= &init_net.ipv4.sysctl_igmp_qrv,
979 		.maxlen		= sizeof(int),
980 		.mode		= 0644,
981 		.proc_handler	= proc_dointvec_minmax,
982 		.extra1		= SYSCTL_ONE
983 	},
984 #endif
985 	{
986 		.procname	= "tcp_congestion_control",
987 		.data		= &init_net.ipv4.tcp_congestion_control,
988 		.mode		= 0644,
989 		.maxlen		= TCP_CA_NAME_MAX,
990 		.proc_handler	= proc_tcp_congestion_control,
991 	},
992 	{
993 		.procname	= "tcp_available_congestion_control",
994 		.maxlen		= TCP_CA_BUF_MAX,
995 		.mode		= 0444,
996 		.proc_handler   = proc_tcp_available_congestion_control,
997 	},
998 	{
999 		.procname	= "tcp_allowed_congestion_control",
1000 		.maxlen		= TCP_CA_BUF_MAX,
1001 		.mode		= 0644,
1002 		.proc_handler   = proc_allowed_congestion_control,
1003 	},
1004 	{
1005 		.procname	= "tcp_keepalive_time",
1006 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_time,
1007 		.maxlen		= sizeof(int),
1008 		.mode		= 0644,
1009 		.proc_handler	= proc_dointvec_jiffies,
1010 	},
1011 	{
1012 		.procname	= "tcp_keepalive_probes",
1013 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_probes,
1014 		.maxlen		= sizeof(u8),
1015 		.mode		= 0644,
1016 		.proc_handler	= proc_dou8vec_minmax,
1017 	},
1018 	{
1019 		.procname	= "tcp_keepalive_intvl",
1020 		.data		= &init_net.ipv4.sysctl_tcp_keepalive_intvl,
1021 		.maxlen		= sizeof(int),
1022 		.mode		= 0644,
1023 		.proc_handler	= proc_dointvec_jiffies,
1024 	},
1025 	{
1026 		.procname	= "tcp_syn_retries",
1027 		.data		= &init_net.ipv4.sysctl_tcp_syn_retries,
1028 		.maxlen		= sizeof(u8),
1029 		.mode		= 0644,
1030 		.proc_handler	= proc_dou8vec_minmax,
1031 		.extra1		= &tcp_syn_retries_min,
1032 		.extra2		= &tcp_syn_retries_max
1033 	},
1034 	{
1035 		.procname	= "tcp_synack_retries",
1036 		.data		= &init_net.ipv4.sysctl_tcp_synack_retries,
1037 		.maxlen		= sizeof(u8),
1038 		.mode		= 0644,
1039 		.proc_handler	= proc_dou8vec_minmax,
1040 	},
1041 #ifdef CONFIG_SYN_COOKIES
1042 	{
1043 		.procname	= "tcp_syncookies",
1044 		.data		= &init_net.ipv4.sysctl_tcp_syncookies,
1045 		.maxlen		= sizeof(u8),
1046 		.mode		= 0644,
1047 		.proc_handler	= proc_dou8vec_minmax,
1048 	},
1049 #endif
1050 	{
1051 		.procname	= "tcp_migrate_req",
1052 		.data		= &init_net.ipv4.sysctl_tcp_migrate_req,
1053 		.maxlen		= sizeof(u8),
1054 		.mode		= 0644,
1055 		.proc_handler	= proc_dou8vec_minmax,
1056 		.extra1		= SYSCTL_ZERO,
1057 		.extra2		= SYSCTL_ONE
1058 	},
1059 	{
1060 		.procname	= "tcp_reordering",
1061 		.data		= &init_net.ipv4.sysctl_tcp_reordering,
1062 		.maxlen		= sizeof(int),
1063 		.mode		= 0644,
1064 		.proc_handler	= proc_dointvec_minmax,
1065 		.extra1		= SYSCTL_ONE,
1066 		.extra2		= &init_net.ipv4.sysctl_tcp_max_reordering,
1067 	},
1068 	{
1069 		.procname	= "tcp_retries1",
1070 		.data		= &init_net.ipv4.sysctl_tcp_retries1,
1071 		.maxlen		= sizeof(u8),
1072 		.mode		= 0644,
1073 		.proc_handler	= proc_dou8vec_minmax,
1074 		.extra2		= &tcp_retr1_max
1075 	},
1076 	{
1077 		.procname	= "tcp_retries2",
1078 		.data		= &init_net.ipv4.sysctl_tcp_retries2,
1079 		.maxlen		= sizeof(u8),
1080 		.mode		= 0644,
1081 		.proc_handler	= proc_dou8vec_minmax,
1082 	},
1083 	{
1084 		.procname	= "tcp_orphan_retries",
1085 		.data		= &init_net.ipv4.sysctl_tcp_orphan_retries,
1086 		.maxlen		= sizeof(u8),
1087 		.mode		= 0644,
1088 		.proc_handler	= proc_dou8vec_minmax,
1089 	},
1090 	{
1091 		.procname	= "tcp_fin_timeout",
1092 		.data		= &init_net.ipv4.sysctl_tcp_fin_timeout,
1093 		.maxlen		= sizeof(int),
1094 		.mode		= 0644,
1095 		.proc_handler	= proc_dointvec_jiffies,
1096 	},
1097 	{
1098 		.procname	= "tcp_notsent_lowat",
1099 		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
1100 		.maxlen		= sizeof(unsigned int),
1101 		.mode		= 0644,
1102 		.proc_handler	= proc_douintvec,
1103 	},
1104 	{
1105 		.procname	= "tcp_tw_reuse",
1106 		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse,
1107 		.maxlen		= sizeof(u8),
1108 		.mode		= 0644,
1109 		.proc_handler	= proc_dou8vec_minmax,
1110 		.extra1		= SYSCTL_ZERO,
1111 		.extra2		= SYSCTL_TWO,
1112 	},
1113 	{
1114 		.procname	= "tcp_tw_reuse_delay",
1115 		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse_delay,
1116 		.maxlen		= sizeof(unsigned int),
1117 		.mode		= 0644,
1118 		.proc_handler	= proc_douintvec_minmax,
1119 		.extra1		= SYSCTL_ONE,
1120 		.extra2		= &tcp_tw_reuse_delay_max,
1121 	},
1122 	{
1123 		.procname	= "tcp_max_syn_backlog",
1124 		.data		= &init_net.ipv4.sysctl_max_syn_backlog,
1125 		.maxlen		= sizeof(int),
1126 		.mode		= 0644,
1127 		.proc_handler	= proc_dointvec
1128 	},
1129 	{
1130 		.procname	= "tcp_fastopen",
1131 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1132 		.maxlen		= sizeof(int),
1133 		.mode		= 0644,
1134 		.proc_handler	= proc_dointvec,
1135 	},
1136 	{
1137 		.procname	= "tcp_fastopen_key",
1138 		.mode		= 0600,
1139 		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
1140 		/* maxlen to print the list of keys in hex (*2), with dashes
1141 		 * separating doublewords and a comma in between keys.
1142 		 */
1143 		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH *
1144 				   2 * TCP_FASTOPEN_KEY_MAX) +
1145 				   (TCP_FASTOPEN_KEY_MAX * 5)),
1146 		.proc_handler	= proc_tcp_fastopen_key,
1147 	},
1148 	{
1149 		.procname	= "tcp_fastopen_blackhole_timeout_sec",
1150 		.data		= &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1151 		.maxlen		= sizeof(int),
1152 		.mode		= 0644,
1153 		.proc_handler	= proc_tfo_blackhole_detect_timeout,
1154 		.extra1		= SYSCTL_ZERO,
1155 	},
1156 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1157 	{
1158 		.procname	= "fib_multipath_use_neigh",
1159 		.data		= &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1160 		.maxlen		= sizeof(u8),
1161 		.mode		= 0644,
1162 		.proc_handler	= proc_dou8vec_minmax,
1163 		.extra1		= SYSCTL_ZERO,
1164 		.extra2		= SYSCTL_ONE,
1165 	},
1166 	{
1167 		.procname	= "fib_multipath_hash_policy",
1168 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1169 		.maxlen		= sizeof(u8),
1170 		.mode		= 0644,
1171 		.proc_handler	= proc_fib_multipath_hash_policy,
1172 		.extra1		= SYSCTL_ZERO,
1173 		.extra2		= SYSCTL_THREE,
1174 	},
1175 	{
1176 		.procname	= "fib_multipath_hash_fields",
1177 		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_fields,
1178 		.maxlen		= sizeof(u32),
1179 		.mode		= 0644,
1180 		.proc_handler	= proc_fib_multipath_hash_fields,
1181 		.extra1		= SYSCTL_ONE,
1182 		.extra2		= &fib_multipath_hash_fields_all_mask,
1183 	},
1184 	{
1185 		.procname	= "fib_multipath_hash_seed",
1186 		.data		= &init_net,
1187 		.maxlen		= sizeof(u32),
1188 		.mode		= 0644,
1189 		.proc_handler	= proc_fib_multipath_hash_seed,
1190 	},
1191 #endif
1192 	{
1193 		.procname	= "ip_unprivileged_port_start",
1194 		.maxlen		= sizeof(int),
1195 		.data		= &init_net.ipv4.sysctl_ip_prot_sock,
1196 		.mode		= 0644,
1197 		.proc_handler	= ipv4_privileged_ports,
1198 	},
1199 #ifdef CONFIG_NET_L3_MASTER_DEV
1200 	{
1201 		.procname	= "udp_l3mdev_accept",
1202 		.data		= &init_net.ipv4.sysctl_udp_l3mdev_accept,
1203 		.maxlen		= sizeof(u8),
1204 		.mode		= 0644,
1205 		.proc_handler	= proc_dou8vec_minmax,
1206 		.extra1		= SYSCTL_ZERO,
1207 		.extra2		= SYSCTL_ONE,
1208 	},
1209 #endif
1210 	{
1211 		.procname	= "tcp_sack",
1212 		.data		= &init_net.ipv4.sysctl_tcp_sack,
1213 		.maxlen		= sizeof(u8),
1214 		.mode		= 0644,
1215 		.proc_handler	= proc_dou8vec_minmax,
1216 	},
1217 	{
1218 		.procname	= "tcp_window_scaling",
1219 		.data		= &init_net.ipv4.sysctl_tcp_window_scaling,
1220 		.maxlen		= sizeof(u8),
1221 		.mode		= 0644,
1222 		.proc_handler	= proc_dou8vec_minmax,
1223 	},
1224 	{
1225 		.procname	= "tcp_timestamps",
1226 		.data		= &init_net.ipv4.sysctl_tcp_timestamps,
1227 		.maxlen		= sizeof(u8),
1228 		.mode		= 0644,
1229 		.proc_handler	= proc_dou8vec_minmax,
1230 	},
1231 	{
1232 		.procname	= "tcp_early_retrans",
1233 		.data		= &init_net.ipv4.sysctl_tcp_early_retrans,
1234 		.maxlen		= sizeof(u8),
1235 		.mode		= 0644,
1236 		.proc_handler	= proc_dou8vec_minmax,
1237 		.extra1		= SYSCTL_ZERO,
1238 		.extra2		= SYSCTL_FOUR,
1239 	},
1240 	{
1241 		.procname	= "tcp_recovery",
1242 		.data		= &init_net.ipv4.sysctl_tcp_recovery,
1243 		.maxlen		= sizeof(u8),
1244 		.mode		= 0644,
1245 		.proc_handler	= proc_dou8vec_minmax,
1246 	},
1247 	{
1248 		.procname       = "tcp_thin_linear_timeouts",
1249 		.data           = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1250 		.maxlen         = sizeof(u8),
1251 		.mode           = 0644,
1252 		.proc_handler   = proc_dou8vec_minmax,
1253 	},
1254 	{
1255 		.procname	= "tcp_slow_start_after_idle",
1256 		.data		= &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1257 		.maxlen		= sizeof(u8),
1258 		.mode		= 0644,
1259 		.proc_handler	= proc_dou8vec_minmax,
1260 	},
1261 	{
1262 		.procname	= "tcp_retrans_collapse",
1263 		.data		= &init_net.ipv4.sysctl_tcp_retrans_collapse,
1264 		.maxlen		= sizeof(u8),
1265 		.mode		= 0644,
1266 		.proc_handler	= proc_dou8vec_minmax,
1267 	},
1268 	{
1269 		.procname	= "tcp_stdurg",
1270 		.data		= &init_net.ipv4.sysctl_tcp_stdurg,
1271 		.maxlen		= sizeof(u8),
1272 		.mode		= 0644,
1273 		.proc_handler	= proc_dou8vec_minmax,
1274 	},
1275 	{
1276 		.procname	= "tcp_rfc1337",
1277 		.data		= &init_net.ipv4.sysctl_tcp_rfc1337,
1278 		.maxlen		= sizeof(u8),
1279 		.mode		= 0644,
1280 		.proc_handler	= proc_dou8vec_minmax,
1281 	},
1282 	{
1283 		.procname	= "tcp_abort_on_overflow",
1284 		.data		= &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1285 		.maxlen		= sizeof(u8),
1286 		.mode		= 0644,
1287 		.proc_handler	= proc_dou8vec_minmax,
1288 	},
1289 	{
1290 		.procname	= "tcp_fack",
1291 		.data		= &init_net.ipv4.sysctl_tcp_fack,
1292 		.maxlen		= sizeof(u8),
1293 		.mode		= 0644,
1294 		.proc_handler	= proc_dou8vec_minmax,
1295 	},
1296 	{
1297 		.procname	= "tcp_max_reordering",
1298 		.data		= &init_net.ipv4.sysctl_tcp_max_reordering,
1299 		.maxlen		= sizeof(int),
1300 		.mode		= 0644,
1301 		.proc_handler	= proc_dointvec_minmax,
1302 		.extra1		= SYSCTL_ONE,
1303 	},
1304 	{
1305 		.procname	= "tcp_dsack",
1306 		.data		= &init_net.ipv4.sysctl_tcp_dsack,
1307 		.maxlen		= sizeof(u8),
1308 		.mode		= 0644,
1309 		.proc_handler	= proc_dou8vec_minmax,
1310 	},
1311 	{
1312 		.procname	= "tcp_app_win",
1313 		.data		= &init_net.ipv4.sysctl_tcp_app_win,
1314 		.maxlen		= sizeof(u8),
1315 		.mode		= 0644,
1316 		.proc_handler	= proc_dou8vec_minmax,
1317 		.extra1		= SYSCTL_ZERO,
1318 		.extra2		= &tcp_app_win_max,
1319 	},
1320 	{
1321 		.procname	= "tcp_adv_win_scale",
1322 		.data		= &init_net.ipv4.sysctl_tcp_adv_win_scale,
1323 		.maxlen		= sizeof(int),
1324 		.mode		= 0644,
1325 		.proc_handler	= proc_dointvec_minmax,
1326 		.extra1		= &tcp_adv_win_scale_min,
1327 		.extra2		= &tcp_adv_win_scale_max,
1328 	},
1329 	{
1330 		.procname	= "tcp_frto",
1331 		.data		= &init_net.ipv4.sysctl_tcp_frto,
1332 		.maxlen		= sizeof(u8),
1333 		.mode		= 0644,
1334 		.proc_handler	= proc_dou8vec_minmax,
1335 	},
1336 	{
1337 		.procname	= "tcp_no_metrics_save",
1338 		.data		= &init_net.ipv4.sysctl_tcp_nometrics_save,
1339 		.maxlen		= sizeof(u8),
1340 		.mode		= 0644,
1341 		.proc_handler	= proc_dou8vec_minmax,
1342 	},
1343 	{
1344 		.procname	= "tcp_no_ssthresh_metrics_save",
1345 		.data		= &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1346 		.maxlen		= sizeof(u8),
1347 		.mode		= 0644,
1348 		.proc_handler	= proc_dou8vec_minmax,
1349 		.extra1		= SYSCTL_ZERO,
1350 		.extra2		= SYSCTL_ONE,
1351 	},
1352 	{
1353 		.procname	= "tcp_moderate_rcvbuf",
1354 		.data		= &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1355 		.maxlen		= sizeof(u8),
1356 		.mode		= 0644,
1357 		.proc_handler	= proc_dou8vec_minmax,
1358 	},
1359 	{
1360 		.procname	= "tcp_rcvbuf_low_rtt",
1361 		.data		= &init_net.ipv4.sysctl_tcp_rcvbuf_low_rtt,
1362 		.maxlen		= sizeof(int),
1363 		.mode		= 0644,
1364 		.proc_handler	= proc_dointvec_minmax,
1365 		.extra1		= SYSCTL_ZERO,
1366 		.extra2		= SYSCTL_INT_MAX,
1367 	},
1368 	{
1369 		.procname	= "tcp_tso_win_divisor",
1370 		.data		= &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1371 		.maxlen		= sizeof(u8),
1372 		.mode		= 0644,
1373 		.proc_handler	= proc_dou8vec_minmax,
1374 	},
1375 	{
1376 		.procname	= "tcp_workaround_signed_windows",
1377 		.data		= &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1378 		.maxlen		= sizeof(u8),
1379 		.mode		= 0644,
1380 		.proc_handler	= proc_dou8vec_minmax,
1381 	},
1382 	{
1383 		.procname	= "tcp_limit_output_bytes",
1384 		.data		= &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1385 		.maxlen		= sizeof(int),
1386 		.mode		= 0644,
1387 		.proc_handler	= proc_dointvec
1388 	},
1389 	{
1390 		.procname	= "tcp_challenge_ack_limit",
1391 		.data		= &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1392 		.maxlen		= sizeof(int),
1393 		.mode		= 0644,
1394 		.proc_handler	= proc_dointvec
1395 	},
1396 	{
1397 		.procname	= "tcp_min_tso_segs",
1398 		.data		= &init_net.ipv4.sysctl_tcp_min_tso_segs,
1399 		.maxlen		= sizeof(u8),
1400 		.mode		= 0644,
1401 		.proc_handler	= proc_dou8vec_minmax,
1402 		.extra1		= SYSCTL_ONE,
1403 	},
1404 	{
1405 		.procname	= "tcp_tso_rtt_log",
1406 		.data		= &init_net.ipv4.sysctl_tcp_tso_rtt_log,
1407 		.maxlen		= sizeof(u8),
1408 		.mode		= 0644,
1409 		.proc_handler	= proc_dou8vec_minmax,
1410 		.extra2		= &tcp_tso_rtt_log_max,
1411 	},
1412 	{
1413 		.procname	= "tcp_min_rtt_wlen",
1414 		.data		= &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1415 		.maxlen		= sizeof(int),
1416 		.mode		= 0644,
1417 		.proc_handler	= proc_dointvec_minmax,
1418 		.extra1		= SYSCTL_ZERO,
1419 		.extra2		= &one_day_secs
1420 	},
1421 	{
1422 		.procname	= "tcp_autocorking",
1423 		.data		= &init_net.ipv4.sysctl_tcp_autocorking,
1424 		.maxlen		= sizeof(u8),
1425 		.mode		= 0644,
1426 		.proc_handler	= proc_dou8vec_minmax,
1427 		.extra1		= SYSCTL_ZERO,
1428 		.extra2		= SYSCTL_ONE,
1429 	},
1430 	{
1431 		.procname	= "tcp_invalid_ratelimit",
1432 		.data		= &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1433 		.maxlen		= sizeof(int),
1434 		.mode		= 0644,
1435 		.proc_handler	= proc_dointvec_ms_jiffies,
1436 	},
1437 	{
1438 		.procname	= "tcp_pacing_ss_ratio",
1439 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1440 		.maxlen		= sizeof(int),
1441 		.mode		= 0644,
1442 		.proc_handler	= proc_dointvec_minmax,
1443 		.extra1		= SYSCTL_ZERO,
1444 		.extra2		= SYSCTL_ONE_THOUSAND,
1445 	},
1446 	{
1447 		.procname	= "tcp_pacing_ca_ratio",
1448 		.data		= &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1449 		.maxlen		= sizeof(int),
1450 		.mode		= 0644,
1451 		.proc_handler	= proc_dointvec_minmax,
1452 		.extra1		= SYSCTL_ZERO,
1453 		.extra2		= SYSCTL_ONE_THOUSAND,
1454 	},
1455 	{
1456 		.procname	= "tcp_wmem",
1457 		.data		= &init_net.ipv4.sysctl_tcp_wmem,
1458 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_wmem),
1459 		.mode		= 0644,
1460 		.proc_handler	= proc_dointvec_minmax,
1461 		.extra1		= SYSCTL_ONE,
1462 	},
1463 	{
1464 		.procname	= "tcp_rmem",
1465 		.data		= &init_net.ipv4.sysctl_tcp_rmem,
1466 		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_rmem),
1467 		.mode		= 0644,
1468 		.proc_handler	= proc_dointvec_minmax,
1469 		.extra1		= &tcp_min_rcvbuf,
1470 	},
1471 	{
1472 		.procname	= "tcp_comp_sack_delay_ns",
1473 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1474 		.maxlen		= sizeof(unsigned long),
1475 		.mode		= 0644,
1476 		.proc_handler	= proc_doulongvec_minmax,
1477 	},
1478 	{
1479 		.procname	= "tcp_comp_sack_rtt_percent",
1480 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_rtt_percent,
1481 		.maxlen		= sizeof(int),
1482 		.mode		= 0644,
1483 		.proc_handler	= proc_dointvec_minmax,
1484 		.extra1		= SYSCTL_ONE,
1485 		.extra2		= SYSCTL_ONE_THOUSAND,
1486 	},
1487 	{
1488 		.procname	= "tcp_comp_sack_slack_ns",
1489 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1490 		.maxlen		= sizeof(unsigned long),
1491 		.mode		= 0644,
1492 		.proc_handler	= proc_doulongvec_minmax,
1493 	},
1494 	{
1495 		.procname	= "tcp_comp_sack_nr",
1496 		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1497 		.maxlen		= sizeof(u8),
1498 		.mode		= 0644,
1499 		.proc_handler	= proc_dou8vec_minmax,
1500 		.extra1		= SYSCTL_ZERO,
1501 	},
1502 	{
1503 		.procname	= "tcp_backlog_ack_defer",
1504 		.data		= &init_net.ipv4.sysctl_tcp_backlog_ack_defer,
1505 		.maxlen		= sizeof(u8),
1506 		.mode		= 0644,
1507 		.proc_handler	= proc_dou8vec_minmax,
1508 		.extra1		= SYSCTL_ZERO,
1509 		.extra2		= SYSCTL_ONE,
1510 	},
1511 	{
1512 		.procname       = "tcp_reflect_tos",
1513 		.data           = &init_net.ipv4.sysctl_tcp_reflect_tos,
1514 		.maxlen         = sizeof(u8),
1515 		.mode           = 0644,
1516 		.proc_handler   = proc_dou8vec_minmax,
1517 		.extra1         = SYSCTL_ZERO,
1518 		.extra2         = SYSCTL_ONE,
1519 	},
1520 	{
1521 		.procname	= "tcp_ehash_entries",
1522 		.data		= &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1523 		.mode		= 0444,
1524 		.proc_handler	= proc_tcp_ehash_entries,
1525 	},
1526 	{
1527 		.procname	= "tcp_child_ehash_entries",
1528 		.data		= &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1529 		.maxlen		= sizeof(unsigned int),
1530 		.mode		= 0644,
1531 		.proc_handler	= proc_douintvec_minmax,
1532 		.extra1		= SYSCTL_ZERO,
1533 		.extra2		= &tcp_child_ehash_entries_max,
1534 	},
1535 	{
1536 		.procname	= "udp_hash_entries",
1537 		.data		= &init_net.ipv4.sysctl_udp_child_hash_entries,
1538 		.mode		= 0444,
1539 		.proc_handler	= proc_udp_hash_entries,
1540 	},
1541 	{
1542 		.procname	= "udp_child_hash_entries",
1543 		.data		= &init_net.ipv4.sysctl_udp_child_hash_entries,
1544 		.maxlen		= sizeof(unsigned int),
1545 		.mode		= 0644,
1546 		.proc_handler	= proc_douintvec_minmax,
1547 		.extra1		= SYSCTL_ZERO,
1548 		.extra2		= &udp_child_hash_entries_max,
1549 	},
1550 	{
1551 		.procname	= "udp_rmem_min",
1552 		.data		= &init_net.ipv4.sysctl_udp_rmem_min,
1553 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1554 		.mode		= 0644,
1555 		.proc_handler	= proc_dointvec_minmax,
1556 		.extra1		= SYSCTL_ONE
1557 	},
1558 	{
1559 		.procname	= "udp_wmem_min",
1560 		.data		= &init_net.ipv4.sysctl_udp_wmem_min,
1561 		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1562 		.mode		= 0644,
1563 		.proc_handler	= proc_dointvec_minmax,
1564 		.extra1		= SYSCTL_ONE
1565 	},
1566 	{
1567 		.procname	= "fib_notify_on_flag_change",
1568 		.data		= &init_net.ipv4.sysctl_fib_notify_on_flag_change,
1569 		.maxlen		= sizeof(u8),
1570 		.mode		= 0644,
1571 		.proc_handler	= proc_dou8vec_minmax,
1572 		.extra1		= SYSCTL_ZERO,
1573 		.extra2		= SYSCTL_TWO,
1574 	},
1575 	{
1576 		.procname       = "tcp_plb_enabled",
1577 		.data           = &init_net.ipv4.sysctl_tcp_plb_enabled,
1578 		.maxlen         = sizeof(u8),
1579 		.mode           = 0644,
1580 		.proc_handler   = proc_dou8vec_minmax,
1581 		.extra1         = SYSCTL_ZERO,
1582 		.extra2         = SYSCTL_ONE,
1583 	},
1584 	{
1585 		.procname       = "tcp_plb_idle_rehash_rounds",
1586 		.data           = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds,
1587 		.maxlen         = sizeof(u8),
1588 		.mode           = 0644,
1589 		.proc_handler   = proc_dou8vec_minmax,
1590 		.extra2		= &tcp_plb_max_rounds,
1591 	},
1592 	{
1593 		.procname       = "tcp_plb_rehash_rounds",
1594 		.data           = &init_net.ipv4.sysctl_tcp_plb_rehash_rounds,
1595 		.maxlen         = sizeof(u8),
1596 		.mode           = 0644,
1597 		.proc_handler   = proc_dou8vec_minmax,
1598 		.extra2         = &tcp_plb_max_rounds,
1599 	},
1600 	{
1601 		.procname       = "tcp_plb_suspend_rto_sec",
1602 		.data           = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec,
1603 		.maxlen         = sizeof(u8),
1604 		.mode           = 0644,
1605 		.proc_handler   = proc_dou8vec_minmax,
1606 	},
1607 	{
1608 		.procname       = "tcp_plb_cong_thresh",
1609 		.data           = &init_net.ipv4.sysctl_tcp_plb_cong_thresh,
1610 		.maxlen         = sizeof(int),
1611 		.mode           = 0644,
1612 		.proc_handler   = proc_dointvec_minmax,
1613 		.extra1         = SYSCTL_ZERO,
1614 		.extra2         = &tcp_plb_max_cong_thresh,
1615 	},
1616 	{
1617 		.procname	= "tcp_syn_linear_timeouts",
1618 		.data		= &init_net.ipv4.sysctl_tcp_syn_linear_timeouts,
1619 		.maxlen		= sizeof(u8),
1620 		.mode		= 0644,
1621 		.proc_handler	= proc_dou8vec_minmax,
1622 		.extra1		= SYSCTL_ZERO,
1623 		.extra2		= &tcp_syn_linear_timeouts_max,
1624 	},
1625 	{
1626 		.procname	= "tcp_shrink_window",
1627 		.data		= &init_net.ipv4.sysctl_tcp_shrink_window,
1628 		.maxlen		= sizeof(u8),
1629 		.mode		= 0644,
1630 		.proc_handler	= proc_dou8vec_minmax,
1631 		.extra1		= SYSCTL_ZERO,
1632 		.extra2		= SYSCTL_ONE,
1633 	},
1634 	{
1635 		.procname	= "tcp_pingpong_thresh",
1636 		.data		= &init_net.ipv4.sysctl_tcp_pingpong_thresh,
1637 		.maxlen		= sizeof(u8),
1638 		.mode		= 0644,
1639 		.proc_handler	= proc_dou8vec_minmax,
1640 		.extra1		= SYSCTL_ONE,
1641 	},
1642 	{
1643 		.procname	= "tcp_rto_min_us",
1644 		.data		= &init_net.ipv4.sysctl_tcp_rto_min_us,
1645 		.maxlen		= sizeof(int),
1646 		.mode		= 0644,
1647 		.proc_handler	= proc_dointvec_minmax,
1648 		.extra1		= SYSCTL_ONE,
1649 	},
1650 	{
1651 		.procname	= "tcp_rto_max_ms",
1652 		.data		= &init_net.ipv4.sysctl_tcp_rto_max_ms,
1653 		.maxlen		= sizeof(int),
1654 		.mode		= 0644,
1655 		.proc_handler	= proc_dointvec_minmax,
1656 		.extra1		= SYSCTL_ONE_THOUSAND,
1657 		.extra2		= &tcp_rto_max_max,
1658 	},
1659 };
1660 
1661 static const struct ctl_table *ipv4_net_table_dup(struct net *net)
1662 {
1663 	size_t table_size = ARRAY_SIZE(ipv4_net_table);
1664 	struct ctl_table *table;
1665 	int i;
1666 
1667 	table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
1668 	if (!table)
1669 		return NULL;
1670 
1671 	for (i = 0; i < table_size; i++) {
1672 		if (table[i].data) {
1673 			/* Update the variables to point into
1674 			 * the current struct net
1675 			 */
1676 			table[i].data += (void *)net - (void *)&init_net;
1677 		} else {
1678 			/* Entries without data pointer are global;
1679 			 * Make them read-only in non-init_net ns
1680 			 */
1681 			table[i].mode &= ~0222;
1682 		}
1683 		if (table[i].extra2 >= (void *)&init_net.ipv4 &&
1684 		    table[i].extra2 < (void *)(&init_net.ipv4 + 1))
1685 			table[i].extra2 += (void *)net - (void *)&init_net;
1686 	}
1687 	return table;
1688 }
1689 
1690 static __net_init int ipv4_sysctl_init_net(struct net *net)
1691 {
1692 	size_t table_size = ARRAY_SIZE(ipv4_net_table);
1693 	const struct ctl_table *table;
1694 
1695 	table = ipv4_net_table;
1696 	if (!net_eq(net, &init_net)) {
1697 		table = ipv4_net_table_dup(net);
1698 		if (!table)
1699 			goto err_alloc;
1700 	}
1701 
1702 	net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table,
1703 						    table_size);
1704 	if (!net->ipv4.ipv4_hdr)
1705 		goto err_reg;
1706 
1707 	net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1708 	if (!net->ipv4.sysctl_local_reserved_ports)
1709 		goto err_ports;
1710 
1711 	proc_fib_multipath_hash_set_seed(net, 0);
1712 
1713 	return 0;
1714 
1715 err_ports:
1716 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1717 err_reg:
1718 	if (!net_eq(net, &init_net))
1719 		kfree(table);
1720 err_alloc:
1721 	return -ENOMEM;
1722 }
1723 
1724 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1725 {
1726 	const struct ctl_table *table;
1727 
1728 	table = net->ipv4.ipv4_hdr->ctl_table_arg;
1729 	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1730 	kfree(table);
1731 	kfree(net->ipv4.sysctl_local_reserved_ports);
1732 }
1733 
1734 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1735 	.init = ipv4_sysctl_init_net,
1736 	.exit = ipv4_sysctl_exit_net,
1737 };
1738 
1739 static __init int sysctl_ipv4_init(void)
1740 {
1741 	struct ctl_table_header *hdr;
1742 
1743 	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1744 	if (!hdr)
1745 		return -ENOMEM;
1746 
1747 	proc_fib_multipath_hash_init_rand_seed();
1748 
1749 	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1750 		unregister_net_sysctl_table(hdr);
1751 		return -ENOMEM;
1752 	}
1753 
1754 	return 0;
1755 }
1756 
1757 __initcall(sysctl_ipv4_init);
1758