2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4 * Begun April 1, 1996, Mike Shaver.
5 * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
9 #include <linux/module.h>
10 #include <linux/sysctl.h>
11 #include <linux/igmp.h>
12 #include <linux/inetdevice.h>
13 #include <linux/seqlock.h>
14 #include <linux/init.h>
15 #include <linux/slab.h>
16 #include <linux/nsproxy.h>
17 #include <linux/swap.h>
21 #include <net/route.h>
24 #include <net/cipso_ipv4.h>
25 #include <net/inet_frag.h>
27 #include <net/tcp_memcontrol.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 };
39 static int ip_ping_group_range_max
[] = { GID_T_MAX
, GID_T_MAX
};
41 /* Update system visible IP port range */
42 static void set_local_port_range(int range
[2])
44 write_seqlock(&sysctl_local_ports
.lock
);
45 sysctl_local_ports
.range
[0] = range
[0];
46 sysctl_local_ports
.range
[1] = range
[1];
47 write_sequnlock(&sysctl_local_ports
.lock
);
50 /* Validate changes from /proc interface. */
51 static int ipv4_local_port_range(ctl_table
*table
, int write
,
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
,
65 inet_get_local_port_range(range
, range
+ 1);
66 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
68 if (write
&& ret
== 0) {
69 if (range
[1] < range
[0])
72 set_local_port_range(range
);
79 static void inet_get_ping_group_range_table(struct ctl_table
*table
, kgid_t
*low
, kgid_t
*high
)
81 kgid_t
*data
= table
->data
;
84 seq
= read_seqbegin(&sysctl_local_ports
.lock
);
88 } while (read_seqretry(&sysctl_local_ports
.lock
, seq
));
91 /* Update system visible IP port range */
92 static void set_ping_group_range(struct ctl_table
*table
, kgid_t low
, kgid_t high
)
94 kgid_t
*data
= table
->data
;
95 write_seqlock(&sysctl_local_ports
.lock
);
98 write_sequnlock(&sysctl_local_ports
.lock
);
101 /* Validate changes from /proc interface. */
102 static int ipv4_ping_group_range(ctl_table
*table
, int write
,
104 size_t *lenp
, loff_t
*ppos
)
106 struct user_namespace
*user_ns
= current_user_ns();
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
);
119 urange
[0] = from_kgid_munged(user_ns
, low
);
120 urange
[1] = from_kgid_munged(user_ns
, high
);
121 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
123 if (write
&& ret
== 0) {
124 low
= make_kgid(user_ns
, urange
[0]);
125 high
= make_kgid(user_ns
, urange
[1]);
126 if (!gid_valid(low
) || !gid_valid(high
) ||
127 (urange
[1] < urange
[0]) || gid_lt(high
, low
)) {
128 low
= make_kgid(&init_user_ns
, 1);
129 high
= make_kgid(&init_user_ns
, 0);
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
)
140 char val
[TCP_CA_NAME_MAX
];
143 .maxlen
= TCP_CA_NAME_MAX
,
147 tcp_get_default_congestion_control(val
);
149 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
150 if (write
&& ret
== 0)
151 ret
= tcp_set_default_congestion_control(val
);
155 static int proc_tcp_available_congestion_control(ctl_table
*ctl
,
157 void __user
*buffer
, size_t *lenp
,
160 ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
163 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
166 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
167 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
172 static int proc_allowed_congestion_control(ctl_table
*ctl
,
174 void __user
*buffer
, size_t *lenp
,
177 ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
180 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
184 tcp_get_allowed_congestion_control(tbl
.data
, tbl
.maxlen
);
185 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
186 if (write
&& ret
== 0)
187 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
192 static int ipv4_tcp_mem(ctl_table
*ctl
, int write
,
193 void __user
*buffer
, size_t *lenp
,
197 unsigned long vec
[3];
198 struct net
*net
= current
->nsproxy
->net_ns
;
199 #ifdef CONFIG_MEMCG_KMEM
200 struct mem_cgroup
*memcg
;
205 .maxlen
= sizeof(vec
),
210 ctl
->data
= &net
->ipv4
.sysctl_tcp_mem
;
211 return proc_doulongvec_minmax(ctl
, write
, buffer
, lenp
, ppos
);
214 ret
= proc_doulongvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
218 #ifdef CONFIG_MEMCG_KMEM
220 memcg
= mem_cgroup_from_task(current
);
222 tcp_prot_mem(memcg
, vec
[0], 0);
223 tcp_prot_mem(memcg
, vec
[1], 1);
224 tcp_prot_mem(memcg
, vec
[2], 2);
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];
235 int proc_tcp_fastopen_key(ctl_table
*ctl
, int write
, void __user
*buffer
,
236 size_t *lenp
, loff_t
*ppos
)
238 ctl_table tbl
= { .maxlen
= (TCP_FASTOPEN_KEY_LENGTH
* 2 + 10) };
239 struct tcp_fastopen_context
*ctxt
;
241 u32 user_key
[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
243 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_KERNEL
);
248 ctxt
= rcu_dereference(tcp_fastopen_ctx
);
250 memcpy(user_key
, ctxt
->key
, TCP_FASTOPEN_KEY_LENGTH
);
252 memset(user_key
, 0, sizeof(user_key
));
255 snprintf(tbl
.data
, tbl
.maxlen
, "%08x-%08x-%08x-%08x",
256 user_key
[0], user_key
[1], user_key
[2], user_key
[3]);
257 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
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) {
265 tcp_fastopen_reset_cipher(user_key
, TCP_FASTOPEN_KEY_LENGTH
);
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
);
276 static struct ctl_table ipv4_table
[] = {
278 .procname
= "tcp_timestamps",
279 .data
= &sysctl_tcp_timestamps
,
280 .maxlen
= sizeof(int),
282 .proc_handler
= proc_dointvec
285 .procname
= "tcp_window_scaling",
286 .data
= &sysctl_tcp_window_scaling
,
287 .maxlen
= sizeof(int),
289 .proc_handler
= proc_dointvec
292 .procname
= "tcp_sack",
293 .data
= &sysctl_tcp_sack
,
294 .maxlen
= sizeof(int),
296 .proc_handler
= proc_dointvec
299 .procname
= "tcp_retrans_collapse",
300 .data
= &sysctl_tcp_retrans_collapse
,
301 .maxlen
= sizeof(int),
303 .proc_handler
= proc_dointvec
306 .procname
= "ip_default_ttl",
307 .data
= &sysctl_ip_default_ttl
,
308 .maxlen
= sizeof(int),
310 .proc_handler
= proc_dointvec_minmax
,
311 .extra1
= &ip_ttl_min
,
312 .extra2
= &ip_ttl_max
,
315 .procname
= "ip_no_pmtu_disc",
316 .data
= &ipv4_config
.no_pmtu_disc
,
317 .maxlen
= sizeof(int),
319 .proc_handler
= proc_dointvec
322 .procname
= "ip_nonlocal_bind",
323 .data
= &sysctl_ip_nonlocal_bind
,
324 .maxlen
= sizeof(int),
326 .proc_handler
= proc_dointvec
329 .procname
= "tcp_syn_retries",
330 .data
= &sysctl_tcp_syn_retries
,
331 .maxlen
= sizeof(int),
333 .proc_handler
= proc_dointvec
336 .procname
= "tcp_synack_retries",
337 .data
= &sysctl_tcp_synack_retries
,
338 .maxlen
= sizeof(int),
340 .proc_handler
= proc_dointvec
343 .procname
= "tcp_max_orphans",
344 .data
= &sysctl_tcp_max_orphans
,
345 .maxlen
= sizeof(int),
347 .proc_handler
= proc_dointvec
350 .procname
= "tcp_max_tw_buckets",
351 .data
= &tcp_death_row
.sysctl_max_tw_buckets
,
352 .maxlen
= sizeof(int),
354 .proc_handler
= proc_dointvec
357 .procname
= "ip_early_demux",
358 .data
= &sysctl_ip_early_demux
,
359 .maxlen
= sizeof(int),
361 .proc_handler
= proc_dointvec
364 .procname
= "ip_dynaddr",
365 .data
= &sysctl_ip_dynaddr
,
366 .maxlen
= sizeof(int),
368 .proc_handler
= proc_dointvec
371 .procname
= "tcp_keepalive_time",
372 .data
= &sysctl_tcp_keepalive_time
,
373 .maxlen
= sizeof(int),
375 .proc_handler
= proc_dointvec_jiffies
,
378 .procname
= "tcp_keepalive_probes",
379 .data
= &sysctl_tcp_keepalive_probes
,
380 .maxlen
= sizeof(int),
382 .proc_handler
= proc_dointvec
385 .procname
= "tcp_keepalive_intvl",
386 .data
= &sysctl_tcp_keepalive_intvl
,
387 .maxlen
= sizeof(int),
389 .proc_handler
= proc_dointvec_jiffies
,
392 .procname
= "tcp_retries1",
393 .data
= &sysctl_tcp_retries1
,
394 .maxlen
= sizeof(int),
396 .proc_handler
= proc_dointvec_minmax
,
397 .extra2
= &tcp_retr1_max
400 .procname
= "tcp_retries2",
401 .data
= &sysctl_tcp_retries2
,
402 .maxlen
= sizeof(int),
404 .proc_handler
= proc_dointvec
407 .procname
= "tcp_fin_timeout",
408 .data
= &sysctl_tcp_fin_timeout
,
409 .maxlen
= sizeof(int),
411 .proc_handler
= proc_dointvec_jiffies
,
413 #ifdef CONFIG_SYN_COOKIES
415 .procname
= "tcp_syncookies",
416 .data
= &sysctl_tcp_syncookies
,
417 .maxlen
= sizeof(int),
419 .proc_handler
= proc_dointvec
423 .procname
= "tcp_fastopen",
424 .data
= &sysctl_tcp_fastopen
,
425 .maxlen
= sizeof(int),
427 .proc_handler
= proc_dointvec
,
430 .procname
= "tcp_fastopen_key",
432 .maxlen
= ((TCP_FASTOPEN_KEY_LENGTH
* 2) + 10),
433 .proc_handler
= proc_tcp_fastopen_key
,
436 .procname
= "tcp_tw_recycle",
437 .data
= &tcp_death_row
.sysctl_tw_recycle
,
438 .maxlen
= sizeof(int),
440 .proc_handler
= proc_dointvec
443 .procname
= "tcp_abort_on_overflow",
444 .data
= &sysctl_tcp_abort_on_overflow
,
445 .maxlen
= sizeof(int),
447 .proc_handler
= proc_dointvec
450 .procname
= "tcp_stdurg",
451 .data
= &sysctl_tcp_stdurg
,
452 .maxlen
= sizeof(int),
454 .proc_handler
= proc_dointvec
457 .procname
= "tcp_rfc1337",
458 .data
= &sysctl_tcp_rfc1337
,
459 .maxlen
= sizeof(int),
461 .proc_handler
= proc_dointvec
464 .procname
= "tcp_max_syn_backlog",
465 .data
= &sysctl_max_syn_backlog
,
466 .maxlen
= sizeof(int),
468 .proc_handler
= proc_dointvec
471 .procname
= "ip_local_port_range",
472 .data
= &sysctl_local_ports
.range
,
473 .maxlen
= sizeof(sysctl_local_ports
.range
),
475 .proc_handler
= ipv4_local_port_range
,
478 .procname
= "ip_local_reserved_ports",
479 .data
= NULL
, /* initialized in sysctl_ipv4_init */
482 .proc_handler
= proc_do_large_bitmap
,
485 .procname
= "igmp_max_memberships",
486 .data
= &sysctl_igmp_max_memberships
,
487 .maxlen
= sizeof(int),
489 .proc_handler
= proc_dointvec
492 .procname
= "igmp_max_msf",
493 .data
= &sysctl_igmp_max_msf
,
494 .maxlen
= sizeof(int),
496 .proc_handler
= proc_dointvec
499 .procname
= "inet_peer_threshold",
500 .data
= &inet_peer_threshold
,
501 .maxlen
= sizeof(int),
503 .proc_handler
= proc_dointvec
506 .procname
= "inet_peer_minttl",
507 .data
= &inet_peer_minttl
,
508 .maxlen
= sizeof(int),
510 .proc_handler
= proc_dointvec_jiffies
,
513 .procname
= "inet_peer_maxttl",
514 .data
= &inet_peer_maxttl
,
515 .maxlen
= sizeof(int),
517 .proc_handler
= proc_dointvec_jiffies
,
520 .procname
= "tcp_orphan_retries",
521 .data
= &sysctl_tcp_orphan_retries
,
522 .maxlen
= sizeof(int),
524 .proc_handler
= proc_dointvec
527 .procname
= "tcp_fack",
528 .data
= &sysctl_tcp_fack
,
529 .maxlen
= sizeof(int),
531 .proc_handler
= proc_dointvec
534 .procname
= "tcp_reordering",
535 .data
= &sysctl_tcp_reordering
,
536 .maxlen
= sizeof(int),
538 .proc_handler
= proc_dointvec
541 .procname
= "tcp_ecn",
542 .data
= &sysctl_tcp_ecn
,
543 .maxlen
= sizeof(int),
545 .proc_handler
= proc_dointvec
548 .procname
= "tcp_dsack",
549 .data
= &sysctl_tcp_dsack
,
550 .maxlen
= sizeof(int),
552 .proc_handler
= proc_dointvec
555 .procname
= "tcp_wmem",
556 .data
= &sysctl_tcp_wmem
,
557 .maxlen
= sizeof(sysctl_tcp_wmem
),
559 .proc_handler
= proc_dointvec
562 .procname
= "tcp_rmem",
563 .data
= &sysctl_tcp_rmem
,
564 .maxlen
= sizeof(sysctl_tcp_rmem
),
566 .proc_handler
= proc_dointvec
569 .procname
= "tcp_app_win",
570 .data
= &sysctl_tcp_app_win
,
571 .maxlen
= sizeof(int),
573 .proc_handler
= proc_dointvec
576 .procname
= "tcp_adv_win_scale",
577 .data
= &sysctl_tcp_adv_win_scale
,
578 .maxlen
= sizeof(int),
580 .proc_handler
= proc_dointvec_minmax
,
581 .extra1
= &tcp_adv_win_scale_min
,
582 .extra2
= &tcp_adv_win_scale_max
,
585 .procname
= "tcp_tw_reuse",
586 .data
= &sysctl_tcp_tw_reuse
,
587 .maxlen
= sizeof(int),
589 .proc_handler
= proc_dointvec
592 .procname
= "tcp_frto",
593 .data
= &sysctl_tcp_frto
,
594 .maxlen
= sizeof(int),
596 .proc_handler
= proc_dointvec
599 .procname
= "tcp_frto_response",
600 .data
= &sysctl_tcp_frto_response
,
601 .maxlen
= sizeof(int),
603 .proc_handler
= proc_dointvec
606 .procname
= "tcp_low_latency",
607 .data
= &sysctl_tcp_low_latency
,
608 .maxlen
= sizeof(int),
610 .proc_handler
= proc_dointvec
613 .procname
= "tcp_no_metrics_save",
614 .data
= &sysctl_tcp_nometrics_save
,
615 .maxlen
= sizeof(int),
617 .proc_handler
= proc_dointvec
,
620 .procname
= "tcp_moderate_rcvbuf",
621 .data
= &sysctl_tcp_moderate_rcvbuf
,
622 .maxlen
= sizeof(int),
624 .proc_handler
= proc_dointvec
,
627 .procname
= "tcp_tso_win_divisor",
628 .data
= &sysctl_tcp_tso_win_divisor
,
629 .maxlen
= sizeof(int),
631 .proc_handler
= proc_dointvec
,
634 .procname
= "tcp_congestion_control",
636 .maxlen
= TCP_CA_NAME_MAX
,
637 .proc_handler
= proc_tcp_congestion_control
,
640 .procname
= "tcp_abc",
641 .data
= &sysctl_tcp_abc
,
642 .maxlen
= sizeof(int),
644 .proc_handler
= proc_dointvec
,
647 .procname
= "tcp_mtu_probing",
648 .data
= &sysctl_tcp_mtu_probing
,
649 .maxlen
= sizeof(int),
651 .proc_handler
= proc_dointvec
,
654 .procname
= "tcp_base_mss",
655 .data
= &sysctl_tcp_base_mss
,
656 .maxlen
= sizeof(int),
658 .proc_handler
= proc_dointvec
,
661 .procname
= "tcp_workaround_signed_windows",
662 .data
= &sysctl_tcp_workaround_signed_windows
,
663 .maxlen
= sizeof(int),
665 .proc_handler
= proc_dointvec
668 .procname
= "tcp_limit_output_bytes",
669 .data
= &sysctl_tcp_limit_output_bytes
,
670 .maxlen
= sizeof(int),
672 .proc_handler
= proc_dointvec
675 .procname
= "tcp_challenge_ack_limit",
676 .data
= &sysctl_tcp_challenge_ack_limit
,
677 .maxlen
= sizeof(int),
679 .proc_handler
= proc_dointvec
681 #ifdef CONFIG_NET_DMA
683 .procname
= "tcp_dma_copybreak",
684 .data
= &sysctl_tcp_dma_copybreak
,
685 .maxlen
= sizeof(int),
687 .proc_handler
= proc_dointvec
691 .procname
= "tcp_slow_start_after_idle",
692 .data
= &sysctl_tcp_slow_start_after_idle
,
693 .maxlen
= sizeof(int),
695 .proc_handler
= proc_dointvec
697 #ifdef CONFIG_NETLABEL
699 .procname
= "cipso_cache_enable",
700 .data
= &cipso_v4_cache_enabled
,
701 .maxlen
= sizeof(int),
703 .proc_handler
= proc_dointvec
,
706 .procname
= "cipso_cache_bucket_size",
707 .data
= &cipso_v4_cache_bucketsize
,
708 .maxlen
= sizeof(int),
710 .proc_handler
= proc_dointvec
,
713 .procname
= "cipso_rbm_optfmt",
714 .data
= &cipso_v4_rbm_optfmt
,
715 .maxlen
= sizeof(int),
717 .proc_handler
= proc_dointvec
,
720 .procname
= "cipso_rbm_strictvalid",
721 .data
= &cipso_v4_rbm_strictvalid
,
722 .maxlen
= sizeof(int),
724 .proc_handler
= proc_dointvec
,
726 #endif /* CONFIG_NETLABEL */
728 .procname
= "tcp_available_congestion_control",
729 .maxlen
= TCP_CA_BUF_MAX
,
731 .proc_handler
= proc_tcp_available_congestion_control
,
734 .procname
= "tcp_allowed_congestion_control",
735 .maxlen
= TCP_CA_BUF_MAX
,
737 .proc_handler
= proc_allowed_congestion_control
,
740 .procname
= "tcp_max_ssthresh",
741 .data
= &sysctl_tcp_max_ssthresh
,
742 .maxlen
= sizeof(int),
744 .proc_handler
= proc_dointvec
,
747 .procname
= "tcp_cookie_size",
748 .data
= &sysctl_tcp_cookie_size
,
749 .maxlen
= sizeof(int),
751 .proc_handler
= proc_dointvec
754 .procname
= "tcp_thin_linear_timeouts",
755 .data
= &sysctl_tcp_thin_linear_timeouts
,
756 .maxlen
= sizeof(int),
758 .proc_handler
= proc_dointvec
761 .procname
= "tcp_thin_dupack",
762 .data
= &sysctl_tcp_thin_dupack
,
763 .maxlen
= sizeof(int),
765 .proc_handler
= proc_dointvec
768 .procname
= "tcp_early_retrans",
769 .data
= &sysctl_tcp_early_retrans
,
770 .maxlen
= sizeof(int),
772 .proc_handler
= proc_dointvec_minmax
,
777 .procname
= "udp_mem",
778 .data
= &sysctl_udp_mem
,
779 .maxlen
= sizeof(sysctl_udp_mem
),
781 .proc_handler
= proc_doulongvec_minmax
,
784 .procname
= "udp_rmem_min",
785 .data
= &sysctl_udp_rmem_min
,
786 .maxlen
= sizeof(sysctl_udp_rmem_min
),
788 .proc_handler
= proc_dointvec_minmax
,
792 .procname
= "udp_wmem_min",
793 .data
= &sysctl_udp_wmem_min
,
794 .maxlen
= sizeof(sysctl_udp_wmem_min
),
796 .proc_handler
= proc_dointvec_minmax
,
802 static struct ctl_table ipv4_net_table
[] = {
804 .procname
= "icmp_echo_ignore_all",
805 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_all
,
806 .maxlen
= sizeof(int),
808 .proc_handler
= proc_dointvec
811 .procname
= "icmp_echo_ignore_broadcasts",
812 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_broadcasts
,
813 .maxlen
= sizeof(int),
815 .proc_handler
= proc_dointvec
818 .procname
= "icmp_ignore_bogus_error_responses",
819 .data
= &init_net
.ipv4
.sysctl_icmp_ignore_bogus_error_responses
,
820 .maxlen
= sizeof(int),
822 .proc_handler
= proc_dointvec
825 .procname
= "icmp_errors_use_inbound_ifaddr",
826 .data
= &init_net
.ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
,
827 .maxlen
= sizeof(int),
829 .proc_handler
= proc_dointvec
832 .procname
= "icmp_ratelimit",
833 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
834 .maxlen
= sizeof(int),
836 .proc_handler
= proc_dointvec_ms_jiffies
,
839 .procname
= "icmp_ratemask",
840 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
841 .maxlen
= sizeof(int),
843 .proc_handler
= proc_dointvec
846 .procname
= "ping_group_range",
847 .data
= &init_net
.ipv4
.sysctl_ping_group_range
,
848 .maxlen
= sizeof(gid_t
)*2,
850 .proc_handler
= ipv4_ping_group_range
,
853 .procname
= "tcp_mem",
854 .maxlen
= sizeof(init_net
.ipv4
.sysctl_tcp_mem
),
856 .proc_handler
= ipv4_tcp_mem
,
861 static __net_init
int ipv4_sysctl_init_net(struct net
*net
)
863 struct ctl_table
*table
;
865 table
= ipv4_net_table
;
866 if (!net_eq(net
, &init_net
)) {
867 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
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
;
886 /* Don't export sysctls to unprivileged users */
887 if (net
->user_ns
!= &init_user_ns
)
888 table
[0].procname
= NULL
;
892 * Sane defaults - nobody may create ping sockets.
893 * Boot scripts should set this to distro-specific group.
895 net
->ipv4
.sysctl_ping_group_range
[0] = make_kgid(&init_user_ns
, 1);
896 net
->ipv4
.sysctl_ping_group_range
[1] = make_kgid(&init_user_ns
, 0);
900 net
->ipv4
.ipv4_hdr
= register_net_sysctl(net
, "net/ipv4", table
);
901 if (net
->ipv4
.ipv4_hdr
== NULL
)
907 if (!net_eq(net
, &init_net
))
913 static __net_exit
void ipv4_sysctl_exit_net(struct net
*net
)
915 struct ctl_table
*table
;
917 table
= net
->ipv4
.ipv4_hdr
->ctl_table_arg
;
918 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
922 static __net_initdata
struct pernet_operations ipv4_sysctl_ops
= {
923 .init
= ipv4_sysctl_init_net
,
924 .exit
= ipv4_sysctl_exit_net
,
927 static __init
int sysctl_ipv4_init(void)
929 struct ctl_table_header
*hdr
;
932 for (i
= ipv4_table
; i
->procname
; i
++) {
933 if (strcmp(i
->procname
, "ip_local_reserved_ports") == 0) {
934 i
->data
= sysctl_local_reserved_ports
;
941 hdr
= register_net_sysctl(&init_net
, "net/ipv4", ipv4_table
);
945 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
946 unregister_net_sysctl_table(hdr
);
953 __initcall(sysctl_ipv4_init
);