9 #include <linux/module.h>
10 #include <linux/sysctl.h>
11 #include <linux/igmp.h>
15 #include <linux/slab.h>
31 static int tcp_retr1_max = 255;
32 static int ip_local_port_range_min[] = { 1, 1 };
33 static int ip_local_port_range_max[] = { 65535, 65535 };
34 static int tcp_adv_win_scale_min = -31;
35 static int tcp_adv_win_scale_max = 31;
36 static int ip_ttl_min = 1;
37 static int ip_ttl_max = 255;
38 static int ip_ping_group_range_min[] = { 0, 0 };
42 static void set_local_port_range(
int range[2])
53 size_t *lenp, loff_t *ppos)
59 .maxlen =
sizeof(
range),
61 .extra1 = &ip_local_port_range_min,
62 .extra2 = &ip_local_port_range_max,
68 if (write && ret == 0) {
69 if (range[1] < range[0])
72 set_local_port_range(range);
102 static int ipv4_ping_group_range(
ctl_table *table,
int write,
104 size_t *lenp, loff_t *ppos)
112 .maxlen =
sizeof(urange),
114 .extra1 = &ip_ping_group_range_min,
115 .extra2 = &ip_ping_group_range_max,
118 inet_get_ping_group_range_table(table, &low, &high);
123 if (write && ret == 0) {
126 if (!gid_valid(low) || !gid_valid(high) ||
127 (urange[1] < urange[0]) || gid_lt(high, low)) {
131 set_ping_group_range(table, low, high);
137 static int proc_tcp_congestion_control(
ctl_table *
ctl,
int write,
138 void __user *buffer,
size_t *lenp, loff_t *ppos)
150 if (write && ret == 0)
155 static int proc_tcp_available_congestion_control(
ctl_table *ctl,
157 void __user *buffer,
size_t *lenp,
172 static int proc_allowed_congestion_control(
ctl_table *ctl,
174 void __user *buffer,
size_t *lenp,
186 if (write && ret == 0)
192 static int ipv4_tcp_mem(
ctl_table *ctl,
int write,
193 void __user *buffer,
size_t *lenp,
197 unsigned long vec[3];
199 #ifdef CONFIG_MEMCG_KMEM
205 .maxlen =
sizeof(vec),
210 ctl->
data = &net->
ipv4.sysctl_tcp_mem;
218 #ifdef CONFIG_MEMCG_KMEM
228 net->
ipv4.sysctl_tcp_mem[0] = vec[0];
229 net->
ipv4.sysctl_tcp_mem[1] = vec[1];
230 net->
ipv4.sysctl_tcp_mem[2] = vec[2];
236 size_t *lenp, loff_t *ppos)
252 memset(user_key, 0,
sizeof(user_key));
256 user_key[0], user_key[1], user_key[2], user_key[3]);
259 if (write && ret == 0) {
260 if (
sscanf(tbl.
data,
"%x-%x-%x-%x", user_key, user_key + 1,
261 user_key + 2, user_key + 3) != 4) {
269 pr_debug(
"proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
270 user_key[0], user_key[1], user_key[2], user_key[3],
271 (
char *)tbl.
data, ret);
280 .maxlen =
sizeof(
int),
285 .procname =
"tcp_window_scaling",
287 .maxlen =
sizeof(
int),
292 .procname =
"tcp_sack",
294 .maxlen =
sizeof(
int),
299 .procname =
"tcp_retrans_collapse",
301 .maxlen =
sizeof(
int),
306 .procname =
"ip_default_ttl",
308 .maxlen =
sizeof(
int),
315 .procname =
"ip_no_pmtu_disc",
317 .maxlen =
sizeof(
int),
322 .procname =
"ip_nonlocal_bind",
324 .maxlen =
sizeof(
int),
329 .procname =
"tcp_syn_retries",
331 .maxlen =
sizeof(
int),
336 .procname =
"tcp_synack_retries",
338 .maxlen =
sizeof(
int),
343 .procname =
"tcp_max_orphans",
345 .maxlen =
sizeof(
int),
350 .procname =
"tcp_max_tw_buckets",
352 .maxlen =
sizeof(
int),
357 .procname =
"ip_early_demux",
359 .maxlen =
sizeof(
int),
364 .procname =
"ip_dynaddr",
366 .maxlen =
sizeof(
int),
371 .procname =
"tcp_keepalive_time",
373 .maxlen =
sizeof(
int),
378 .procname =
"tcp_keepalive_probes",
380 .maxlen =
sizeof(
int),
385 .procname =
"tcp_keepalive_intvl",
387 .maxlen =
sizeof(
int),
392 .procname =
"tcp_retries1",
394 .maxlen =
sizeof(
int),
400 .procname =
"tcp_retries2",
402 .maxlen =
sizeof(
int),
407 .procname =
"tcp_fin_timeout",
409 .maxlen =
sizeof(
int),
413 #ifdef CONFIG_SYN_COOKIES
415 .procname =
"tcp_syncookies",
417 .maxlen =
sizeof(
int),
423 .procname =
"tcp_fastopen",
425 .maxlen =
sizeof(
int),
430 .procname =
"tcp_fastopen_key",
436 .procname =
"tcp_tw_recycle",
438 .maxlen =
sizeof(
int),
443 .procname =
"tcp_abort_on_overflow",
445 .maxlen =
sizeof(
int),
450 .procname =
"tcp_stdurg",
452 .maxlen =
sizeof(
int),
457 .procname =
"tcp_rfc1337",
459 .maxlen =
sizeof(
int),
464 .procname =
"tcp_max_syn_backlog",
466 .maxlen =
sizeof(
int),
471 .procname =
"ip_local_port_range",
478 .procname =
"ip_local_reserved_ports",
485 .procname =
"igmp_max_memberships",
487 .maxlen =
sizeof(
int),
492 .procname =
"igmp_max_msf",
494 .maxlen =
sizeof(
int),
499 .procname =
"inet_peer_threshold",
501 .maxlen =
sizeof(
int),
506 .procname =
"inet_peer_minttl",
508 .maxlen =
sizeof(
int),
513 .procname =
"inet_peer_maxttl",
515 .maxlen =
sizeof(
int),
520 .procname =
"tcp_orphan_retries",
522 .maxlen =
sizeof(
int),
527 .procname =
"tcp_fack",
529 .maxlen =
sizeof(
int),
534 .procname =
"tcp_reordering",
536 .maxlen =
sizeof(
int),
541 .procname =
"tcp_ecn",
543 .maxlen =
sizeof(
int),
548 .procname =
"tcp_dsack",
550 .maxlen =
sizeof(
int),
555 .procname =
"tcp_wmem",
562 .procname =
"tcp_rmem",
569 .procname =
"tcp_app_win",
571 .maxlen =
sizeof(
int),
576 .procname =
"tcp_adv_win_scale",
578 .maxlen =
sizeof(
int),
581 .
extra1 = &tcp_adv_win_scale_min,
582 .
extra2 = &tcp_adv_win_scale_max,
585 .procname =
"tcp_tw_reuse",
587 .maxlen =
sizeof(
int),
592 .procname =
"tcp_frto",
594 .maxlen =
sizeof(
int),
599 .procname =
"tcp_frto_response",
601 .maxlen =
sizeof(
int),
606 .procname =
"tcp_low_latency",
608 .maxlen =
sizeof(
int),
613 .procname =
"tcp_no_metrics_save",
615 .maxlen =
sizeof(
int),
620 .procname =
"tcp_moderate_rcvbuf",
622 .maxlen =
sizeof(
int),
627 .procname =
"tcp_tso_win_divisor",
629 .maxlen =
sizeof(
int),
634 .procname =
"tcp_congestion_control",
637 .proc_handler = proc_tcp_congestion_control,
640 .procname =
"tcp_abc",
642 .maxlen =
sizeof(
int),
647 .procname =
"tcp_mtu_probing",
649 .maxlen =
sizeof(
int),
654 .procname =
"tcp_base_mss",
656 .maxlen =
sizeof(
int),
661 .procname =
"tcp_workaround_signed_windows",
663 .maxlen =
sizeof(
int),
668 .procname =
"tcp_limit_output_bytes",
670 .maxlen =
sizeof(
int),
675 .procname =
"tcp_challenge_ack_limit",
677 .maxlen =
sizeof(
int),
681 #ifdef CONFIG_NET_DMA
683 .procname =
"tcp_dma_copybreak",
685 .maxlen =
sizeof(
int),
691 .procname =
"tcp_slow_start_after_idle",
693 .maxlen =
sizeof(
int),
697 #ifdef CONFIG_NETLABEL
699 .procname =
"cipso_cache_enable",
701 .maxlen =
sizeof(
int),
706 .procname =
"cipso_cache_bucket_size",
708 .maxlen =
sizeof(
int),
713 .procname =
"cipso_rbm_optfmt",
715 .maxlen =
sizeof(
int),
720 .procname =
"cipso_rbm_strictvalid",
722 .maxlen =
sizeof(
int),
728 .procname =
"tcp_available_congestion_control",
731 .proc_handler = proc_tcp_available_congestion_control,
734 .procname =
"tcp_allowed_congestion_control",
737 .proc_handler = proc_allowed_congestion_control,
740 .procname =
"tcp_max_ssthresh",
742 .maxlen =
sizeof(
int),
747 .procname =
"tcp_cookie_size",
749 .maxlen =
sizeof(
int),
754 .procname =
"tcp_thin_linear_timeouts",
756 .maxlen =
sizeof(
int),
761 .procname =
"tcp_thin_dupack",
763 .maxlen =
sizeof(
int),
768 .procname =
"tcp_early_retrans",
770 .maxlen =
sizeof(
int),
777 .procname =
"udp_mem",
784 .procname =
"udp_rmem_min",
792 .procname =
"udp_wmem_min",
802 static struct ctl_table ipv4_net_table[] = {
805 .data = &
init_net.ipv4.sysctl_icmp_echo_ignore_all,
806 .maxlen =
sizeof(
int),
811 .procname =
"icmp_echo_ignore_broadcasts",
812 .data = &
init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
813 .maxlen =
sizeof(
int),
818 .procname =
"icmp_ignore_bogus_error_responses",
819 .data = &
init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
820 .maxlen =
sizeof(
int),
825 .procname =
"icmp_errors_use_inbound_ifaddr",
826 .data = &
init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
827 .maxlen =
sizeof(
int),
832 .procname =
"icmp_ratelimit",
833 .data = &
init_net.ipv4.sysctl_icmp_ratelimit,
834 .maxlen =
sizeof(
int),
839 .procname =
"icmp_ratemask",
840 .data = &
init_net.ipv4.sysctl_icmp_ratemask,
841 .maxlen =
sizeof(
int),
846 .procname =
"ping_group_range",
847 .data = &
init_net.ipv4.sysctl_ping_group_range,
848 .maxlen =
sizeof(
gid_t)*2,
853 .procname =
"tcp_mem",
854 .maxlen =
sizeof(
init_net.ipv4.sysctl_tcp_mem),
861 static __net_init int ipv4_sysctl_init_net(
struct net *net)
865 table = ipv4_net_table;
872 &net->
ipv4.sysctl_icmp_echo_ignore_all;
874 &net->
ipv4.sysctl_icmp_echo_ignore_broadcasts;
876 &net->
ipv4.sysctl_icmp_ignore_bogus_error_responses;
878 &net->
ipv4.sysctl_icmp_errors_use_inbound_ifaddr;
880 &net->
ipv4.sysctl_icmp_ratelimit;
882 &net->
ipv4.sysctl_icmp_ratemask;
884 &net->
ipv4.sysctl_ping_group_range;
910 static __net_exit void ipv4_sysctl_exit_net(
struct net *net)
914 table = net->
ipv4.ipv4_hdr->ctl_table_arg;
920 .
init = ipv4_sysctl_init_net,
921 .exit = ipv4_sysctl_exit_net,
924 static __init int sysctl_ipv4_init(
void)
929 for (i = ipv4_table; i->
procname; i++) {