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>
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;
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
,
75 size_t *lenp
, loff_t
*ppos
)
78 container_of(table
->data
, struct net
, ipv4
.ip_local_ports
.range
);
81 struct ctl_table tmp
= {
83 .maxlen
= sizeof(range
),
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
98 if ((range
[1] < range
[0]) ||
99 (range
[0] < net
->ipv4
.sysctl_ip_prot_sock
))
102 set_local_port_range(net
, range
);
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
);
117 struct ctl_table tmp
= {
119 .maxlen
= sizeof(pports
),
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
)
137 net
->ipv4
.sysctl_ip_prot_sock
= pports
;
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
;
147 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
150 seq
= read_seqbegin(&net
->ipv4
.ping_group_range
.lock
);
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
;
162 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
163 write_seqlock(&net
->ipv4
.ping_group_range
.lock
);
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
,
172 size_t *lenp
, loff_t
*ppos
)
174 struct user_namespace
*user_ns
= current_user_ns();
178 struct ctl_table tmp
= {
180 .maxlen
= sizeof(urange
),
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
))
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
);
206 static int ipv4_fwd_update_priority(struct ctl_table
*table
, int write
,
208 size_t *lenp
, loff_t
*ppos
)
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
,
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
= {
231 .maxlen
= TCP_CA_NAME_MAX
,
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
);
243 static int proc_tcp_available_congestion_control(struct ctl_table
*ctl
,
245 void __user
*buffer
, size_t *lenp
,
248 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
251 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
254 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
255 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
260 static int proc_allowed_congestion_control(struct ctl_table
*ctl
,
262 void __user
*buffer
, size_t *lenp
,
265 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
268 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
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
);
280 static int sscanf_key(char *buf
, __le32
*key
)
285 if (sscanf(buf
, "%x-%x-%x-%x", user_key
, user_key
+ 1,
286 user_key
+ 2, user_key
+ 3) != 4) {
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
);
298 static int proc_tcp_fastopen_key(struct ctl_table
*table
, int write
,
299 void __user
*buffer
, size_t *lenp
,
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];
314 int ret
, i
= 0, off
= 0, n_keys
= 0;
316 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_KERNEL
);
321 ctx
= rcu_dereference(net
->ipv4
.tcp_fastopen_ctx
);
323 n_keys
= tcp_fastopen_context_len(ctx
);
324 memcpy(&key
[0], &ctx
->key
[0], TCP_FASTOPEN_KEY_LENGTH
* n_keys
);
329 memset(&key
[0], 0, TCP_FASTOPEN_KEY_LENGTH
);
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",
342 user_key
[i
* 4 + 3]);
344 if (WARN_ON_ONCE(off
>= tbl
.maxlen
- 1))
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
, ',');
359 if (sscanf_key(tbl
.data
, key
)) {
364 if (sscanf_key(backup_data
, key
+ 4)) {
369 tcp_fastopen_reset_cipher(net
, NULL
, key
,
370 backup_data
? key
+ 4 : NULL
);
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
;
387 ipprot
= rcu_dereference(inet_protos
[protocol
]);
389 ipprot
->early_demux
= enabled
? ipprot
->early_demux_handler
:
392 #if IS_ENABLED(CONFIG_IPV6)
393 ip6prot
= rcu_dereference(inet6_protos
[protocol
]);
395 ip6prot
->early_demux
= enabled
? ip6prot
->early_demux_handler
:
401 static int proc_tcp_early_demux(struct ctl_table
*table
, int write
,
402 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
406 ret
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
409 int enabled
= init_net
.ipv4
.sysctl_tcp_early_demux
;
411 proc_configure_early_demux(enabled
, IPPROTO_TCP
);
417 static int proc_udp_early_demux(struct ctl_table
*table
, int write
,
418 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
422 ret
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
425 int enabled
= init_net
.ipv4
.sysctl_udp_early_demux
;
427 proc_configure_early_demux(enabled
, IPPROTO_UDP
);
433 static int proc_tfo_blackhole_detect_timeout(struct ctl_table
*table
,
436 size_t *lenp
, loff_t
*ppos
)
438 struct net
*net
= container_of(table
->data
, struct net
,
439 ipv4
.sysctl_tcp_fastopen_blackhole_timeout
);
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);
449 static int proc_tcp_available_ulp(struct ctl_table
*ctl
,
451 void __user
*buffer
, size_t *lenp
,
454 struct ctl_table tbl
= { .maxlen
= TCP_ULP_BUF_MAX
, };
457 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
460 tcp_get_available_ulp(tbl
.data
, TCP_ULP_BUF_MAX
);
461 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
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
,
472 struct net
*net
= container_of(table
->data
, struct net
,
473 ipv4
.sysctl_fib_multipath_hash_policy
);
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
);
484 static struct ctl_table ipv4_table
[] = {
486 .procname
= "tcp_max_orphans",
487 .data
= &sysctl_tcp_max_orphans
,
488 .maxlen
= sizeof(int),
490 .proc_handler
= proc_dointvec
493 .procname
= "inet_peer_threshold",
494 .data
= &inet_peer_threshold
,
495 .maxlen
= sizeof(int),
497 .proc_handler
= proc_dointvec
500 .procname
= "inet_peer_minttl",
501 .data
= &inet_peer_minttl
,
502 .maxlen
= sizeof(int),
504 .proc_handler
= proc_dointvec_jiffies
,
507 .procname
= "inet_peer_maxttl",
508 .data
= &inet_peer_maxttl
,
509 .maxlen
= sizeof(int),
511 .proc_handler
= proc_dointvec_jiffies
,
514 .procname
= "tcp_mem",
515 .maxlen
= sizeof(sysctl_tcp_mem
),
516 .data
= &sysctl_tcp_mem
,
518 .proc_handler
= proc_doulongvec_minmax
,
521 .procname
= "tcp_low_latency",
522 .data
= &sysctl_tcp_low_latency
,
523 .maxlen
= sizeof(int),
525 .proc_handler
= proc_dointvec
527 #ifdef CONFIG_NETLABEL
529 .procname
= "cipso_cache_enable",
530 .data
= &cipso_v4_cache_enabled
,
531 .maxlen
= sizeof(int),
533 .proc_handler
= proc_dointvec
,
536 .procname
= "cipso_cache_bucket_size",
537 .data
= &cipso_v4_cache_bucketsize
,
538 .maxlen
= sizeof(int),
540 .proc_handler
= proc_dointvec
,
543 .procname
= "cipso_rbm_optfmt",
544 .data
= &cipso_v4_rbm_optfmt
,
545 .maxlen
= sizeof(int),
547 .proc_handler
= proc_dointvec
,
550 .procname
= "cipso_rbm_strictvalid",
551 .data
= &cipso_v4_rbm_strictvalid
,
552 .maxlen
= sizeof(int),
554 .proc_handler
= proc_dointvec
,
556 #endif /* CONFIG_NETLABEL */
558 .procname
= "tcp_available_ulp",
559 .maxlen
= TCP_ULP_BUF_MAX
,
561 .proc_handler
= proc_tcp_available_ulp
,
564 .procname
= "icmp_msgs_per_sec",
565 .data
= &sysctl_icmp_msgs_per_sec
,
566 .maxlen
= sizeof(int),
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),
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
),
584 .proc_handler
= proc_doulongvec_minmax
,
587 .procname
= "fib_sync_mem",
588 .data
= &sysctl_fib_sync_mem
,
589 .maxlen
= sizeof(sysctl_fib_sync_mem
),
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
,
599 .proc_handler
= proc_do_static_key
,
602 .procname
= "tcp_tx_skb_cache",
603 .data
= &tcp_tx_skb_cache_key
.key
,
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),
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),
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),
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),
637 .proc_handler
= proc_dointvec
640 .procname
= "icmp_ratelimit",
641 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
642 .maxlen
= sizeof(int),
644 .proc_handler
= proc_dointvec_ms_jiffies
,
647 .procname
= "icmp_ratemask",
648 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
649 .maxlen
= sizeof(int),
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,
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),
666 .proc_handler
= proc_dointvec_minmax
,
667 .extra1
= SYSCTL_ZERO
,
668 .extra2
= SYSCTL_ONE
,
672 .procname
= "tcp_ecn",
673 .data
= &init_net
.ipv4
.sysctl_tcp_ecn
,
674 .maxlen
= sizeof(int),
676 .proc_handler
= proc_dointvec
679 .procname
= "tcp_ecn_fallback",
680 .data
= &init_net
.ipv4
.sysctl_tcp_ecn_fallback
,
681 .maxlen
= sizeof(int),
683 .proc_handler
= proc_dointvec
686 .procname
= "ip_dynaddr",
687 .data
= &init_net
.ipv4
.sysctl_ip_dynaddr
,
688 .maxlen
= sizeof(int),
690 .proc_handler
= proc_dointvec
693 .procname
= "ip_early_demux",
694 .data
= &init_net
.ipv4
.sysctl_ip_early_demux
,
695 .maxlen
= sizeof(int),
697 .proc_handler
= proc_dointvec
700 .procname
= "udp_early_demux",
701 .data
= &init_net
.ipv4
.sysctl_udp_early_demux
,
702 .maxlen
= sizeof(int),
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),
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),
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),
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
,
736 .proc_handler
= ipv4_local_port_range
,
739 .procname
= "ip_local_reserved_ports",
740 .data
= &init_net
.ipv4
.sysctl_local_reserved_ports
,
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),
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),
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),
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),
773 .proc_handler
= proc_dointvec
776 .procname
= "ip_autobind_reuse",
777 .data
= &init_net
.ipv4
.sysctl_ip_autobind_reuse
,
778 .maxlen
= sizeof(int),
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),
789 .proc_handler
= proc_dointvec
,
792 .procname
= "tcp_fwmark_accept",
793 .data
= &init_net
.ipv4
.sysctl_tcp_fwmark_accept
,
794 .maxlen
= sizeof(int),
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),
804 .proc_handler
= proc_dointvec_minmax
,
805 .extra1
= SYSCTL_ZERO
,
806 .extra2
= SYSCTL_ONE
,
810 .procname
= "tcp_mtu_probing",
811 .data
= &init_net
.ipv4
.sysctl_tcp_mtu_probing
,
812 .maxlen
= sizeof(int),
814 .proc_handler
= proc_dointvec
,
817 .procname
= "tcp_base_mss",
818 .data
= &init_net
.ipv4
.sysctl_tcp_base_mss
,
819 .maxlen
= sizeof(int),
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),
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),
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),
846 .proc_handler
= proc_dointvec
,
849 .procname
= "tcp_probe_interval",
850 .data
= &init_net
.ipv4
.sysctl_tcp_probe_interval
,
851 .maxlen
= sizeof(u32
),
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),
861 .proc_handler
= proc_dointvec
864 .procname
= "igmp_max_memberships",
865 .data
= &init_net
.ipv4
.sysctl_igmp_max_memberships
,
866 .maxlen
= sizeof(int),
868 .proc_handler
= proc_dointvec
871 .procname
= "igmp_max_msf",
872 .data
= &init_net
.ipv4
.sysctl_igmp_max_msf
,
873 .maxlen
= sizeof(int),
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),
883 .proc_handler
= proc_dointvec_minmax
,
888 .procname
= "tcp_congestion_control",
889 .data
= &init_net
.ipv4
.tcp_congestion_control
,
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
,
898 .proc_handler
= proc_tcp_available_congestion_control
,
901 .procname
= "tcp_allowed_congestion_control",
902 .maxlen
= TCP_CA_BUF_MAX
,
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),
911 .proc_handler
= proc_dointvec_jiffies
,
914 .procname
= "tcp_keepalive_probes",
915 .data
= &init_net
.ipv4
.sysctl_tcp_keepalive_probes
,
916 .maxlen
= sizeof(int),
918 .proc_handler
= proc_dointvec
921 .procname
= "tcp_keepalive_intvl",
922 .data
= &init_net
.ipv4
.sysctl_tcp_keepalive_intvl
,
923 .maxlen
= sizeof(int),
925 .proc_handler
= proc_dointvec_jiffies
,
928 .procname
= "tcp_syn_retries",
929 .data
= &init_net
.ipv4
.sysctl_tcp_syn_retries
,
930 .maxlen
= sizeof(int),
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),
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),
949 .proc_handler
= proc_dointvec
953 .procname
= "tcp_reordering",
954 .data
= &init_net
.ipv4
.sysctl_tcp_reordering
,
955 .maxlen
= sizeof(int),
957 .proc_handler
= proc_dointvec
960 .procname
= "tcp_retries1",
961 .data
= &init_net
.ipv4
.sysctl_tcp_retries1
,
962 .maxlen
= sizeof(int),
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),
972 .proc_handler
= proc_dointvec
975 .procname
= "tcp_orphan_retries",
976 .data
= &init_net
.ipv4
.sysctl_tcp_orphan_retries
,
977 .maxlen
= sizeof(int),
979 .proc_handler
= proc_dointvec
982 .procname
= "tcp_fin_timeout",
983 .data
= &init_net
.ipv4
.sysctl_tcp_fin_timeout
,
984 .maxlen
= sizeof(int),
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),
993 .proc_handler
= proc_douintvec
,
996 .procname
= "tcp_tw_reuse",
997 .data
= &init_net
.ipv4
.sysctl_tcp_tw_reuse
,
998 .maxlen
= sizeof(int),
1000 .proc_handler
= proc_dointvec_minmax
,
1001 .extra1
= SYSCTL_ZERO
,
1005 .procname
= "tcp_max_tw_buckets",
1006 .data
= &init_net
.ipv4
.tcp_death_row
.sysctl_max_tw_buckets
,
1007 .maxlen
= sizeof(int),
1009 .proc_handler
= proc_dointvec
1012 .procname
= "tcp_max_syn_backlog",
1013 .data
= &init_net
.ipv4
.sysctl_max_syn_backlog
,
1014 .maxlen
= sizeof(int),
1016 .proc_handler
= proc_dointvec
1019 .procname
= "tcp_fastopen",
1020 .data
= &init_net
.ipv4
.sysctl_tcp_fastopen
,
1021 .maxlen
= sizeof(int),
1023 .proc_handler
= proc_dointvec
,
1026 .procname
= "tcp_fastopen_key",
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),
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),
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),
1060 .proc_handler
= proc_fib_multipath_hash_policy
,
1061 .extra1
= SYSCTL_ZERO
,
1066 .procname
= "ip_unprivileged_port_start",
1067 .maxlen
= sizeof(int),
1068 .data
= &init_net
.ipv4
.sysctl_ip_prot_sock
,
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),
1078 .proc_handler
= proc_dointvec_minmax
,
1079 .extra1
= SYSCTL_ZERO
,
1080 .extra2
= SYSCTL_ONE
,
1084 .procname
= "tcp_sack",
1085 .data
= &init_net
.ipv4
.sysctl_tcp_sack
,
1086 .maxlen
= sizeof(int),
1088 .proc_handler
= proc_dointvec
1091 .procname
= "tcp_window_scaling",
1092 .data
= &init_net
.ipv4
.sysctl_tcp_window_scaling
,
1093 .maxlen
= sizeof(int),
1095 .proc_handler
= proc_dointvec
1098 .procname
= "tcp_timestamps",
1099 .data
= &init_net
.ipv4
.sysctl_tcp_timestamps
,
1100 .maxlen
= sizeof(int),
1102 .proc_handler
= proc_dointvec
1105 .procname
= "tcp_early_retrans",
1106 .data
= &init_net
.ipv4
.sysctl_tcp_early_retrans
,
1107 .maxlen
= sizeof(int),
1109 .proc_handler
= proc_dointvec_minmax
,
1110 .extra1
= SYSCTL_ZERO
,
1114 .procname
= "tcp_recovery",
1115 .data
= &init_net
.ipv4
.sysctl_tcp_recovery
,
1116 .maxlen
= sizeof(int),
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),
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),
1132 .proc_handler
= proc_dointvec
1135 .procname
= "tcp_retrans_collapse",
1136 .data
= &init_net
.ipv4
.sysctl_tcp_retrans_collapse
,
1137 .maxlen
= sizeof(int),
1139 .proc_handler
= proc_dointvec
1142 .procname
= "tcp_stdurg",
1143 .data
= &init_net
.ipv4
.sysctl_tcp_stdurg
,
1144 .maxlen
= sizeof(int),
1146 .proc_handler
= proc_dointvec
1149 .procname
= "tcp_rfc1337",
1150 .data
= &init_net
.ipv4
.sysctl_tcp_rfc1337
,
1151 .maxlen
= sizeof(int),
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),
1160 .proc_handler
= proc_dointvec
1163 .procname
= "tcp_fack",
1164 .data
= &init_net
.ipv4
.sysctl_tcp_fack
,
1165 .maxlen
= sizeof(int),
1167 .proc_handler
= proc_dointvec
1170 .procname
= "tcp_max_reordering",
1171 .data
= &init_net
.ipv4
.sysctl_tcp_max_reordering
,
1172 .maxlen
= sizeof(int),
1174 .proc_handler
= proc_dointvec
1177 .procname
= "tcp_dsack",
1178 .data
= &init_net
.ipv4
.sysctl_tcp_dsack
,
1179 .maxlen
= sizeof(int),
1181 .proc_handler
= proc_dointvec
1184 .procname
= "tcp_app_win",
1185 .data
= &init_net
.ipv4
.sysctl_tcp_app_win
,
1186 .maxlen
= sizeof(int),
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),
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),
1204 .proc_handler
= proc_dointvec
1207 .procname
= "tcp_no_metrics_save",
1208 .data
= &init_net
.ipv4
.sysctl_tcp_nometrics_save
,
1209 .maxlen
= sizeof(int),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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
),
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
),
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),
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),
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),
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
),
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
),
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
)) {
1375 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
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
)
1388 net
->ipv4
.sysctl_local_reserved_ports
= kzalloc(65536 / 8, GFP_KERNEL
);
1389 if (!net
->ipv4
.sysctl_local_reserved_ports
)
1395 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
1397 if (!net_eq(net
, &init_net
))
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
);
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
);
1426 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
1427 unregister_net_sysctl_table(hdr
);
1434 __initcall(sysctl_ipv4_init
);