octeontx2-pf: Fix error return code in otx2_probe()
[linux/fpc-iii.git] / net / ipv4 / sysctl_net_ipv4.c
blob3a628423d27bfe28d5dfc5b70c5b9f980275fc7f
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
5 * Begun April 1, 1996, Mike Shaver.
6 * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
7 */
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>
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;
54 /* obsolete */
55 static int sysctl_tcp_low_latency __read_mostly;
57 /* Update system visible IP port range */
58 static void set_local_port_range(struct net *net, int range[2])
60 bool same_parity = !((range[0] ^ range[1]) & 1);
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");
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);
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)
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,
89 inet_get_local_port_range(net, &range[0], &range[1]);
91 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
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.
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);
105 return ret;
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)
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,
125 pports = net->ipv4.sysctl_ip_prot_sock;
127 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
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.
134 if (range[0] < pports)
135 ret = -EINVAL;
136 else
137 net->ipv4.sysctl_ip_prot_sock = pports;
140 return ret;
143 static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
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);
152 *low = data[0];
153 *high = data[1];
154 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
157 /* Update system visible IP port range */
158 static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
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);
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)
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,
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);
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);
200 set_ping_group_range(table, low, high);
203 return ret;
206 static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
207 void __user *buffer,
208 size_t *lenp, loff_t *ppos)
210 struct net *net;
211 int ret;
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);
220 return ret;
223 static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
224 void __user *buffer, size_t *lenp, loff_t *ppos)
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,
233 int ret;
235 tcp_get_default_congestion_control(net, val);
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;
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)
248 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
249 int ret;
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;
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)
265 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
266 int ret;
268 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
269 if (!tbl.data)
270 return -ENOMEM;
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;
280 static int sscanf_key(char *buf, __le32 *key)
282 u32 user_key[4];
283 int i, ret = 0;
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]);
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);
295 return ret;
298 static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
299 void __user *buffer, size_t *lenp,
300 loff_t *ppos)
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.
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;
316 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
317 if (!tbl.data)
318 return -ENOMEM;
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);
326 rcu_read_unlock();
328 if (!n_keys) {
329 memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
330 n_keys = 1;
333 for (i = 0; i < n_keys * 4; i++)
334 user_key[i] = le32_to_cpu(key[i]);
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]);
344 if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
345 break;
347 if (i + 1 < n_keys)
348 off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
351 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
353 if (write && ret == 0) {
354 backup_data = strchr(tbl.data, ',');
355 if (backup_data) {
356 *backup_data = '\0';
357 backup_data++;
359 if (sscanf_key(tbl.data, key)) {
360 ret = -EINVAL;
361 goto bad_key;
363 if (backup_data) {
364 if (sscanf_key(backup_data, key + 4)) {
365 ret = -EINVAL;
366 goto bad_key;
369 tcp_fastopen_reset_cipher(net, NULL, key,
370 backup_data ? key + 4 : NULL);
373 bad_key:
374 kfree(tbl.data);
375 return ret;
378 static void proc_configure_early_demux(int enabled, int protocol)
380 struct net_protocol *ipprot;
381 #if IS_ENABLED(CONFIG_IPV6)
382 struct inet6_protocol *ip6prot;
383 #endif
385 rcu_read_lock();
387 ipprot = rcu_dereference(inet_protos[protocol]);
388 if (ipprot)
389 ipprot->early_demux = enabled ? ipprot->early_demux_handler :
390 NULL;
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();
401 static int proc_tcp_early_demux(struct ctl_table *table, int write,
402 void __user *buffer, size_t *lenp, loff_t *ppos)
404 int ret = 0;
406 ret = proc_dointvec(table, write, buffer, lenp, ppos);
408 if (write && !ret) {
409 int enabled = init_net.ipv4.sysctl_tcp_early_demux;
411 proc_configure_early_demux(enabled, IPPROTO_TCP);
414 return ret;
417 static int proc_udp_early_demux(struct ctl_table *table, int write,
418 void __user *buffer, size_t *lenp, loff_t *ppos)
420 int ret = 0;
422 ret = proc_dointvec(table, write, buffer, lenp, ppos);
424 if (write && !ret) {
425 int enabled = init_net.ipv4.sysctl_udp_early_demux;
427 proc_configure_early_demux(enabled, IPPROTO_UDP);
430 return ret;
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)
438 struct net *net = container_of(table->data, struct net,
439 ipv4.sysctl_tcp_fastopen_blackhole_timeout);
440 int ret;
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);
446 return ret;
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)
454 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
455 int ret;
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);
464 return ret;
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)
472 struct net *net = container_of(table->data, struct net,
473 ipv4.sysctl_fib_multipath_hash_policy);
474 int ret;
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);
480 return ret;
482 #endif
484 static struct ctl_table ipv4_table[] = {
486 .procname = "tcp_max_orphans",
487 .data = &sysctl_tcp_max_orphans,
488 .maxlen = sizeof(int),
489 .mode = 0644,
490 .proc_handler = proc_dointvec
493 .procname = "inet_peer_threshold",
494 .data = &inet_peer_threshold,
495 .maxlen = sizeof(int),
496 .mode = 0644,
497 .proc_handler = proc_dointvec
500 .procname = "inet_peer_minttl",
501 .data = &inet_peer_minttl,
502 .maxlen = sizeof(int),
503 .mode = 0644,
504 .proc_handler = proc_dointvec_jiffies,
507 .procname = "inet_peer_maxttl",
508 .data = &inet_peer_maxttl,
509 .maxlen = sizeof(int),
510 .mode = 0644,
511 .proc_handler = proc_dointvec_jiffies,
514 .procname = "tcp_mem",
515 .maxlen = sizeof(sysctl_tcp_mem),
516 .data = &sysctl_tcp_mem,
517 .mode = 0644,
518 .proc_handler = proc_doulongvec_minmax,
521 .procname = "tcp_low_latency",
522 .data = &sysctl_tcp_low_latency,
523 .maxlen = sizeof(int),
524 .mode = 0644,
525 .proc_handler = proc_dointvec
527 #ifdef CONFIG_NETLABEL
529 .procname = "cipso_cache_enable",
530 .data = &cipso_v4_cache_enabled,
531 .maxlen = sizeof(int),
532 .mode = 0644,
533 .proc_handler = proc_dointvec,
536 .procname = "cipso_cache_bucket_size",
537 .data = &cipso_v4_cache_bucketsize,
538 .maxlen = sizeof(int),
539 .mode = 0644,
540 .proc_handler = proc_dointvec,
543 .procname = "cipso_rbm_optfmt",
544 .data = &cipso_v4_rbm_optfmt,
545 .maxlen = sizeof(int),
546 .mode = 0644,
547 .proc_handler = proc_dointvec,
550 .procname = "cipso_rbm_strictvalid",
551 .data = &cipso_v4_rbm_strictvalid,
552 .maxlen = sizeof(int),
553 .mode = 0644,
554 .proc_handler = proc_dointvec,
556 #endif /* CONFIG_NETLABEL */
558 .procname = "tcp_available_ulp",
559 .maxlen = TCP_ULP_BUF_MAX,
560 .mode = 0444,
561 .proc_handler = proc_tcp_available_ulp,
564 .procname = "icmp_msgs_per_sec",
565 .data = &sysctl_icmp_msgs_per_sec,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 .proc_handler = proc_dointvec_minmax,
569 .extra1 = SYSCTL_ZERO,
572 .procname = "icmp_msgs_burst",
573 .data = &sysctl_icmp_msgs_burst,
574 .maxlen = sizeof(int),
575 .mode = 0644,
576 .proc_handler = proc_dointvec_minmax,
577 .extra1 = SYSCTL_ZERO,
580 .procname = "udp_mem",
581 .data = &sysctl_udp_mem,
582 .maxlen = sizeof(sysctl_udp_mem),
583 .mode = 0644,
584 .proc_handler = proc_doulongvec_minmax,
587 .procname = "fib_sync_mem",
588 .data = &sysctl_fib_sync_mem,
589 .maxlen = sizeof(sysctl_fib_sync_mem),
590 .mode = 0644,
591 .proc_handler = proc_douintvec_minmax,
592 .extra1 = &sysctl_fib_sync_mem_min,
593 .extra2 = &sysctl_fib_sync_mem_max,
596 .procname = "tcp_rx_skb_cache",
597 .data = &tcp_rx_skb_cache_key.key,
598 .mode = 0644,
599 .proc_handler = proc_do_static_key,
602 .procname = "tcp_tx_skb_cache",
603 .data = &tcp_tx_skb_cache_key.key,
604 .mode = 0644,
605 .proc_handler = proc_do_static_key,
610 static struct ctl_table ipv4_net_table[] = {
612 .procname = "icmp_echo_ignore_all",
613 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 .proc_handler = proc_dointvec
619 .procname = "icmp_echo_ignore_broadcasts",
620 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
621 .maxlen = sizeof(int),
622 .mode = 0644,
623 .proc_handler = proc_dointvec
626 .procname = "icmp_ignore_bogus_error_responses",
627 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = proc_dointvec
633 .procname = "icmp_errors_use_inbound_ifaddr",
634 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
635 .maxlen = sizeof(int),
636 .mode = 0644,
637 .proc_handler = proc_dointvec
640 .procname = "icmp_ratelimit",
641 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
642 .maxlen = sizeof(int),
643 .mode = 0644,
644 .proc_handler = proc_dointvec_ms_jiffies,
647 .procname = "icmp_ratemask",
648 .data = &init_net.ipv4.sysctl_icmp_ratemask,
649 .maxlen = sizeof(int),
650 .mode = 0644,
651 .proc_handler = proc_dointvec
654 .procname = "ping_group_range",
655 .data = &init_net.ipv4.ping_group_range.range,
656 .maxlen = sizeof(gid_t)*2,
657 .mode = 0644,
658 .proc_handler = ipv4_ping_group_range,
660 #ifdef CONFIG_NET_L3_MASTER_DEV
662 .procname = "raw_l3mdev_accept",
663 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept,
664 .maxlen = sizeof(int),
665 .mode = 0644,
666 .proc_handler = proc_dointvec_minmax,
667 .extra1 = SYSCTL_ZERO,
668 .extra2 = SYSCTL_ONE,
670 #endif
672 .procname = "tcp_ecn",
673 .data = &init_net.ipv4.sysctl_tcp_ecn,
674 .maxlen = sizeof(int),
675 .mode = 0644,
676 .proc_handler = proc_dointvec
679 .procname = "tcp_ecn_fallback",
680 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
681 .maxlen = sizeof(int),
682 .mode = 0644,
683 .proc_handler = proc_dointvec
686 .procname = "ip_dynaddr",
687 .data = &init_net.ipv4.sysctl_ip_dynaddr,
688 .maxlen = sizeof(int),
689 .mode = 0644,
690 .proc_handler = proc_dointvec
693 .procname = "ip_early_demux",
694 .data = &init_net.ipv4.sysctl_ip_early_demux,
695 .maxlen = sizeof(int),
696 .mode = 0644,
697 .proc_handler = proc_dointvec
700 .procname = "udp_early_demux",
701 .data = &init_net.ipv4.sysctl_udp_early_demux,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 .proc_handler = proc_udp_early_demux
707 .procname = "tcp_early_demux",
708 .data = &init_net.ipv4.sysctl_tcp_early_demux,
709 .maxlen = sizeof(int),
710 .mode = 0644,
711 .proc_handler = proc_tcp_early_demux
714 .procname = "nexthop_compat_mode",
715 .data = &init_net.ipv4.sysctl_nexthop_compat_mode,
716 .maxlen = sizeof(int),
717 .mode = 0644,
718 .proc_handler = proc_dointvec_minmax,
719 .extra1 = SYSCTL_ZERO,
720 .extra2 = SYSCTL_ONE,
723 .procname = "ip_default_ttl",
724 .data = &init_net.ipv4.sysctl_ip_default_ttl,
725 .maxlen = sizeof(int),
726 .mode = 0644,
727 .proc_handler = proc_dointvec_minmax,
728 .extra1 = &ip_ttl_min,
729 .extra2 = &ip_ttl_max,
732 .procname = "ip_local_port_range",
733 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
734 .data = &init_net.ipv4.ip_local_ports.range,
735 .mode = 0644,
736 .proc_handler = ipv4_local_port_range,
739 .procname = "ip_local_reserved_ports",
740 .data = &init_net.ipv4.sysctl_local_reserved_ports,
741 .maxlen = 65536,
742 .mode = 0644,
743 .proc_handler = proc_do_large_bitmap,
746 .procname = "ip_no_pmtu_disc",
747 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
748 .maxlen = sizeof(int),
749 .mode = 0644,
750 .proc_handler = proc_dointvec
753 .procname = "ip_forward_use_pmtu",
754 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
755 .maxlen = sizeof(int),
756 .mode = 0644,
757 .proc_handler = proc_dointvec,
760 .procname = "ip_forward_update_priority",
761 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
762 .maxlen = sizeof(int),
763 .mode = 0644,
764 .proc_handler = ipv4_fwd_update_priority,
765 .extra1 = SYSCTL_ZERO,
766 .extra2 = SYSCTL_ONE,
769 .procname = "ip_nonlocal_bind",
770 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
771 .maxlen = sizeof(int),
772 .mode = 0644,
773 .proc_handler = proc_dointvec
776 .procname = "ip_autobind_reuse",
777 .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
778 .maxlen = sizeof(int),
779 .mode = 0644,
780 .proc_handler = proc_dointvec_minmax,
781 .extra1 = SYSCTL_ZERO,
782 .extra2 = SYSCTL_ONE,
785 .procname = "fwmark_reflect",
786 .data = &init_net.ipv4.sysctl_fwmark_reflect,
787 .maxlen = sizeof(int),
788 .mode = 0644,
789 .proc_handler = proc_dointvec,
792 .procname = "tcp_fwmark_accept",
793 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
794 .maxlen = sizeof(int),
795 .mode = 0644,
796 .proc_handler = proc_dointvec,
798 #ifdef CONFIG_NET_L3_MASTER_DEV
800 .procname = "tcp_l3mdev_accept",
801 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
802 .maxlen = sizeof(int),
803 .mode = 0644,
804 .proc_handler = proc_dointvec_minmax,
805 .extra1 = SYSCTL_ZERO,
806 .extra2 = SYSCTL_ONE,
808 #endif
810 .procname = "tcp_mtu_probing",
811 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
812 .maxlen = sizeof(int),
813 .mode = 0644,
814 .proc_handler = proc_dointvec,
817 .procname = "tcp_base_mss",
818 .data = &init_net.ipv4.sysctl_tcp_base_mss,
819 .maxlen = sizeof(int),
820 .mode = 0644,
821 .proc_handler = proc_dointvec,
824 .procname = "tcp_min_snd_mss",
825 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
826 .maxlen = sizeof(int),
827 .mode = 0644,
828 .proc_handler = proc_dointvec_minmax,
829 .extra1 = &tcp_min_snd_mss_min,
830 .extra2 = &tcp_min_snd_mss_max,
833 .procname = "tcp_mtu_probe_floor",
834 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
835 .maxlen = sizeof(int),
836 .mode = 0644,
837 .proc_handler = proc_dointvec_minmax,
838 .extra1 = &tcp_min_snd_mss_min,
839 .extra2 = &tcp_min_snd_mss_max,
842 .procname = "tcp_probe_threshold",
843 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
844 .maxlen = sizeof(int),
845 .mode = 0644,
846 .proc_handler = proc_dointvec,
849 .procname = "tcp_probe_interval",
850 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
851 .maxlen = sizeof(u32),
852 .mode = 0644,
853 .proc_handler = proc_douintvec_minmax,
854 .extra2 = &u32_max_div_HZ,
857 .procname = "igmp_link_local_mcast_reports",
858 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
859 .maxlen = sizeof(int),
860 .mode = 0644,
861 .proc_handler = proc_dointvec
864 .procname = "igmp_max_memberships",
865 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
866 .maxlen = sizeof(int),
867 .mode = 0644,
868 .proc_handler = proc_dointvec
871 .procname = "igmp_max_msf",
872 .data = &init_net.ipv4.sysctl_igmp_max_msf,
873 .maxlen = sizeof(int),
874 .mode = 0644,
875 .proc_handler = proc_dointvec
877 #ifdef CONFIG_IP_MULTICAST
879 .procname = "igmp_qrv",
880 .data = &init_net.ipv4.sysctl_igmp_qrv,
881 .maxlen = sizeof(int),
882 .mode = 0644,
883 .proc_handler = proc_dointvec_minmax,
884 .extra1 = SYSCTL_ONE
886 #endif
888 .procname = "tcp_congestion_control",
889 .data = &init_net.ipv4.tcp_congestion_control,
890 .mode = 0644,
891 .maxlen = TCP_CA_NAME_MAX,
892 .proc_handler = proc_tcp_congestion_control,
895 .procname = "tcp_available_congestion_control",
896 .maxlen = TCP_CA_BUF_MAX,
897 .mode = 0444,
898 .proc_handler = proc_tcp_available_congestion_control,
901 .procname = "tcp_allowed_congestion_control",
902 .maxlen = TCP_CA_BUF_MAX,
903 .mode = 0644,
904 .proc_handler = proc_allowed_congestion_control,
907 .procname = "tcp_keepalive_time",
908 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
909 .maxlen = sizeof(int),
910 .mode = 0644,
911 .proc_handler = proc_dointvec_jiffies,
914 .procname = "tcp_keepalive_probes",
915 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
916 .maxlen = sizeof(int),
917 .mode = 0644,
918 .proc_handler = proc_dointvec
921 .procname = "tcp_keepalive_intvl",
922 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
923 .maxlen = sizeof(int),
924 .mode = 0644,
925 .proc_handler = proc_dointvec_jiffies,
928 .procname = "tcp_syn_retries",
929 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
930 .maxlen = sizeof(int),
931 .mode = 0644,
932 .proc_handler = proc_dointvec_minmax,
933 .extra1 = &tcp_syn_retries_min,
934 .extra2 = &tcp_syn_retries_max
937 .procname = "tcp_synack_retries",
938 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
939 .maxlen = sizeof(int),
940 .mode = 0644,
941 .proc_handler = proc_dointvec
943 #ifdef CONFIG_SYN_COOKIES
945 .procname = "tcp_syncookies",
946 .data = &init_net.ipv4.sysctl_tcp_syncookies,
947 .maxlen = sizeof(int),
948 .mode = 0644,
949 .proc_handler = proc_dointvec
951 #endif
953 .procname = "tcp_reordering",
954 .data = &init_net.ipv4.sysctl_tcp_reordering,
955 .maxlen = sizeof(int),
956 .mode = 0644,
957 .proc_handler = proc_dointvec
960 .procname = "tcp_retries1",
961 .data = &init_net.ipv4.sysctl_tcp_retries1,
962 .maxlen = sizeof(int),
963 .mode = 0644,
964 .proc_handler = proc_dointvec_minmax,
965 .extra2 = &tcp_retr1_max
968 .procname = "tcp_retries2",
969 .data = &init_net.ipv4.sysctl_tcp_retries2,
970 .maxlen = sizeof(int),
971 .mode = 0644,
972 .proc_handler = proc_dointvec
975 .procname = "tcp_orphan_retries",
976 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
977 .maxlen = sizeof(int),
978 .mode = 0644,
979 .proc_handler = proc_dointvec
982 .procname = "tcp_fin_timeout",
983 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
984 .maxlen = sizeof(int),
985 .mode = 0644,
986 .proc_handler = proc_dointvec_jiffies,
989 .procname = "tcp_notsent_lowat",
990 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
991 .maxlen = sizeof(unsigned int),
992 .mode = 0644,
993 .proc_handler = proc_douintvec,
996 .procname = "tcp_tw_reuse",
997 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
998 .maxlen = sizeof(int),
999 .mode = 0644,
1000 .proc_handler = proc_dointvec_minmax,
1001 .extra1 = SYSCTL_ZERO,
1002 .extra2 = &two,
1005 .procname = "tcp_max_tw_buckets",
1006 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
1007 .maxlen = sizeof(int),
1008 .mode = 0644,
1009 .proc_handler = proc_dointvec
1012 .procname = "tcp_max_syn_backlog",
1013 .data = &init_net.ipv4.sysctl_max_syn_backlog,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
1016 .proc_handler = proc_dointvec
1019 .procname = "tcp_fastopen",
1020 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
1023 .proc_handler = proc_dointvec,
1026 .procname = "tcp_fastopen_key",
1027 .mode = 0600,
1028 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1029 /* maxlen to print the list of keys in hex (*2), with dashes
1030 * separating doublewords and a comma in between keys.
1032 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
1033 2 * TCP_FASTOPEN_KEY_MAX) +
1034 (TCP_FASTOPEN_KEY_MAX * 5)),
1035 .proc_handler = proc_tcp_fastopen_key,
1038 .procname = "tcp_fastopen_blackhole_timeout_sec",
1039 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
1042 .proc_handler = proc_tfo_blackhole_detect_timeout,
1043 .extra1 = SYSCTL_ZERO,
1045 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1047 .procname = "fib_multipath_use_neigh",
1048 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1049 .maxlen = sizeof(int),
1050 .mode = 0644,
1051 .proc_handler = proc_dointvec_minmax,
1052 .extra1 = SYSCTL_ZERO,
1053 .extra2 = SYSCTL_ONE,
1056 .procname = "fib_multipath_hash_policy",
1057 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1058 .maxlen = sizeof(int),
1059 .mode = 0644,
1060 .proc_handler = proc_fib_multipath_hash_policy,
1061 .extra1 = SYSCTL_ZERO,
1062 .extra2 = &two,
1064 #endif
1066 .procname = "ip_unprivileged_port_start",
1067 .maxlen = sizeof(int),
1068 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1069 .mode = 0644,
1070 .proc_handler = ipv4_privileged_ports,
1072 #ifdef CONFIG_NET_L3_MASTER_DEV
1074 .procname = "udp_l3mdev_accept",
1075 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1076 .maxlen = sizeof(int),
1077 .mode = 0644,
1078 .proc_handler = proc_dointvec_minmax,
1079 .extra1 = SYSCTL_ZERO,
1080 .extra2 = SYSCTL_ONE,
1082 #endif
1084 .procname = "tcp_sack",
1085 .data = &init_net.ipv4.sysctl_tcp_sack,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
1088 .proc_handler = proc_dointvec
1091 .procname = "tcp_window_scaling",
1092 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1093 .maxlen = sizeof(int),
1094 .mode = 0644,
1095 .proc_handler = proc_dointvec
1098 .procname = "tcp_timestamps",
1099 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1100 .maxlen = sizeof(int),
1101 .mode = 0644,
1102 .proc_handler = proc_dointvec
1105 .procname = "tcp_early_retrans",
1106 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
1107 .maxlen = sizeof(int),
1108 .mode = 0644,
1109 .proc_handler = proc_dointvec_minmax,
1110 .extra1 = SYSCTL_ZERO,
1111 .extra2 = &four,
1114 .procname = "tcp_recovery",
1115 .data = &init_net.ipv4.sysctl_tcp_recovery,
1116 .maxlen = sizeof(int),
1117 .mode = 0644,
1118 .proc_handler = proc_dointvec,
1121 .procname = "tcp_thin_linear_timeouts",
1122 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1123 .maxlen = sizeof(int),
1124 .mode = 0644,
1125 .proc_handler = proc_dointvec
1128 .procname = "tcp_slow_start_after_idle",
1129 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1130 .maxlen = sizeof(int),
1131 .mode = 0644,
1132 .proc_handler = proc_dointvec
1135 .procname = "tcp_retrans_collapse",
1136 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1137 .maxlen = sizeof(int),
1138 .mode = 0644,
1139 .proc_handler = proc_dointvec
1142 .procname = "tcp_stdurg",
1143 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1144 .maxlen = sizeof(int),
1145 .mode = 0644,
1146 .proc_handler = proc_dointvec
1149 .procname = "tcp_rfc1337",
1150 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1151 .maxlen = sizeof(int),
1152 .mode = 0644,
1153 .proc_handler = proc_dointvec
1156 .procname = "tcp_abort_on_overflow",
1157 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1158 .maxlen = sizeof(int),
1159 .mode = 0644,
1160 .proc_handler = proc_dointvec
1163 .procname = "tcp_fack",
1164 .data = &init_net.ipv4.sysctl_tcp_fack,
1165 .maxlen = sizeof(int),
1166 .mode = 0644,
1167 .proc_handler = proc_dointvec
1170 .procname = "tcp_max_reordering",
1171 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
1174 .proc_handler = proc_dointvec
1177 .procname = "tcp_dsack",
1178 .data = &init_net.ipv4.sysctl_tcp_dsack,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
1181 .proc_handler = proc_dointvec
1184 .procname = "tcp_app_win",
1185 .data = &init_net.ipv4.sysctl_tcp_app_win,
1186 .maxlen = sizeof(int),
1187 .mode = 0644,
1188 .proc_handler = proc_dointvec
1191 .procname = "tcp_adv_win_scale",
1192 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1193 .maxlen = sizeof(int),
1194 .mode = 0644,
1195 .proc_handler = proc_dointvec_minmax,
1196 .extra1 = &tcp_adv_win_scale_min,
1197 .extra2 = &tcp_adv_win_scale_max,
1200 .procname = "tcp_frto",
1201 .data = &init_net.ipv4.sysctl_tcp_frto,
1202 .maxlen = sizeof(int),
1203 .mode = 0644,
1204 .proc_handler = proc_dointvec
1207 .procname = "tcp_no_metrics_save",
1208 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1209 .maxlen = sizeof(int),
1210 .mode = 0644,
1211 .proc_handler = proc_dointvec,
1214 .procname = "tcp_no_ssthresh_metrics_save",
1215 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1216 .maxlen = sizeof(int),
1217 .mode = 0644,
1218 .proc_handler = proc_dointvec_minmax,
1219 .extra1 = SYSCTL_ZERO,
1220 .extra2 = SYSCTL_ONE,
1223 .procname = "tcp_moderate_rcvbuf",
1224 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1225 .maxlen = sizeof(int),
1226 .mode = 0644,
1227 .proc_handler = proc_dointvec,
1230 .procname = "tcp_tso_win_divisor",
1231 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1232 .maxlen = sizeof(int),
1233 .mode = 0644,
1234 .proc_handler = proc_dointvec,
1237 .procname = "tcp_workaround_signed_windows",
1238 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1239 .maxlen = sizeof(int),
1240 .mode = 0644,
1241 .proc_handler = proc_dointvec
1244 .procname = "tcp_limit_output_bytes",
1245 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1246 .maxlen = sizeof(int),
1247 .mode = 0644,
1248 .proc_handler = proc_dointvec
1251 .procname = "tcp_challenge_ack_limit",
1252 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1253 .maxlen = sizeof(int),
1254 .mode = 0644,
1255 .proc_handler = proc_dointvec
1258 .procname = "tcp_min_tso_segs",
1259 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1260 .maxlen = sizeof(int),
1261 .mode = 0644,
1262 .proc_handler = proc_dointvec_minmax,
1263 .extra1 = SYSCTL_ONE,
1264 .extra2 = &gso_max_segs,
1267 .procname = "tcp_min_rtt_wlen",
1268 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1269 .maxlen = sizeof(int),
1270 .mode = 0644,
1271 .proc_handler = proc_dointvec_minmax,
1272 .extra1 = SYSCTL_ZERO,
1273 .extra2 = &one_day_secs
1276 .procname = "tcp_autocorking",
1277 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1278 .maxlen = sizeof(int),
1279 .mode = 0644,
1280 .proc_handler = proc_dointvec_minmax,
1281 .extra1 = SYSCTL_ZERO,
1282 .extra2 = SYSCTL_ONE,
1285 .procname = "tcp_invalid_ratelimit",
1286 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1287 .maxlen = sizeof(int),
1288 .mode = 0644,
1289 .proc_handler = proc_dointvec_ms_jiffies,
1292 .procname = "tcp_pacing_ss_ratio",
1293 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1294 .maxlen = sizeof(int),
1295 .mode = 0644,
1296 .proc_handler = proc_dointvec_minmax,
1297 .extra1 = SYSCTL_ZERO,
1298 .extra2 = &thousand,
1301 .procname = "tcp_pacing_ca_ratio",
1302 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1303 .maxlen = sizeof(int),
1304 .mode = 0644,
1305 .proc_handler = proc_dointvec_minmax,
1306 .extra1 = SYSCTL_ZERO,
1307 .extra2 = &thousand,
1310 .procname = "tcp_wmem",
1311 .data = &init_net.ipv4.sysctl_tcp_wmem,
1312 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
1313 .mode = 0644,
1314 .proc_handler = proc_dointvec_minmax,
1315 .extra1 = SYSCTL_ONE,
1318 .procname = "tcp_rmem",
1319 .data = &init_net.ipv4.sysctl_tcp_rmem,
1320 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
1321 .mode = 0644,
1322 .proc_handler = proc_dointvec_minmax,
1323 .extra1 = SYSCTL_ONE,
1326 .procname = "tcp_comp_sack_delay_ns",
1327 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1328 .maxlen = sizeof(unsigned long),
1329 .mode = 0644,
1330 .proc_handler = proc_doulongvec_minmax,
1333 .procname = "tcp_comp_sack_slack_ns",
1334 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1335 .maxlen = sizeof(unsigned long),
1336 .mode = 0644,
1337 .proc_handler = proc_doulongvec_minmax,
1340 .procname = "tcp_comp_sack_nr",
1341 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1342 .maxlen = sizeof(int),
1343 .mode = 0644,
1344 .proc_handler = proc_dointvec_minmax,
1345 .extra1 = SYSCTL_ZERO,
1346 .extra2 = &comp_sack_nr_max,
1349 .procname = "udp_rmem_min",
1350 .data = &init_net.ipv4.sysctl_udp_rmem_min,
1351 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1352 .mode = 0644,
1353 .proc_handler = proc_dointvec_minmax,
1354 .extra1 = SYSCTL_ONE
1357 .procname = "udp_wmem_min",
1358 .data = &init_net.ipv4.sysctl_udp_wmem_min,
1359 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1360 .mode = 0644,
1361 .proc_handler = proc_dointvec_minmax,
1362 .extra1 = SYSCTL_ONE
1367 static __net_init int ipv4_sysctl_init_net(struct net *net)
1369 struct ctl_table *table;
1371 table = ipv4_net_table;
1372 if (!net_eq(net, &init_net)) {
1373 int i;
1375 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1376 if (!table)
1377 goto err_alloc;
1379 /* Update the variables to point into the current struct net */
1380 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1381 table[i].data += (void *)net - (void *)&init_net;
1384 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
1385 if (!net->ipv4.ipv4_hdr)
1386 goto err_reg;
1388 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1389 if (!net->ipv4.sysctl_local_reserved_ports)
1390 goto err_ports;
1392 return 0;
1394 err_ports:
1395 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1396 err_reg:
1397 if (!net_eq(net, &init_net))
1398 kfree(table);
1399 err_alloc:
1400 return -ENOMEM;
1403 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1405 struct ctl_table *table;
1407 kfree(net->ipv4.sysctl_local_reserved_ports);
1408 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1409 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1410 kfree(table);
1413 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1414 .init = ipv4_sysctl_init_net,
1415 .exit = ipv4_sysctl_exit_net,
1418 static __init int sysctl_ipv4_init(void)
1420 struct ctl_table_header *hdr;
1422 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1423 if (!hdr)
1424 return -ENOMEM;
1426 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1427 unregister_net_sysctl_table(hdr);
1428 return -ENOMEM;
1431 return 0;
1434 __initcall(sysctl_ipv4_init);