1 // SPDX-License-Identifier: GPL-2.0
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]
9 #include <linux/sysctl.h>
10 #include <linux/seqlock.h>
11 #include <linux/init.h>
12 #include <linux/slab.h>
15 #include <net/ip_fib.h>
18 #include <net/cipso_ipv4.h>
20 #include <net/protocol.h>
21 #include <net/netevent.h>
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_min_snd_mss_min = TCP_MIN_SND_MSS;
30 static int tcp_min_snd_mss_max = 65535;
31 static int ip_privileged_port_min;
32 static int ip_privileged_port_max = 65535;
33 static int ip_ttl_min = 1;
34 static int ip_ttl_max = 255;
35 static int tcp_syn_retries_min = 1;
36 static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
37 static int tcp_syn_linear_timeouts_max = MAX_TCP_SYNCNT;
38 static unsigned long ip_ping_group_range_min[] = { 0, 0 };
39 static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
40 static u32 u32_max_div_HZ = UINT_MAX / HZ;
41 static int one_day_secs = 24 * 3600;
42 static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
43 FIB_MULTIPATH_HASH_FIELD_ALL_MASK;
44 static unsigned int tcp_child_ehash_entries_max = 16 * 1024 * 1024;
45 static unsigned int udp_child_hash_entries_max = UDP_HTABLE_SIZE_MAX;
46 static int tcp_plb_max_rounds = 31;
47 static int tcp_plb_max_cong_thresh = 256;
50 static int sysctl_tcp_low_latency __read_mostly;
52 /* Update system visible IP port range */
53 static void set_local_port_range(struct net *net, unsigned int low, unsigned int high)
55 bool same_parity = !((low ^ high) & 1);
57 if (same_parity && !net->ipv4.ip_local_ports.warned) {
58 net->ipv4.ip_local_ports.warned = true;
59 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
61 WRITE_ONCE(net->ipv4.ip_local_ports.range, high << 16 | low);
64 /* Validate changes from /proc interface. */
65 static int ipv4_local_port_range(struct ctl_table *table, int write,
66 void *buffer, size_t *lenp, loff_t *ppos)
68 struct net *net = table->data;
71 struct ctl_table tmp = {
73 .maxlen = sizeof(range),
75 .extra1 = &ip_local_port_range_min,
76 .extra2 = &ip_local_port_range_max,
79 inet_get_local_port_range(net, &range[0], &range[1]);
81 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
83 if (write && ret == 0) {
84 /* Ensure that the upper limit is not smaller than the lower,
85 * and that the lower does not encroach upon the privileged
88 if ((range[1] < range[0]) ||
89 (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock)))
92 set_local_port_range(net, range[0], range[1]);
98 /* Validate changes from /proc interface. */
99 static int ipv4_privileged_ports(struct ctl_table *table, int write,
100 void *buffer, size_t *lenp, loff_t *ppos)
102 struct net *net = container_of(table->data, struct net,
103 ipv4.sysctl_ip_prot_sock);
107 struct ctl_table tmp = {
109 .maxlen = sizeof(pports),
111 .extra1 = &ip_privileged_port_min,
112 .extra2 = &ip_privileged_port_max,
115 pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock);
117 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
119 if (write && ret == 0) {
120 inet_get_local_port_range(net, &range[0], &range[1]);
121 /* Ensure that the local port range doesn't overlap with the
122 * privileged port range.
124 if (range[0] < pports)
127 WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports);
133 static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
135 kgid_t *data = table->data;
137 container_of(table->data, struct net, ipv4.ping_group_range.range);
140 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
144 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
147 /* Update system visible IP port range */
148 static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
150 kgid_t *data = table->data;
152 container_of(table->data, struct net, ipv4.ping_group_range.range);
153 write_seqlock(&net->ipv4.ping_group_range.lock);
156 write_sequnlock(&net->ipv4.ping_group_range.lock);
159 /* Validate changes from /proc interface. */
160 static int ipv4_ping_group_range(struct ctl_table *table, int write,
161 void *buffer, size_t *lenp, loff_t *ppos)
163 struct user_namespace *user_ns = current_user_ns();
165 unsigned long urange[2];
167 struct ctl_table tmp = {
169 .maxlen = sizeof(urange),
171 .extra1 = &ip_ping_group_range_min,
172 .extra2 = &ip_ping_group_range_max,
175 inet_get_ping_group_range_table(table, &low, &high);
176 urange[0] = from_kgid_munged(user_ns, low);
177 urange[1] = from_kgid_munged(user_ns, high);
178 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
180 if (write && ret == 0) {
181 low = make_kgid(user_ns, urange[0]);
182 high = make_kgid(user_ns, urange[1]);
183 if (!gid_valid(low) || !gid_valid(high))
185 if (urange[1] < urange[0] || gid_lt(high, low)) {
186 low = make_kgid(&init_user_ns, 1);
187 high = make_kgid(&init_user_ns, 0);
189 set_ping_group_range(table, low, high);
195 static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
196 void *buffer, size_t *lenp, loff_t *ppos)
201 net = container_of(table->data, struct net,
202 ipv4.sysctl_ip_fwd_update_priority);
203 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
204 if (write && ret == 0)
205 call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
211 static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
212 void *buffer, size_t *lenp, loff_t *ppos)
214 struct net *net = container_of(ctl->data, struct net,
215 ipv4.tcp_congestion_control);
216 char val[TCP_CA_NAME_MAX];
217 struct ctl_table tbl = {
219 .maxlen = TCP_CA_NAME_MAX,
223 tcp_get_default_congestion_control(net, val);
225 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
226 if (write && ret == 0)
227 ret = tcp_set_default_congestion_control(net, val);
231 static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
232 int write, void *buffer,
233 size_t *lenp, loff_t *ppos)
235 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
238 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
241 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
242 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
247 static int proc_allowed_congestion_control(struct ctl_table *ctl,
248 int write, void *buffer,
249 size_t *lenp, loff_t *ppos)
251 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
254 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
258 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
259 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
260 if (write && ret == 0)
261 ret = tcp_set_allowed_congestion_control(tbl.data);
266 static int sscanf_key(char *buf, __le32 *key)
271 if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
272 user_key + 2, user_key + 3) != 4) {
275 for (i = 0; i < ARRAY_SIZE(user_key); i++)
276 key[i] = cpu_to_le32(user_key[i]);
278 pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
279 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
284 static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
285 void *buffer, size_t *lenp, loff_t *ppos)
287 struct net *net = container_of(table->data, struct net,
288 ipv4.sysctl_tcp_fastopen);
289 /* maxlen to print the list of keys in hex (*2), with dashes
290 * separating doublewords and a comma in between keys.
292 struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
293 2 * TCP_FASTOPEN_KEY_MAX) +
294 (TCP_FASTOPEN_KEY_MAX * 5)) };
295 u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
296 __le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
298 int ret, i = 0, off = 0, n_keys;
300 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
304 n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
306 memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
310 for (i = 0; i < n_keys * 4; i++)
311 user_key[i] = le32_to_cpu(key[i]);
313 for (i = 0; i < n_keys; i++) {
314 off += snprintf(tbl.data + off, tbl.maxlen - off,
315 "%08x-%08x-%08x-%08x",
319 user_key[i * 4 + 3]);
321 if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
325 off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
328 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
330 if (write && ret == 0) {
331 backup_data = strchr(tbl.data, ',');
336 if (sscanf_key(tbl.data, key)) {
341 if (sscanf_key(backup_data, key + 4)) {
346 tcp_fastopen_reset_cipher(net, NULL, key,
347 backup_data ? key + 4 : NULL);
355 static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
356 int write, void *buffer,
357 size_t *lenp, loff_t *ppos)
359 struct net *net = container_of(table->data, struct net,
360 ipv4.sysctl_tcp_fastopen_blackhole_timeout);
363 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
364 if (write && ret == 0)
365 atomic_set(&net->ipv4.tfo_active_disable_times, 0);
370 static int proc_tcp_available_ulp(struct ctl_table *ctl,
371 int write, void *buffer, size_t *lenp,
374 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
377 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
380 tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
381 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
387 static int proc_tcp_ehash_entries(struct ctl_table *table, int write,
388 void *buffer, size_t *lenp, loff_t *ppos)
390 struct net *net = container_of(table->data, struct net,
391 ipv4.sysctl_tcp_child_ehash_entries);
392 struct inet_hashinfo *hinfo = net->ipv4.tcp_death_row.hashinfo;
393 int tcp_ehash_entries;
394 struct ctl_table tbl;
396 tcp_ehash_entries = hinfo->ehash_mask + 1;
398 /* A negative number indicates that the child netns
399 * shares the global ehash.
401 if (!net_eq(net, &init_net) && !hinfo->pernet)
402 tcp_ehash_entries *= -1;
404 memset(&tbl, 0, sizeof(tbl));
405 tbl.data = &tcp_ehash_entries;
406 tbl.maxlen = sizeof(int);
408 return proc_dointvec(&tbl, write, buffer, lenp, ppos);
411 static int proc_udp_hash_entries(struct ctl_table *table, int write,
412 void *buffer, size_t *lenp, loff_t *ppos)
414 struct net *net = container_of(table->data, struct net,
415 ipv4.sysctl_udp_child_hash_entries);
416 int udp_hash_entries;
417 struct ctl_table tbl;
419 udp_hash_entries = net->ipv4.udp_table->mask + 1;
421 /* A negative number indicates that the child netns
422 * shares the global udp_table.
424 if (!net_eq(net, &init_net) && net->ipv4.udp_table == &udp_table)
425 udp_hash_entries *= -1;
427 memset(&tbl, 0, sizeof(tbl));
428 tbl.data = &udp_hash_entries;
429 tbl.maxlen = sizeof(int);
431 return proc_dointvec(&tbl, write, buffer, lenp, ppos);
434 #ifdef CONFIG_IP_ROUTE_MULTIPATH
435 static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
436 void *buffer, size_t *lenp,
439 struct net *net = container_of(table->data, struct net,
440 ipv4.sysctl_fib_multipath_hash_policy);
443 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
444 if (write && ret == 0)
445 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
450 static int proc_fib_multipath_hash_fields(struct ctl_table *table, int write,
451 void *buffer, size_t *lenp,
457 net = container_of(table->data, struct net,
458 ipv4.sysctl_fib_multipath_hash_fields);
459 ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
460 if (write && ret == 0)
461 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
467 static struct ctl_table ipv4_table[] = {
469 .procname = "tcp_max_orphans",
470 .data = &sysctl_tcp_max_orphans,
471 .maxlen = sizeof(int),
473 .proc_handler = proc_dointvec
476 .procname = "inet_peer_threshold",
477 .data = &inet_peer_threshold,
478 .maxlen = sizeof(int),
480 .proc_handler = proc_dointvec
483 .procname = "inet_peer_minttl",
484 .data = &inet_peer_minttl,
485 .maxlen = sizeof(int),
487 .proc_handler = proc_dointvec_jiffies,
490 .procname = "inet_peer_maxttl",
491 .data = &inet_peer_maxttl,
492 .maxlen = sizeof(int),
494 .proc_handler = proc_dointvec_jiffies,
497 .procname = "tcp_mem",
498 .maxlen = sizeof(sysctl_tcp_mem),
499 .data = &sysctl_tcp_mem,
501 .proc_handler = proc_doulongvec_minmax,
504 .procname = "tcp_low_latency",
505 .data = &sysctl_tcp_low_latency,
506 .maxlen = sizeof(int),
508 .proc_handler = proc_dointvec
510 #ifdef CONFIG_NETLABEL
512 .procname = "cipso_cache_enable",
513 .data = &cipso_v4_cache_enabled,
514 .maxlen = sizeof(int),
516 .proc_handler = proc_dointvec,
519 .procname = "cipso_cache_bucket_size",
520 .data = &cipso_v4_cache_bucketsize,
521 .maxlen = sizeof(int),
523 .proc_handler = proc_dointvec,
526 .procname = "cipso_rbm_optfmt",
527 .data = &cipso_v4_rbm_optfmt,
528 .maxlen = sizeof(int),
530 .proc_handler = proc_dointvec,
533 .procname = "cipso_rbm_strictvalid",
534 .data = &cipso_v4_rbm_strictvalid,
535 .maxlen = sizeof(int),
537 .proc_handler = proc_dointvec,
539 #endif /* CONFIG_NETLABEL */
541 .procname = "tcp_available_ulp",
542 .maxlen = TCP_ULP_BUF_MAX,
544 .proc_handler = proc_tcp_available_ulp,
547 .procname = "icmp_msgs_per_sec",
548 .data = &sysctl_icmp_msgs_per_sec,
549 .maxlen = sizeof(int),
551 .proc_handler = proc_dointvec_minmax,
552 .extra1 = SYSCTL_ZERO,
555 .procname = "icmp_msgs_burst",
556 .data = &sysctl_icmp_msgs_burst,
557 .maxlen = sizeof(int),
559 .proc_handler = proc_dointvec_minmax,
560 .extra1 = SYSCTL_ZERO,
563 .procname = "udp_mem",
564 .data = &sysctl_udp_mem,
565 .maxlen = sizeof(sysctl_udp_mem),
567 .proc_handler = proc_doulongvec_minmax,
570 .procname = "fib_sync_mem",
571 .data = &sysctl_fib_sync_mem,
572 .maxlen = sizeof(sysctl_fib_sync_mem),
574 .proc_handler = proc_douintvec_minmax,
575 .extra1 = &sysctl_fib_sync_mem_min,
576 .extra2 = &sysctl_fib_sync_mem_max,
581 static struct ctl_table ipv4_net_table[] = {
583 .procname = "tcp_max_tw_buckets",
584 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
585 .maxlen = sizeof(int),
587 .proc_handler = proc_dointvec
590 .procname = "icmp_echo_ignore_all",
591 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
592 .maxlen = sizeof(u8),
594 .proc_handler = proc_dou8vec_minmax,
595 .extra1 = SYSCTL_ZERO,
599 .procname = "icmp_echo_enable_probe",
600 .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe,
601 .maxlen = sizeof(u8),
603 .proc_handler = proc_dou8vec_minmax,
604 .extra1 = SYSCTL_ZERO,
608 .procname = "icmp_echo_ignore_broadcasts",
609 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
610 .maxlen = sizeof(u8),
612 .proc_handler = proc_dou8vec_minmax,
613 .extra1 = SYSCTL_ZERO,
617 .procname = "icmp_ignore_bogus_error_responses",
618 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
619 .maxlen = sizeof(u8),
621 .proc_handler = proc_dou8vec_minmax,
622 .extra1 = SYSCTL_ZERO,
626 .procname = "icmp_errors_use_inbound_ifaddr",
627 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
628 .maxlen = sizeof(u8),
630 .proc_handler = proc_dou8vec_minmax,
631 .extra1 = SYSCTL_ZERO,
635 .procname = "icmp_ratelimit",
636 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
637 .maxlen = sizeof(int),
639 .proc_handler = proc_dointvec_ms_jiffies,
642 .procname = "icmp_ratemask",
643 .data = &init_net.ipv4.sysctl_icmp_ratemask,
644 .maxlen = sizeof(int),
646 .proc_handler = proc_dointvec
649 .procname = "ping_group_range",
650 .data = &init_net.ipv4.ping_group_range.range,
651 .maxlen = sizeof(gid_t)*2,
653 .proc_handler = ipv4_ping_group_range,
655 #ifdef CONFIG_NET_L3_MASTER_DEV
657 .procname = "raw_l3mdev_accept",
658 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept,
659 .maxlen = sizeof(u8),
661 .proc_handler = proc_dou8vec_minmax,
662 .extra1 = SYSCTL_ZERO,
663 .extra2 = SYSCTL_ONE,
667 .procname = "tcp_ecn",
668 .data = &init_net.ipv4.sysctl_tcp_ecn,
669 .maxlen = sizeof(u8),
671 .proc_handler = proc_dou8vec_minmax,
672 .extra1 = SYSCTL_ZERO,
673 .extra2 = SYSCTL_TWO,
676 .procname = "tcp_ecn_fallback",
677 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
678 .maxlen = sizeof(u8),
680 .proc_handler = proc_dou8vec_minmax,
681 .extra1 = SYSCTL_ZERO,
682 .extra2 = SYSCTL_ONE,
685 .procname = "ip_dynaddr",
686 .data = &init_net.ipv4.sysctl_ip_dynaddr,
687 .maxlen = sizeof(u8),
689 .proc_handler = proc_dou8vec_minmax,
692 .procname = "ip_early_demux",
693 .data = &init_net.ipv4.sysctl_ip_early_demux,
694 .maxlen = sizeof(u8),
696 .proc_handler = proc_dou8vec_minmax,
699 .procname = "udp_early_demux",
700 .data = &init_net.ipv4.sysctl_udp_early_demux,
701 .maxlen = sizeof(u8),
703 .proc_handler = proc_dou8vec_minmax,
706 .procname = "tcp_early_demux",
707 .data = &init_net.ipv4.sysctl_tcp_early_demux,
708 .maxlen = sizeof(u8),
710 .proc_handler = proc_dou8vec_minmax,
713 .procname = "nexthop_compat_mode",
714 .data = &init_net.ipv4.sysctl_nexthop_compat_mode,
715 .maxlen = sizeof(u8),
717 .proc_handler = proc_dou8vec_minmax,
718 .extra1 = SYSCTL_ZERO,
719 .extra2 = SYSCTL_ONE,
722 .procname = "ip_default_ttl",
723 .data = &init_net.ipv4.sysctl_ip_default_ttl,
724 .maxlen = sizeof(u8),
726 .proc_handler = proc_dou8vec_minmax,
727 .extra1 = &ip_ttl_min,
728 .extra2 = &ip_ttl_max,
731 .procname = "ip_local_port_range",
735 .proc_handler = ipv4_local_port_range,
738 .procname = "ip_local_reserved_ports",
739 .data = &init_net.ipv4.sysctl_local_reserved_ports,
742 .proc_handler = proc_do_large_bitmap,
745 .procname = "ip_no_pmtu_disc",
746 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
747 .maxlen = sizeof(u8),
749 .proc_handler = proc_dou8vec_minmax,
752 .procname = "ip_forward_use_pmtu",
753 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
754 .maxlen = sizeof(u8),
756 .proc_handler = proc_dou8vec_minmax,
759 .procname = "ip_forward_update_priority",
760 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
761 .maxlen = sizeof(u8),
763 .proc_handler = ipv4_fwd_update_priority,
764 .extra1 = SYSCTL_ZERO,
765 .extra2 = SYSCTL_ONE,
768 .procname = "ip_nonlocal_bind",
769 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
770 .maxlen = sizeof(u8),
772 .proc_handler = proc_dou8vec_minmax,
775 .procname = "ip_autobind_reuse",
776 .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
777 .maxlen = sizeof(u8),
779 .proc_handler = proc_dou8vec_minmax,
780 .extra1 = SYSCTL_ZERO,
781 .extra2 = SYSCTL_ONE,
784 .procname = "fwmark_reflect",
785 .data = &init_net.ipv4.sysctl_fwmark_reflect,
786 .maxlen = sizeof(u8),
788 .proc_handler = proc_dou8vec_minmax,
791 .procname = "tcp_fwmark_accept",
792 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
793 .maxlen = sizeof(u8),
795 .proc_handler = proc_dou8vec_minmax,
797 #ifdef CONFIG_NET_L3_MASTER_DEV
799 .procname = "tcp_l3mdev_accept",
800 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
801 .maxlen = sizeof(u8),
803 .proc_handler = proc_dou8vec_minmax,
804 .extra1 = SYSCTL_ZERO,
805 .extra2 = SYSCTL_ONE,
809 .procname = "tcp_mtu_probing",
810 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
811 .maxlen = sizeof(u8),
813 .proc_handler = proc_dou8vec_minmax,
816 .procname = "tcp_base_mss",
817 .data = &init_net.ipv4.sysctl_tcp_base_mss,
818 .maxlen = sizeof(int),
820 .proc_handler = proc_dointvec,
823 .procname = "tcp_min_snd_mss",
824 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
825 .maxlen = sizeof(int),
827 .proc_handler = proc_dointvec_minmax,
828 .extra1 = &tcp_min_snd_mss_min,
829 .extra2 = &tcp_min_snd_mss_max,
832 .procname = "tcp_mtu_probe_floor",
833 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
834 .maxlen = sizeof(int),
836 .proc_handler = proc_dointvec_minmax,
837 .extra1 = &tcp_min_snd_mss_min,
838 .extra2 = &tcp_min_snd_mss_max,
841 .procname = "tcp_probe_threshold",
842 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
843 .maxlen = sizeof(int),
845 .proc_handler = proc_dointvec,
848 .procname = "tcp_probe_interval",
849 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
850 .maxlen = sizeof(u32),
852 .proc_handler = proc_douintvec_minmax,
853 .extra2 = &u32_max_div_HZ,
856 .procname = "igmp_link_local_mcast_reports",
857 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
858 .maxlen = sizeof(u8),
860 .proc_handler = proc_dou8vec_minmax,
863 .procname = "igmp_max_memberships",
864 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
865 .maxlen = sizeof(int),
867 .proc_handler = proc_dointvec
870 .procname = "igmp_max_msf",
871 .data = &init_net.ipv4.sysctl_igmp_max_msf,
872 .maxlen = sizeof(int),
874 .proc_handler = proc_dointvec
876 #ifdef CONFIG_IP_MULTICAST
878 .procname = "igmp_qrv",
879 .data = &init_net.ipv4.sysctl_igmp_qrv,
880 .maxlen = sizeof(int),
882 .proc_handler = proc_dointvec_minmax,
887 .procname = "tcp_congestion_control",
888 .data = &init_net.ipv4.tcp_congestion_control,
890 .maxlen = TCP_CA_NAME_MAX,
891 .proc_handler = proc_tcp_congestion_control,
894 .procname = "tcp_available_congestion_control",
895 .maxlen = TCP_CA_BUF_MAX,
897 .proc_handler = proc_tcp_available_congestion_control,
900 .procname = "tcp_allowed_congestion_control",
901 .maxlen = TCP_CA_BUF_MAX,
903 .proc_handler = proc_allowed_congestion_control,
906 .procname = "tcp_keepalive_time",
907 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
908 .maxlen = sizeof(int),
910 .proc_handler = proc_dointvec_jiffies,
913 .procname = "tcp_keepalive_probes",
914 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
915 .maxlen = sizeof(u8),
917 .proc_handler = proc_dou8vec_minmax,
920 .procname = "tcp_keepalive_intvl",
921 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
922 .maxlen = sizeof(int),
924 .proc_handler = proc_dointvec_jiffies,
927 .procname = "tcp_syn_retries",
928 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
929 .maxlen = sizeof(u8),
931 .proc_handler = proc_dou8vec_minmax,
932 .extra1 = &tcp_syn_retries_min,
933 .extra2 = &tcp_syn_retries_max
936 .procname = "tcp_synack_retries",
937 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
938 .maxlen = sizeof(u8),
940 .proc_handler = proc_dou8vec_minmax,
942 #ifdef CONFIG_SYN_COOKIES
944 .procname = "tcp_syncookies",
945 .data = &init_net.ipv4.sysctl_tcp_syncookies,
946 .maxlen = sizeof(u8),
948 .proc_handler = proc_dou8vec_minmax,
952 .procname = "tcp_migrate_req",
953 .data = &init_net.ipv4.sysctl_tcp_migrate_req,
954 .maxlen = sizeof(u8),
956 .proc_handler = proc_dou8vec_minmax,
957 .extra1 = SYSCTL_ZERO,
961 .procname = "tcp_reordering",
962 .data = &init_net.ipv4.sysctl_tcp_reordering,
963 .maxlen = sizeof(int),
965 .proc_handler = proc_dointvec
968 .procname = "tcp_retries1",
969 .data = &init_net.ipv4.sysctl_tcp_retries1,
970 .maxlen = sizeof(u8),
972 .proc_handler = proc_dou8vec_minmax,
973 .extra2 = &tcp_retr1_max
976 .procname = "tcp_retries2",
977 .data = &init_net.ipv4.sysctl_tcp_retries2,
978 .maxlen = sizeof(u8),
980 .proc_handler = proc_dou8vec_minmax,
983 .procname = "tcp_orphan_retries",
984 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
985 .maxlen = sizeof(u8),
987 .proc_handler = proc_dou8vec_minmax,
990 .procname = "tcp_fin_timeout",
991 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
992 .maxlen = sizeof(int),
994 .proc_handler = proc_dointvec_jiffies,
997 .procname = "tcp_notsent_lowat",
998 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
999 .maxlen = sizeof(unsigned int),
1001 .proc_handler = proc_douintvec,
1004 .procname = "tcp_tw_reuse",
1005 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
1006 .maxlen = sizeof(u8),
1008 .proc_handler = proc_dou8vec_minmax,
1009 .extra1 = SYSCTL_ZERO,
1010 .extra2 = SYSCTL_TWO,
1013 .procname = "tcp_max_syn_backlog",
1014 .data = &init_net.ipv4.sysctl_max_syn_backlog,
1015 .maxlen = sizeof(int),
1017 .proc_handler = proc_dointvec
1020 .procname = "tcp_fastopen",
1021 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1022 .maxlen = sizeof(int),
1024 .proc_handler = proc_dointvec,
1027 .procname = "tcp_fastopen_key",
1029 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1030 /* maxlen to print the list of keys in hex (*2), with dashes
1031 * separating doublewords and a comma in between keys.
1033 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
1034 2 * TCP_FASTOPEN_KEY_MAX) +
1035 (TCP_FASTOPEN_KEY_MAX * 5)),
1036 .proc_handler = proc_tcp_fastopen_key,
1039 .procname = "tcp_fastopen_blackhole_timeout_sec",
1040 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1041 .maxlen = sizeof(int),
1043 .proc_handler = proc_tfo_blackhole_detect_timeout,
1044 .extra1 = SYSCTL_ZERO,
1046 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1048 .procname = "fib_multipath_use_neigh",
1049 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1050 .maxlen = sizeof(u8),
1052 .proc_handler = proc_dou8vec_minmax,
1053 .extra1 = SYSCTL_ZERO,
1054 .extra2 = SYSCTL_ONE,
1057 .procname = "fib_multipath_hash_policy",
1058 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1059 .maxlen = sizeof(u8),
1061 .proc_handler = proc_fib_multipath_hash_policy,
1062 .extra1 = SYSCTL_ZERO,
1063 .extra2 = SYSCTL_THREE,
1066 .procname = "fib_multipath_hash_fields",
1067 .data = &init_net.ipv4.sysctl_fib_multipath_hash_fields,
1068 .maxlen = sizeof(u32),
1070 .proc_handler = proc_fib_multipath_hash_fields,
1071 .extra1 = SYSCTL_ONE,
1072 .extra2 = &fib_multipath_hash_fields_all_mask,
1076 .procname = "ip_unprivileged_port_start",
1077 .maxlen = sizeof(int),
1078 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1080 .proc_handler = ipv4_privileged_ports,
1082 #ifdef CONFIG_NET_L3_MASTER_DEV
1084 .procname = "udp_l3mdev_accept",
1085 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1086 .maxlen = sizeof(u8),
1088 .proc_handler = proc_dou8vec_minmax,
1089 .extra1 = SYSCTL_ZERO,
1090 .extra2 = SYSCTL_ONE,
1094 .procname = "tcp_sack",
1095 .data = &init_net.ipv4.sysctl_tcp_sack,
1096 .maxlen = sizeof(u8),
1098 .proc_handler = proc_dou8vec_minmax,
1101 .procname = "tcp_window_scaling",
1102 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1103 .maxlen = sizeof(u8),
1105 .proc_handler = proc_dou8vec_minmax,
1108 .procname = "tcp_timestamps",
1109 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1110 .maxlen = sizeof(u8),
1112 .proc_handler = proc_dou8vec_minmax,
1115 .procname = "tcp_early_retrans",
1116 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
1117 .maxlen = sizeof(u8),
1119 .proc_handler = proc_dou8vec_minmax,
1120 .extra1 = SYSCTL_ZERO,
1121 .extra2 = SYSCTL_FOUR,
1124 .procname = "tcp_recovery",
1125 .data = &init_net.ipv4.sysctl_tcp_recovery,
1126 .maxlen = sizeof(u8),
1128 .proc_handler = proc_dou8vec_minmax,
1131 .procname = "tcp_thin_linear_timeouts",
1132 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1133 .maxlen = sizeof(u8),
1135 .proc_handler = proc_dou8vec_minmax,
1138 .procname = "tcp_slow_start_after_idle",
1139 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1140 .maxlen = sizeof(u8),
1142 .proc_handler = proc_dou8vec_minmax,
1145 .procname = "tcp_retrans_collapse",
1146 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1147 .maxlen = sizeof(u8),
1149 .proc_handler = proc_dou8vec_minmax,
1152 .procname = "tcp_stdurg",
1153 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1154 .maxlen = sizeof(u8),
1156 .proc_handler = proc_dou8vec_minmax,
1159 .procname = "tcp_rfc1337",
1160 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1161 .maxlen = sizeof(u8),
1163 .proc_handler = proc_dou8vec_minmax,
1166 .procname = "tcp_abort_on_overflow",
1167 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1168 .maxlen = sizeof(u8),
1170 .proc_handler = proc_dou8vec_minmax,
1173 .procname = "tcp_fack",
1174 .data = &init_net.ipv4.sysctl_tcp_fack,
1175 .maxlen = sizeof(u8),
1177 .proc_handler = proc_dou8vec_minmax,
1180 .procname = "tcp_max_reordering",
1181 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1182 .maxlen = sizeof(int),
1184 .proc_handler = proc_dointvec
1187 .procname = "tcp_dsack",
1188 .data = &init_net.ipv4.sysctl_tcp_dsack,
1189 .maxlen = sizeof(u8),
1191 .proc_handler = proc_dou8vec_minmax,
1194 .procname = "tcp_app_win",
1195 .data = &init_net.ipv4.sysctl_tcp_app_win,
1196 .maxlen = sizeof(u8),
1198 .proc_handler = proc_dou8vec_minmax,
1199 .extra1 = SYSCTL_ZERO,
1200 .extra2 = &tcp_app_win_max,
1203 .procname = "tcp_adv_win_scale",
1204 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1205 .maxlen = sizeof(int),
1207 .proc_handler = proc_dointvec_minmax,
1208 .extra1 = &tcp_adv_win_scale_min,
1209 .extra2 = &tcp_adv_win_scale_max,
1212 .procname = "tcp_frto",
1213 .data = &init_net.ipv4.sysctl_tcp_frto,
1214 .maxlen = sizeof(u8),
1216 .proc_handler = proc_dou8vec_minmax,
1219 .procname = "tcp_no_metrics_save",
1220 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1221 .maxlen = sizeof(u8),
1223 .proc_handler = proc_dou8vec_minmax,
1226 .procname = "tcp_no_ssthresh_metrics_save",
1227 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1228 .maxlen = sizeof(u8),
1230 .proc_handler = proc_dou8vec_minmax,
1231 .extra1 = SYSCTL_ZERO,
1232 .extra2 = SYSCTL_ONE,
1235 .procname = "tcp_moderate_rcvbuf",
1236 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1237 .maxlen = sizeof(u8),
1239 .proc_handler = proc_dou8vec_minmax,
1242 .procname = "tcp_tso_win_divisor",
1243 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1244 .maxlen = sizeof(u8),
1246 .proc_handler = proc_dou8vec_minmax,
1249 .procname = "tcp_workaround_signed_windows",
1250 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1251 .maxlen = sizeof(u8),
1253 .proc_handler = proc_dou8vec_minmax,
1256 .procname = "tcp_limit_output_bytes",
1257 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1258 .maxlen = sizeof(int),
1260 .proc_handler = proc_dointvec
1263 .procname = "tcp_challenge_ack_limit",
1264 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1265 .maxlen = sizeof(int),
1267 .proc_handler = proc_dointvec
1270 .procname = "tcp_min_tso_segs",
1271 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1272 .maxlen = sizeof(u8),
1274 .proc_handler = proc_dou8vec_minmax,
1275 .extra1 = SYSCTL_ONE,
1278 .procname = "tcp_tso_rtt_log",
1279 .data = &init_net.ipv4.sysctl_tcp_tso_rtt_log,
1280 .maxlen = sizeof(u8),
1282 .proc_handler = proc_dou8vec_minmax,
1285 .procname = "tcp_min_rtt_wlen",
1286 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1287 .maxlen = sizeof(int),
1289 .proc_handler = proc_dointvec_minmax,
1290 .extra1 = SYSCTL_ZERO,
1291 .extra2 = &one_day_secs
1294 .procname = "tcp_autocorking",
1295 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1296 .maxlen = sizeof(u8),
1298 .proc_handler = proc_dou8vec_minmax,
1299 .extra1 = SYSCTL_ZERO,
1300 .extra2 = SYSCTL_ONE,
1303 .procname = "tcp_invalid_ratelimit",
1304 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1305 .maxlen = sizeof(int),
1307 .proc_handler = proc_dointvec_ms_jiffies,
1310 .procname = "tcp_pacing_ss_ratio",
1311 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1312 .maxlen = sizeof(int),
1314 .proc_handler = proc_dointvec_minmax,
1315 .extra1 = SYSCTL_ZERO,
1316 .extra2 = SYSCTL_ONE_THOUSAND,
1319 .procname = "tcp_pacing_ca_ratio",
1320 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1321 .maxlen = sizeof(int),
1323 .proc_handler = proc_dointvec_minmax,
1324 .extra1 = SYSCTL_ZERO,
1325 .extra2 = SYSCTL_ONE_THOUSAND,
1328 .procname = "tcp_wmem",
1329 .data = &init_net.ipv4.sysctl_tcp_wmem,
1330 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
1332 .proc_handler = proc_dointvec_minmax,
1333 .extra1 = SYSCTL_ONE,
1336 .procname = "tcp_rmem",
1337 .data = &init_net.ipv4.sysctl_tcp_rmem,
1338 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
1340 .proc_handler = proc_dointvec_minmax,
1341 .extra1 = SYSCTL_ONE,
1344 .procname = "tcp_comp_sack_delay_ns",
1345 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1346 .maxlen = sizeof(unsigned long),
1348 .proc_handler = proc_doulongvec_minmax,
1351 .procname = "tcp_comp_sack_slack_ns",
1352 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1353 .maxlen = sizeof(unsigned long),
1355 .proc_handler = proc_doulongvec_minmax,
1358 .procname = "tcp_comp_sack_nr",
1359 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1360 .maxlen = sizeof(u8),
1362 .proc_handler = proc_dou8vec_minmax,
1363 .extra1 = SYSCTL_ZERO,
1366 .procname = "tcp_backlog_ack_defer",
1367 .data = &init_net.ipv4.sysctl_tcp_backlog_ack_defer,
1368 .maxlen = sizeof(u8),
1370 .proc_handler = proc_dou8vec_minmax,
1371 .extra1 = SYSCTL_ZERO,
1372 .extra2 = SYSCTL_ONE,
1375 .procname = "tcp_reflect_tos",
1376 .data = &init_net.ipv4.sysctl_tcp_reflect_tos,
1377 .maxlen = sizeof(u8),
1379 .proc_handler = proc_dou8vec_minmax,
1380 .extra1 = SYSCTL_ZERO,
1381 .extra2 = SYSCTL_ONE,
1384 .procname = "tcp_ehash_entries",
1385 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1387 .proc_handler = proc_tcp_ehash_entries,
1390 .procname = "tcp_child_ehash_entries",
1391 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1392 .maxlen = sizeof(unsigned int),
1394 .proc_handler = proc_douintvec_minmax,
1395 .extra1 = SYSCTL_ZERO,
1396 .extra2 = &tcp_child_ehash_entries_max,
1399 .procname = "udp_hash_entries",
1400 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1402 .proc_handler = proc_udp_hash_entries,
1405 .procname = "udp_child_hash_entries",
1406 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1407 .maxlen = sizeof(unsigned int),
1409 .proc_handler = proc_douintvec_minmax,
1410 .extra1 = SYSCTL_ZERO,
1411 .extra2 = &udp_child_hash_entries_max,
1414 .procname = "udp_rmem_min",
1415 .data = &init_net.ipv4.sysctl_udp_rmem_min,
1416 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1418 .proc_handler = proc_dointvec_minmax,
1419 .extra1 = SYSCTL_ONE
1422 .procname = "udp_wmem_min",
1423 .data = &init_net.ipv4.sysctl_udp_wmem_min,
1424 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1426 .proc_handler = proc_dointvec_minmax,
1427 .extra1 = SYSCTL_ONE
1430 .procname = "fib_notify_on_flag_change",
1431 .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,
1432 .maxlen = sizeof(u8),
1434 .proc_handler = proc_dou8vec_minmax,
1435 .extra1 = SYSCTL_ZERO,
1436 .extra2 = SYSCTL_TWO,
1439 .procname = "tcp_plb_enabled",
1440 .data = &init_net.ipv4.sysctl_tcp_plb_enabled,
1441 .maxlen = sizeof(u8),
1443 .proc_handler = proc_dou8vec_minmax,
1444 .extra1 = SYSCTL_ZERO,
1445 .extra2 = SYSCTL_ONE,
1448 .procname = "tcp_plb_idle_rehash_rounds",
1449 .data = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds,
1450 .maxlen = sizeof(u8),
1452 .proc_handler = proc_dou8vec_minmax,
1453 .extra2 = &tcp_plb_max_rounds,
1456 .procname = "tcp_plb_rehash_rounds",
1457 .data = &init_net.ipv4.sysctl_tcp_plb_rehash_rounds,
1458 .maxlen = sizeof(u8),
1460 .proc_handler = proc_dou8vec_minmax,
1461 .extra2 = &tcp_plb_max_rounds,
1464 .procname = "tcp_plb_suspend_rto_sec",
1465 .data = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec,
1466 .maxlen = sizeof(u8),
1468 .proc_handler = proc_dou8vec_minmax,
1471 .procname = "tcp_plb_cong_thresh",
1472 .data = &init_net.ipv4.sysctl_tcp_plb_cong_thresh,
1473 .maxlen = sizeof(int),
1475 .proc_handler = proc_dointvec_minmax,
1476 .extra1 = SYSCTL_ZERO,
1477 .extra2 = &tcp_plb_max_cong_thresh,
1480 .procname = "tcp_syn_linear_timeouts",
1481 .data = &init_net.ipv4.sysctl_tcp_syn_linear_timeouts,
1482 .maxlen = sizeof(u8),
1484 .proc_handler = proc_dou8vec_minmax,
1485 .extra1 = SYSCTL_ZERO,
1486 .extra2 = &tcp_syn_linear_timeouts_max,
1489 .procname = "tcp_shrink_window",
1490 .data = &init_net.ipv4.sysctl_tcp_shrink_window,
1491 .maxlen = sizeof(u8),
1493 .proc_handler = proc_dou8vec_minmax,
1494 .extra1 = SYSCTL_ZERO,
1495 .extra2 = SYSCTL_ONE,
1498 .procname = "tcp_pingpong_thresh",
1499 .data = &init_net.ipv4.sysctl_tcp_pingpong_thresh,
1500 .maxlen = sizeof(u8),
1502 .proc_handler = proc_dou8vec_minmax,
1503 .extra1 = SYSCTL_ONE,
1508 static __net_init int ipv4_sysctl_init_net(struct net *net)
1510 struct ctl_table *table;
1512 table = ipv4_net_table;
1513 if (!net_eq(net, &init_net)) {
1516 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1520 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) {
1521 if (table[i].data) {
1522 /* Update the variables to point into
1523 * the current struct net
1525 table[i].data += (void *)net - (void *)&init_net;
1527 /* Entries without data pointer are global;
1528 * Make them read-only in non-init_net ns
1530 table[i].mode &= ~0222;
1535 net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table,
1536 ARRAY_SIZE(ipv4_net_table));
1537 if (!net->ipv4.ipv4_hdr)
1540 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1541 if (!net->ipv4.sysctl_local_reserved_ports)
1547 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1549 if (!net_eq(net, &init_net))
1555 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1557 struct ctl_table *table;
1559 kfree(net->ipv4.sysctl_local_reserved_ports);
1560 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1561 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1565 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1566 .init = ipv4_sysctl_init_net,
1567 .exit = ipv4_sysctl_exit_net,
1570 static __init int sysctl_ipv4_init(void)
1572 struct ctl_table_header *hdr;
1574 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1578 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1579 unregister_net_sysctl_table(hdr);
1586 __initcall(sysctl_ipv4_init);