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]
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>
22 #include <net/route.h>
25 #include <net/cipso_ipv4.h>
26 #include <net/inet_frag.h>
28 #include <net/protocol.h>
29 #include <net/netevent.h>
35 static int thousand
= 1000;
36 static int gso_max_segs
= GSO_MAX_SEGS
;
37 static int tcp_retr1_max
= 255;
38 static int ip_local_port_range_min
[] = { 1, 1 };
39 static int ip_local_port_range_max
[] = { 65535, 65535 };
40 static int tcp_adv_win_scale_min
= -31;
41 static int tcp_adv_win_scale_max
= 31;
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;
53 static int sysctl_tcp_low_latency __read_mostly
;
55 /* Update system visible IP port range */
56 static void set_local_port_range(struct net
*net
, int range
[2])
58 bool same_parity
= !((range
[0] ^ range
[1]) & 1);
60 write_seqlock_bh(&net
->ipv4
.ip_local_ports
.lock
);
61 if (same_parity
&& !net
->ipv4
.ip_local_ports
.warned
) {
62 net
->ipv4
.ip_local_ports
.warned
= true;
63 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
65 net
->ipv4
.ip_local_ports
.range
[0] = range
[0];
66 net
->ipv4
.ip_local_ports
.range
[1] = range
[1];
67 write_sequnlock_bh(&net
->ipv4
.ip_local_ports
.lock
);
70 /* Validate changes from /proc interface. */
71 static int ipv4_local_port_range(struct ctl_table
*table
, int write
,
73 size_t *lenp
, loff_t
*ppos
)
76 container_of(table
->data
, struct net
, ipv4
.ip_local_ports
.range
);
79 struct ctl_table tmp
= {
81 .maxlen
= sizeof(range
),
83 .extra1
= &ip_local_port_range_min
,
84 .extra2
= &ip_local_port_range_max
,
87 inet_get_local_port_range(net
, &range
[0], &range
[1]);
89 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
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
96 if ((range
[1] < range
[0]) ||
97 (range
[0] < net
->ipv4
.sysctl_ip_prot_sock
))
100 set_local_port_range(net
, range
);
106 /* Validate changes from /proc interface. */
107 static int ipv4_privileged_ports(struct ctl_table
*table
, int write
,
108 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
110 struct net
*net
= container_of(table
->data
, struct net
,
111 ipv4
.sysctl_ip_prot_sock
);
115 struct ctl_table tmp
= {
117 .maxlen
= sizeof(pports
),
119 .extra1
= &ip_privileged_port_min
,
120 .extra2
= &ip_privileged_port_max
,
123 pports
= net
->ipv4
.sysctl_ip_prot_sock
;
125 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
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.
132 if (range
[0] < pports
)
135 net
->ipv4
.sysctl_ip_prot_sock
= pports
;
141 static void inet_get_ping_group_range_table(struct ctl_table
*table
, kgid_t
*low
, kgid_t
*high
)
143 kgid_t
*data
= table
->data
;
145 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
148 seq
= read_seqbegin(&net
->ipv4
.ping_group_range
.lock
);
152 } while (read_seqretry(&net
->ipv4
.ping_group_range
.lock
, seq
));
155 /* Update system visible IP port range */
156 static void set_ping_group_range(struct ctl_table
*table
, kgid_t low
, kgid_t high
)
158 kgid_t
*data
= table
->data
;
160 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
161 write_seqlock(&net
->ipv4
.ping_group_range
.lock
);
164 write_sequnlock(&net
->ipv4
.ping_group_range
.lock
);
167 /* Validate changes from /proc interface. */
168 static int ipv4_ping_group_range(struct ctl_table
*table
, int write
,
170 size_t *lenp
, loff_t
*ppos
)
172 struct user_namespace
*user_ns
= current_user_ns();
176 struct ctl_table tmp
= {
178 .maxlen
= sizeof(urange
),
180 .extra1
= &ip_ping_group_range_min
,
181 .extra2
= &ip_ping_group_range_max
,
184 inet_get_ping_group_range_table(table
, &low
, &high
);
185 urange
[0] = from_kgid_munged(user_ns
, low
);
186 urange
[1] = from_kgid_munged(user_ns
, high
);
187 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
189 if (write
&& ret
== 0) {
190 low
= make_kgid(user_ns
, urange
[0]);
191 high
= make_kgid(user_ns
, urange
[1]);
192 if (!gid_valid(low
) || !gid_valid(high
))
194 if (urange
[1] < urange
[0] || gid_lt(high
, low
)) {
195 low
= make_kgid(&init_user_ns
, 1);
196 high
= make_kgid(&init_user_ns
, 0);
198 set_ping_group_range(table
, low
, high
);
204 static int proc_tcp_congestion_control(struct ctl_table
*ctl
, int write
,
205 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
207 struct net
*net
= container_of(ctl
->data
, struct net
,
208 ipv4
.tcp_congestion_control
);
209 char val
[TCP_CA_NAME_MAX
];
210 struct ctl_table tbl
= {
212 .maxlen
= TCP_CA_NAME_MAX
,
216 tcp_get_default_congestion_control(net
, val
);
218 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
219 if (write
&& ret
== 0)
220 ret
= tcp_set_default_congestion_control(net
, val
);
224 static int proc_tcp_available_congestion_control(struct ctl_table
*ctl
,
226 void __user
*buffer
, size_t *lenp
,
229 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
232 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
235 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
236 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
241 static int proc_allowed_congestion_control(struct ctl_table
*ctl
,
243 void __user
*buffer
, size_t *lenp
,
246 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
249 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
253 tcp_get_allowed_congestion_control(tbl
.data
, tbl
.maxlen
);
254 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
255 if (write
&& ret
== 0)
256 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
261 static int proc_tcp_fastopen_key(struct ctl_table
*table
, int write
,
262 void __user
*buffer
, size_t *lenp
,
265 struct net
*net
= container_of(table
->data
, struct net
,
266 ipv4
.sysctl_tcp_fastopen
);
267 struct ctl_table tbl
= { .maxlen
= (TCP_FASTOPEN_KEY_LENGTH
* 2 + 10) };
268 struct tcp_fastopen_context
*ctxt
;
269 u32 user_key
[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
273 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_KERNEL
);
278 ctxt
= rcu_dereference(net
->ipv4
.tcp_fastopen_ctx
);
280 memcpy(key
, ctxt
->key
, TCP_FASTOPEN_KEY_LENGTH
);
282 memset(key
, 0, sizeof(key
));
285 for (i
= 0; i
< ARRAY_SIZE(key
); i
++)
286 user_key
[i
] = le32_to_cpu(key
[i
]);
288 snprintf(tbl
.data
, tbl
.maxlen
, "%08x-%08x-%08x-%08x",
289 user_key
[0], user_key
[1], user_key
[2], user_key
[3]);
290 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
292 if (write
&& ret
== 0) {
293 if (sscanf(tbl
.data
, "%x-%x-%x-%x", user_key
, user_key
+ 1,
294 user_key
+ 2, user_key
+ 3) != 4) {
299 for (i
= 0; i
< ARRAY_SIZE(user_key
); i
++)
300 key
[i
] = cpu_to_le32(user_key
[i
]);
302 tcp_fastopen_reset_cipher(net
, NULL
, key
,
303 TCP_FASTOPEN_KEY_LENGTH
);
307 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
308 user_key
[0], user_key
[1], user_key
[2], user_key
[3],
309 (char *)tbl
.data
, ret
);
314 static void proc_configure_early_demux(int enabled
, int protocol
)
316 struct net_protocol
*ipprot
;
317 #if IS_ENABLED(CONFIG_IPV6)
318 struct inet6_protocol
*ip6prot
;
323 ipprot
= rcu_dereference(inet_protos
[protocol
]);
325 ipprot
->early_demux
= enabled
? ipprot
->early_demux_handler
:
328 #if IS_ENABLED(CONFIG_IPV6)
329 ip6prot
= rcu_dereference(inet6_protos
[protocol
]);
331 ip6prot
->early_demux
= enabled
? ip6prot
->early_demux_handler
:
337 static int proc_tcp_early_demux(struct ctl_table
*table
, int write
,
338 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
342 ret
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
345 int enabled
= init_net
.ipv4
.sysctl_tcp_early_demux
;
347 proc_configure_early_demux(enabled
, IPPROTO_TCP
);
353 static int proc_udp_early_demux(struct ctl_table
*table
, int write
,
354 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
358 ret
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
361 int enabled
= init_net
.ipv4
.sysctl_udp_early_demux
;
363 proc_configure_early_demux(enabled
, IPPROTO_UDP
);
369 static int proc_tfo_blackhole_detect_timeout(struct ctl_table
*table
,
372 size_t *lenp
, loff_t
*ppos
)
374 struct net
*net
= container_of(table
->data
, struct net
,
375 ipv4
.sysctl_tcp_fastopen_blackhole_timeout
);
378 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
379 if (write
&& ret
== 0)
380 atomic_set(&net
->ipv4
.tfo_active_disable_times
, 0);
385 static int proc_tcp_available_ulp(struct ctl_table
*ctl
,
387 void __user
*buffer
, size_t *lenp
,
390 struct ctl_table tbl
= { .maxlen
= TCP_ULP_BUF_MAX
, };
393 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
396 tcp_get_available_ulp(tbl
.data
, TCP_ULP_BUF_MAX
);
397 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
403 #ifdef CONFIG_IP_ROUTE_MULTIPATH
404 static int proc_fib_multipath_hash_policy(struct ctl_table
*table
, int write
,
405 void __user
*buffer
, size_t *lenp
,
408 struct net
*net
= container_of(table
->data
, struct net
,
409 ipv4
.sysctl_fib_multipath_hash_policy
);
412 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
413 if (write
&& ret
== 0)
414 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE
, net
);
420 static struct ctl_table ipv4_table
[] = {
422 .procname
= "tcp_max_orphans",
423 .data
= &sysctl_tcp_max_orphans
,
424 .maxlen
= sizeof(int),
426 .proc_handler
= proc_dointvec
429 .procname
= "inet_peer_threshold",
430 .data
= &inet_peer_threshold
,
431 .maxlen
= sizeof(int),
433 .proc_handler
= proc_dointvec
436 .procname
= "inet_peer_minttl",
437 .data
= &inet_peer_minttl
,
438 .maxlen
= sizeof(int),
440 .proc_handler
= proc_dointvec_jiffies
,
443 .procname
= "inet_peer_maxttl",
444 .data
= &inet_peer_maxttl
,
445 .maxlen
= sizeof(int),
447 .proc_handler
= proc_dointvec_jiffies
,
450 .procname
= "tcp_mem",
451 .maxlen
= sizeof(sysctl_tcp_mem
),
452 .data
= &sysctl_tcp_mem
,
454 .proc_handler
= proc_doulongvec_minmax
,
457 .procname
= "tcp_low_latency",
458 .data
= &sysctl_tcp_low_latency
,
459 .maxlen
= sizeof(int),
461 .proc_handler
= proc_dointvec
463 #ifdef CONFIG_NETLABEL
465 .procname
= "cipso_cache_enable",
466 .data
= &cipso_v4_cache_enabled
,
467 .maxlen
= sizeof(int),
469 .proc_handler
= proc_dointvec
,
472 .procname
= "cipso_cache_bucket_size",
473 .data
= &cipso_v4_cache_bucketsize
,
474 .maxlen
= sizeof(int),
476 .proc_handler
= proc_dointvec
,
479 .procname
= "cipso_rbm_optfmt",
480 .data
= &cipso_v4_rbm_optfmt
,
481 .maxlen
= sizeof(int),
483 .proc_handler
= proc_dointvec
,
486 .procname
= "cipso_rbm_strictvalid",
487 .data
= &cipso_v4_rbm_strictvalid
,
488 .maxlen
= sizeof(int),
490 .proc_handler
= proc_dointvec
,
492 #endif /* CONFIG_NETLABEL */
494 .procname
= "tcp_available_congestion_control",
495 .maxlen
= TCP_CA_BUF_MAX
,
497 .proc_handler
= proc_tcp_available_congestion_control
,
500 .procname
= "tcp_allowed_congestion_control",
501 .maxlen
= TCP_CA_BUF_MAX
,
503 .proc_handler
= proc_allowed_congestion_control
,
506 .procname
= "tcp_available_ulp",
507 .maxlen
= TCP_ULP_BUF_MAX
,
509 .proc_handler
= proc_tcp_available_ulp
,
512 .procname
= "icmp_msgs_per_sec",
513 .data
= &sysctl_icmp_msgs_per_sec
,
514 .maxlen
= sizeof(int),
516 .proc_handler
= proc_dointvec_minmax
,
520 .procname
= "icmp_msgs_burst",
521 .data
= &sysctl_icmp_msgs_burst
,
522 .maxlen
= sizeof(int),
524 .proc_handler
= proc_dointvec_minmax
,
528 .procname
= "udp_mem",
529 .data
= &sysctl_udp_mem
,
530 .maxlen
= sizeof(sysctl_udp_mem
),
532 .proc_handler
= proc_doulongvec_minmax
,
537 static struct ctl_table ipv4_net_table
[] = {
539 .procname
= "icmp_echo_ignore_all",
540 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_all
,
541 .maxlen
= sizeof(int),
543 .proc_handler
= proc_dointvec
546 .procname
= "icmp_echo_ignore_broadcasts",
547 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_broadcasts
,
548 .maxlen
= sizeof(int),
550 .proc_handler
= proc_dointvec
553 .procname
= "icmp_ignore_bogus_error_responses",
554 .data
= &init_net
.ipv4
.sysctl_icmp_ignore_bogus_error_responses
,
555 .maxlen
= sizeof(int),
557 .proc_handler
= proc_dointvec
560 .procname
= "icmp_errors_use_inbound_ifaddr",
561 .data
= &init_net
.ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
,
562 .maxlen
= sizeof(int),
564 .proc_handler
= proc_dointvec
567 .procname
= "icmp_ratelimit",
568 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
569 .maxlen
= sizeof(int),
571 .proc_handler
= proc_dointvec_ms_jiffies
,
574 .procname
= "icmp_ratemask",
575 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
576 .maxlen
= sizeof(int),
578 .proc_handler
= proc_dointvec
581 .procname
= "ping_group_range",
582 .data
= &init_net
.ipv4
.ping_group_range
.range
,
583 .maxlen
= sizeof(gid_t
)*2,
585 .proc_handler
= ipv4_ping_group_range
,
588 .procname
= "tcp_ecn",
589 .data
= &init_net
.ipv4
.sysctl_tcp_ecn
,
590 .maxlen
= sizeof(int),
592 .proc_handler
= proc_dointvec
595 .procname
= "tcp_ecn_fallback",
596 .data
= &init_net
.ipv4
.sysctl_tcp_ecn_fallback
,
597 .maxlen
= sizeof(int),
599 .proc_handler
= proc_dointvec
602 .procname
= "ip_dynaddr",
603 .data
= &init_net
.ipv4
.sysctl_ip_dynaddr
,
604 .maxlen
= sizeof(int),
606 .proc_handler
= proc_dointvec
609 .procname
= "ip_early_demux",
610 .data
= &init_net
.ipv4
.sysctl_ip_early_demux
,
611 .maxlen
= sizeof(int),
613 .proc_handler
= proc_dointvec
616 .procname
= "udp_early_demux",
617 .data
= &init_net
.ipv4
.sysctl_udp_early_demux
,
618 .maxlen
= sizeof(int),
620 .proc_handler
= proc_udp_early_demux
623 .procname
= "tcp_early_demux",
624 .data
= &init_net
.ipv4
.sysctl_tcp_early_demux
,
625 .maxlen
= sizeof(int),
627 .proc_handler
= proc_tcp_early_demux
630 .procname
= "ip_default_ttl",
631 .data
= &init_net
.ipv4
.sysctl_ip_default_ttl
,
632 .maxlen
= sizeof(int),
634 .proc_handler
= proc_dointvec_minmax
,
635 .extra1
= &ip_ttl_min
,
636 .extra2
= &ip_ttl_max
,
639 .procname
= "ip_local_port_range",
640 .maxlen
= sizeof(init_net
.ipv4
.ip_local_ports
.range
),
641 .data
= &init_net
.ipv4
.ip_local_ports
.range
,
643 .proc_handler
= ipv4_local_port_range
,
646 .procname
= "ip_local_reserved_ports",
647 .data
= &init_net
.ipv4
.sysctl_local_reserved_ports
,
650 .proc_handler
= proc_do_large_bitmap
,
653 .procname
= "ip_no_pmtu_disc",
654 .data
= &init_net
.ipv4
.sysctl_ip_no_pmtu_disc
,
655 .maxlen
= sizeof(int),
657 .proc_handler
= proc_dointvec
660 .procname
= "ip_forward_use_pmtu",
661 .data
= &init_net
.ipv4
.sysctl_ip_fwd_use_pmtu
,
662 .maxlen
= sizeof(int),
664 .proc_handler
= proc_dointvec
,
667 .procname
= "ip_nonlocal_bind",
668 .data
= &init_net
.ipv4
.sysctl_ip_nonlocal_bind
,
669 .maxlen
= sizeof(int),
671 .proc_handler
= proc_dointvec
674 .procname
= "fwmark_reflect",
675 .data
= &init_net
.ipv4
.sysctl_fwmark_reflect
,
676 .maxlen
= sizeof(int),
678 .proc_handler
= proc_dointvec
,
681 .procname
= "tcp_fwmark_accept",
682 .data
= &init_net
.ipv4
.sysctl_tcp_fwmark_accept
,
683 .maxlen
= sizeof(int),
685 .proc_handler
= proc_dointvec
,
687 #ifdef CONFIG_NET_L3_MASTER_DEV
689 .procname
= "tcp_l3mdev_accept",
690 .data
= &init_net
.ipv4
.sysctl_tcp_l3mdev_accept
,
691 .maxlen
= sizeof(int),
693 .proc_handler
= proc_dointvec_minmax
,
699 .procname
= "tcp_mtu_probing",
700 .data
= &init_net
.ipv4
.sysctl_tcp_mtu_probing
,
701 .maxlen
= sizeof(int),
703 .proc_handler
= proc_dointvec
,
706 .procname
= "tcp_base_mss",
707 .data
= &init_net
.ipv4
.sysctl_tcp_base_mss
,
708 .maxlen
= sizeof(int),
710 .proc_handler
= proc_dointvec
,
713 .procname
= "tcp_probe_threshold",
714 .data
= &init_net
.ipv4
.sysctl_tcp_probe_threshold
,
715 .maxlen
= sizeof(int),
717 .proc_handler
= proc_dointvec
,
720 .procname
= "tcp_probe_interval",
721 .data
= &init_net
.ipv4
.sysctl_tcp_probe_interval
,
722 .maxlen
= sizeof(int),
724 .proc_handler
= proc_dointvec
,
727 .procname
= "igmp_link_local_mcast_reports",
728 .data
= &init_net
.ipv4
.sysctl_igmp_llm_reports
,
729 .maxlen
= sizeof(int),
731 .proc_handler
= proc_dointvec
734 .procname
= "igmp_max_memberships",
735 .data
= &init_net
.ipv4
.sysctl_igmp_max_memberships
,
736 .maxlen
= sizeof(int),
738 .proc_handler
= proc_dointvec
741 .procname
= "igmp_max_msf",
742 .data
= &init_net
.ipv4
.sysctl_igmp_max_msf
,
743 .maxlen
= sizeof(int),
745 .proc_handler
= proc_dointvec
747 #ifdef CONFIG_IP_MULTICAST
749 .procname
= "igmp_qrv",
750 .data
= &init_net
.ipv4
.sysctl_igmp_qrv
,
751 .maxlen
= sizeof(int),
753 .proc_handler
= proc_dointvec_minmax
,
758 .procname
= "tcp_congestion_control",
759 .data
= &init_net
.ipv4
.tcp_congestion_control
,
761 .maxlen
= TCP_CA_NAME_MAX
,
762 .proc_handler
= proc_tcp_congestion_control
,
765 .procname
= "tcp_keepalive_time",
766 .data
= &init_net
.ipv4
.sysctl_tcp_keepalive_time
,
767 .maxlen
= sizeof(int),
769 .proc_handler
= proc_dointvec_jiffies
,
772 .procname
= "tcp_keepalive_probes",
773 .data
= &init_net
.ipv4
.sysctl_tcp_keepalive_probes
,
774 .maxlen
= sizeof(int),
776 .proc_handler
= proc_dointvec
779 .procname
= "tcp_keepalive_intvl",
780 .data
= &init_net
.ipv4
.sysctl_tcp_keepalive_intvl
,
781 .maxlen
= sizeof(int),
783 .proc_handler
= proc_dointvec_jiffies
,
786 .procname
= "tcp_syn_retries",
787 .data
= &init_net
.ipv4
.sysctl_tcp_syn_retries
,
788 .maxlen
= sizeof(int),
790 .proc_handler
= proc_dointvec_minmax
,
791 .extra1
= &tcp_syn_retries_min
,
792 .extra2
= &tcp_syn_retries_max
795 .procname
= "tcp_synack_retries",
796 .data
= &init_net
.ipv4
.sysctl_tcp_synack_retries
,
797 .maxlen
= sizeof(int),
799 .proc_handler
= proc_dointvec
801 #ifdef CONFIG_SYN_COOKIES
803 .procname
= "tcp_syncookies",
804 .data
= &init_net
.ipv4
.sysctl_tcp_syncookies
,
805 .maxlen
= sizeof(int),
807 .proc_handler
= proc_dointvec
811 .procname
= "tcp_reordering",
812 .data
= &init_net
.ipv4
.sysctl_tcp_reordering
,
813 .maxlen
= sizeof(int),
815 .proc_handler
= proc_dointvec
818 .procname
= "tcp_retries1",
819 .data
= &init_net
.ipv4
.sysctl_tcp_retries1
,
820 .maxlen
= sizeof(int),
822 .proc_handler
= proc_dointvec_minmax
,
823 .extra2
= &tcp_retr1_max
826 .procname
= "tcp_retries2",
827 .data
= &init_net
.ipv4
.sysctl_tcp_retries2
,
828 .maxlen
= sizeof(int),
830 .proc_handler
= proc_dointvec
833 .procname
= "tcp_orphan_retries",
834 .data
= &init_net
.ipv4
.sysctl_tcp_orphan_retries
,
835 .maxlen
= sizeof(int),
837 .proc_handler
= proc_dointvec
840 .procname
= "tcp_fin_timeout",
841 .data
= &init_net
.ipv4
.sysctl_tcp_fin_timeout
,
842 .maxlen
= sizeof(int),
844 .proc_handler
= proc_dointvec_jiffies
,
847 .procname
= "tcp_notsent_lowat",
848 .data
= &init_net
.ipv4
.sysctl_tcp_notsent_lowat
,
849 .maxlen
= sizeof(unsigned int),
851 .proc_handler
= proc_douintvec
,
854 .procname
= "tcp_tw_reuse",
855 .data
= &init_net
.ipv4
.sysctl_tcp_tw_reuse
,
856 .maxlen
= sizeof(int),
858 .proc_handler
= proc_dointvec_minmax
,
863 .procname
= "tcp_max_tw_buckets",
864 .data
= &init_net
.ipv4
.tcp_death_row
.sysctl_max_tw_buckets
,
865 .maxlen
= sizeof(int),
867 .proc_handler
= proc_dointvec
870 .procname
= "tcp_max_syn_backlog",
871 .data
= &init_net
.ipv4
.sysctl_max_syn_backlog
,
872 .maxlen
= sizeof(int),
874 .proc_handler
= proc_dointvec
877 .procname
= "tcp_fastopen",
878 .data
= &init_net
.ipv4
.sysctl_tcp_fastopen
,
879 .maxlen
= sizeof(int),
881 .proc_handler
= proc_dointvec
,
884 .procname
= "tcp_fastopen_key",
886 .data
= &init_net
.ipv4
.sysctl_tcp_fastopen
,
887 .maxlen
= ((TCP_FASTOPEN_KEY_LENGTH
* 2) + 10),
888 .proc_handler
= proc_tcp_fastopen_key
,
891 .procname
= "tcp_fastopen_blackhole_timeout_sec",
892 .data
= &init_net
.ipv4
.sysctl_tcp_fastopen_blackhole_timeout
,
893 .maxlen
= sizeof(int),
895 .proc_handler
= proc_tfo_blackhole_detect_timeout
,
898 #ifdef CONFIG_IP_ROUTE_MULTIPATH
900 .procname
= "fib_multipath_use_neigh",
901 .data
= &init_net
.ipv4
.sysctl_fib_multipath_use_neigh
,
902 .maxlen
= sizeof(int),
904 .proc_handler
= proc_dointvec_minmax
,
909 .procname
= "fib_multipath_hash_policy",
910 .data
= &init_net
.ipv4
.sysctl_fib_multipath_hash_policy
,
911 .maxlen
= sizeof(int),
913 .proc_handler
= proc_fib_multipath_hash_policy
,
919 .procname
= "ip_unprivileged_port_start",
920 .maxlen
= sizeof(int),
921 .data
= &init_net
.ipv4
.sysctl_ip_prot_sock
,
923 .proc_handler
= ipv4_privileged_ports
,
925 #ifdef CONFIG_NET_L3_MASTER_DEV
927 .procname
= "udp_l3mdev_accept",
928 .data
= &init_net
.ipv4
.sysctl_udp_l3mdev_accept
,
929 .maxlen
= sizeof(int),
931 .proc_handler
= proc_dointvec_minmax
,
937 .procname
= "tcp_sack",
938 .data
= &init_net
.ipv4
.sysctl_tcp_sack
,
939 .maxlen
= sizeof(int),
941 .proc_handler
= proc_dointvec
944 .procname
= "tcp_window_scaling",
945 .data
= &init_net
.ipv4
.sysctl_tcp_window_scaling
,
946 .maxlen
= sizeof(int),
948 .proc_handler
= proc_dointvec
951 .procname
= "tcp_timestamps",
952 .data
= &init_net
.ipv4
.sysctl_tcp_timestamps
,
953 .maxlen
= sizeof(int),
955 .proc_handler
= proc_dointvec
958 .procname
= "tcp_early_retrans",
959 .data
= &init_net
.ipv4
.sysctl_tcp_early_retrans
,
960 .maxlen
= sizeof(int),
962 .proc_handler
= proc_dointvec_minmax
,
967 .procname
= "tcp_recovery",
968 .data
= &init_net
.ipv4
.sysctl_tcp_recovery
,
969 .maxlen
= sizeof(int),
971 .proc_handler
= proc_dointvec
,
974 .procname
= "tcp_thin_linear_timeouts",
975 .data
= &init_net
.ipv4
.sysctl_tcp_thin_linear_timeouts
,
976 .maxlen
= sizeof(int),
978 .proc_handler
= proc_dointvec
981 .procname
= "tcp_slow_start_after_idle",
982 .data
= &init_net
.ipv4
.sysctl_tcp_slow_start_after_idle
,
983 .maxlen
= sizeof(int),
985 .proc_handler
= proc_dointvec
988 .procname
= "tcp_retrans_collapse",
989 .data
= &init_net
.ipv4
.sysctl_tcp_retrans_collapse
,
990 .maxlen
= sizeof(int),
992 .proc_handler
= proc_dointvec
995 .procname
= "tcp_stdurg",
996 .data
= &init_net
.ipv4
.sysctl_tcp_stdurg
,
997 .maxlen
= sizeof(int),
999 .proc_handler
= proc_dointvec
1002 .procname
= "tcp_rfc1337",
1003 .data
= &init_net
.ipv4
.sysctl_tcp_rfc1337
,
1004 .maxlen
= sizeof(int),
1006 .proc_handler
= proc_dointvec
1009 .procname
= "tcp_abort_on_overflow",
1010 .data
= &init_net
.ipv4
.sysctl_tcp_abort_on_overflow
,
1011 .maxlen
= sizeof(int),
1013 .proc_handler
= proc_dointvec
1016 .procname
= "tcp_fack",
1017 .data
= &init_net
.ipv4
.sysctl_tcp_fack
,
1018 .maxlen
= sizeof(int),
1020 .proc_handler
= proc_dointvec
1023 .procname
= "tcp_max_reordering",
1024 .data
= &init_net
.ipv4
.sysctl_tcp_max_reordering
,
1025 .maxlen
= sizeof(int),
1027 .proc_handler
= proc_dointvec
1030 .procname
= "tcp_dsack",
1031 .data
= &init_net
.ipv4
.sysctl_tcp_dsack
,
1032 .maxlen
= sizeof(int),
1034 .proc_handler
= proc_dointvec
1037 .procname
= "tcp_app_win",
1038 .data
= &init_net
.ipv4
.sysctl_tcp_app_win
,
1039 .maxlen
= sizeof(int),
1041 .proc_handler
= proc_dointvec
1044 .procname
= "tcp_adv_win_scale",
1045 .data
= &init_net
.ipv4
.sysctl_tcp_adv_win_scale
,
1046 .maxlen
= sizeof(int),
1048 .proc_handler
= proc_dointvec_minmax
,
1049 .extra1
= &tcp_adv_win_scale_min
,
1050 .extra2
= &tcp_adv_win_scale_max
,
1053 .procname
= "tcp_frto",
1054 .data
= &init_net
.ipv4
.sysctl_tcp_frto
,
1055 .maxlen
= sizeof(int),
1057 .proc_handler
= proc_dointvec
1060 .procname
= "tcp_no_metrics_save",
1061 .data
= &init_net
.ipv4
.sysctl_tcp_nometrics_save
,
1062 .maxlen
= sizeof(int),
1064 .proc_handler
= proc_dointvec
,
1067 .procname
= "tcp_moderate_rcvbuf",
1068 .data
= &init_net
.ipv4
.sysctl_tcp_moderate_rcvbuf
,
1069 .maxlen
= sizeof(int),
1071 .proc_handler
= proc_dointvec
,
1074 .procname
= "tcp_tso_win_divisor",
1075 .data
= &init_net
.ipv4
.sysctl_tcp_tso_win_divisor
,
1076 .maxlen
= sizeof(int),
1078 .proc_handler
= proc_dointvec
,
1081 .procname
= "tcp_workaround_signed_windows",
1082 .data
= &init_net
.ipv4
.sysctl_tcp_workaround_signed_windows
,
1083 .maxlen
= sizeof(int),
1085 .proc_handler
= proc_dointvec
1088 .procname
= "tcp_limit_output_bytes",
1089 .data
= &init_net
.ipv4
.sysctl_tcp_limit_output_bytes
,
1090 .maxlen
= sizeof(int),
1092 .proc_handler
= proc_dointvec
1095 .procname
= "tcp_challenge_ack_limit",
1096 .data
= &init_net
.ipv4
.sysctl_tcp_challenge_ack_limit
,
1097 .maxlen
= sizeof(int),
1099 .proc_handler
= proc_dointvec
1102 .procname
= "tcp_min_tso_segs",
1103 .data
= &init_net
.ipv4
.sysctl_tcp_min_tso_segs
,
1104 .maxlen
= sizeof(int),
1106 .proc_handler
= proc_dointvec_minmax
,
1108 .extra2
= &gso_max_segs
,
1111 .procname
= "tcp_min_rtt_wlen",
1112 .data
= &init_net
.ipv4
.sysctl_tcp_min_rtt_wlen
,
1113 .maxlen
= sizeof(int),
1115 .proc_handler
= proc_dointvec
1118 .procname
= "tcp_autocorking",
1119 .data
= &init_net
.ipv4
.sysctl_tcp_autocorking
,
1120 .maxlen
= sizeof(int),
1122 .proc_handler
= proc_dointvec_minmax
,
1127 .procname
= "tcp_invalid_ratelimit",
1128 .data
= &init_net
.ipv4
.sysctl_tcp_invalid_ratelimit
,
1129 .maxlen
= sizeof(int),
1131 .proc_handler
= proc_dointvec_ms_jiffies
,
1134 .procname
= "tcp_pacing_ss_ratio",
1135 .data
= &init_net
.ipv4
.sysctl_tcp_pacing_ss_ratio
,
1136 .maxlen
= sizeof(int),
1138 .proc_handler
= proc_dointvec_minmax
,
1140 .extra2
= &thousand
,
1143 .procname
= "tcp_pacing_ca_ratio",
1144 .data
= &init_net
.ipv4
.sysctl_tcp_pacing_ca_ratio
,
1145 .maxlen
= sizeof(int),
1147 .proc_handler
= proc_dointvec_minmax
,
1149 .extra2
= &thousand
,
1152 .procname
= "tcp_wmem",
1153 .data
= &init_net
.ipv4
.sysctl_tcp_wmem
,
1154 .maxlen
= sizeof(init_net
.ipv4
.sysctl_tcp_wmem
),
1156 .proc_handler
= proc_dointvec_minmax
,
1160 .procname
= "tcp_rmem",
1161 .data
= &init_net
.ipv4
.sysctl_tcp_rmem
,
1162 .maxlen
= sizeof(init_net
.ipv4
.sysctl_tcp_rmem
),
1164 .proc_handler
= proc_dointvec_minmax
,
1168 .procname
= "tcp_comp_sack_delay_ns",
1169 .data
= &init_net
.ipv4
.sysctl_tcp_comp_sack_delay_ns
,
1170 .maxlen
= sizeof(unsigned long),
1172 .proc_handler
= proc_doulongvec_minmax
,
1175 .procname
= "tcp_comp_sack_nr",
1176 .data
= &init_net
.ipv4
.sysctl_tcp_comp_sack_nr
,
1177 .maxlen
= sizeof(int),
1179 .proc_handler
= proc_dointvec_minmax
,
1181 .extra2
= &comp_sack_nr_max
,
1184 .procname
= "udp_rmem_min",
1185 .data
= &init_net
.ipv4
.sysctl_udp_rmem_min
,
1186 .maxlen
= sizeof(init_net
.ipv4
.sysctl_udp_rmem_min
),
1188 .proc_handler
= proc_dointvec_minmax
,
1192 .procname
= "udp_wmem_min",
1193 .data
= &init_net
.ipv4
.sysctl_udp_wmem_min
,
1194 .maxlen
= sizeof(init_net
.ipv4
.sysctl_udp_wmem_min
),
1196 .proc_handler
= proc_dointvec_minmax
,
1202 static __net_init
int ipv4_sysctl_init_net(struct net
*net
)
1204 struct ctl_table
*table
;
1206 table
= ipv4_net_table
;
1207 if (!net_eq(net
, &init_net
)) {
1210 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
1214 /* Update the variables to point into the current struct net */
1215 for (i
= 0; i
< ARRAY_SIZE(ipv4_net_table
) - 1; i
++)
1216 table
[i
].data
+= (void *)net
- (void *)&init_net
;
1219 net
->ipv4
.ipv4_hdr
= register_net_sysctl(net
, "net/ipv4", table
);
1220 if (!net
->ipv4
.ipv4_hdr
)
1223 net
->ipv4
.sysctl_local_reserved_ports
= kzalloc(65536 / 8, GFP_KERNEL
);
1224 if (!net
->ipv4
.sysctl_local_reserved_ports
)
1230 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
1232 if (!net_eq(net
, &init_net
))
1238 static __net_exit
void ipv4_sysctl_exit_net(struct net
*net
)
1240 struct ctl_table
*table
;
1242 kfree(net
->ipv4
.sysctl_local_reserved_ports
);
1243 table
= net
->ipv4
.ipv4_hdr
->ctl_table_arg
;
1244 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
1248 static __net_initdata
struct pernet_operations ipv4_sysctl_ops
= {
1249 .init
= ipv4_sysctl_init_net
,
1250 .exit
= ipv4_sysctl_exit_net
,
1253 static __init
int sysctl_ipv4_init(void)
1255 struct ctl_table_header
*hdr
;
1257 hdr
= register_net_sysctl(&init_net
, "net/ipv4", ipv4_table
);
1261 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
1262 unregister_net_sysctl_table(hdr
);
1269 __initcall(sysctl_ipv4_init
);