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>
32 static int thousand
= 1000;
33 static int gso_max_segs
= GSO_MAX_SEGS
;
34 static int tcp_retr1_max
= 255;
35 static int ip_local_port_range_min
[] = { 1, 1 };
36 static int ip_local_port_range_max
[] = { 65535, 65535 };
37 static int tcp_adv_win_scale_min
= -31;
38 static int tcp_adv_win_scale_max
= 31;
39 static int ip_ttl_min
= 1;
40 static int ip_ttl_max
= 255;
41 static int tcp_syn_retries_min
= 1;
42 static int tcp_syn_retries_max
= MAX_TCP_SYNCNT
;
43 static int ip_ping_group_range_min
[] = { 0, 0 };
44 static int ip_ping_group_range_max
[] = { GID_T_MAX
, GID_T_MAX
};
46 /* Update system visible IP port range */
47 static void set_local_port_range(struct net
*net
, int range
[2])
49 bool same_parity
= !((range
[0] ^ range
[1]) & 1);
51 write_seqlock_bh(&net
->ipv4
.ip_local_ports
.lock
);
52 if (same_parity
&& !net
->ipv4
.ip_local_ports
.warned
) {
53 net
->ipv4
.ip_local_ports
.warned
= true;
54 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
56 net
->ipv4
.ip_local_ports
.range
[0] = range
[0];
57 net
->ipv4
.ip_local_ports
.range
[1] = range
[1];
58 write_sequnlock_bh(&net
->ipv4
.ip_local_ports
.lock
);
61 /* Validate changes from /proc interface. */
62 static int ipv4_local_port_range(struct ctl_table
*table
, int write
,
64 size_t *lenp
, loff_t
*ppos
)
67 container_of(table
->data
, struct net
, ipv4
.ip_local_ports
.range
);
70 struct ctl_table tmp
= {
72 .maxlen
= sizeof(range
),
74 .extra1
= &ip_local_port_range_min
,
75 .extra2
= &ip_local_port_range_max
,
78 inet_get_local_port_range(net
, &range
[0], &range
[1]);
80 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
82 if (write
&& ret
== 0) {
83 if (range
[1] < range
[0])
86 set_local_port_range(net
, range
);
93 static void inet_get_ping_group_range_table(struct ctl_table
*table
, kgid_t
*low
, kgid_t
*high
)
95 kgid_t
*data
= table
->data
;
97 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
100 seq
= read_seqbegin(&net
->ipv4
.ip_local_ports
.lock
);
104 } while (read_seqretry(&net
->ipv4
.ip_local_ports
.lock
, seq
));
107 /* Update system visible IP port range */
108 static void set_ping_group_range(struct ctl_table
*table
, kgid_t low
, kgid_t high
)
110 kgid_t
*data
= table
->data
;
112 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
113 write_seqlock(&net
->ipv4
.ip_local_ports
.lock
);
116 write_sequnlock(&net
->ipv4
.ip_local_ports
.lock
);
119 /* Validate changes from /proc interface. */
120 static int ipv4_ping_group_range(struct ctl_table
*table
, int write
,
122 size_t *lenp
, loff_t
*ppos
)
124 struct user_namespace
*user_ns
= current_user_ns();
128 struct ctl_table tmp
= {
130 .maxlen
= sizeof(urange
),
132 .extra1
= &ip_ping_group_range_min
,
133 .extra2
= &ip_ping_group_range_max
,
136 inet_get_ping_group_range_table(table
, &low
, &high
);
137 urange
[0] = from_kgid_munged(user_ns
, low
);
138 urange
[1] = from_kgid_munged(user_ns
, high
);
139 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
141 if (write
&& ret
== 0) {
142 low
= make_kgid(user_ns
, urange
[0]);
143 high
= make_kgid(user_ns
, urange
[1]);
144 if (!gid_valid(low
) || !gid_valid(high
) ||
145 (urange
[1] < urange
[0]) || gid_lt(high
, low
)) {
146 low
= make_kgid(&init_user_ns
, 1);
147 high
= make_kgid(&init_user_ns
, 0);
149 set_ping_group_range(table
, low
, high
);
155 static int proc_tcp_congestion_control(struct ctl_table
*ctl
, int write
,
156 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
158 char val
[TCP_CA_NAME_MAX
];
159 struct ctl_table tbl
= {
161 .maxlen
= TCP_CA_NAME_MAX
,
165 tcp_get_default_congestion_control(val
);
167 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
168 if (write
&& ret
== 0)
169 ret
= tcp_set_default_congestion_control(val
);
173 static int proc_tcp_available_congestion_control(struct ctl_table
*ctl
,
175 void __user
*buffer
, size_t *lenp
,
178 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
181 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
184 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
185 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
190 static int proc_allowed_congestion_control(struct ctl_table
*ctl
,
192 void __user
*buffer
, size_t *lenp
,
195 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
198 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
202 tcp_get_allowed_congestion_control(tbl
.data
, tbl
.maxlen
);
203 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
204 if (write
&& ret
== 0)
205 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
210 static int proc_tcp_fastopen_key(struct ctl_table
*ctl
, int write
,
211 void __user
*buffer
, size_t *lenp
,
214 struct ctl_table tbl
= { .maxlen
= (TCP_FASTOPEN_KEY_LENGTH
* 2 + 10) };
215 struct tcp_fastopen_context
*ctxt
;
217 u32 user_key
[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
219 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_KERNEL
);
224 ctxt
= rcu_dereference(tcp_fastopen_ctx
);
226 memcpy(user_key
, ctxt
->key
, TCP_FASTOPEN_KEY_LENGTH
);
228 memset(user_key
, 0, sizeof(user_key
));
231 snprintf(tbl
.data
, tbl
.maxlen
, "%08x-%08x-%08x-%08x",
232 user_key
[0], user_key
[1], user_key
[2], user_key
[3]);
233 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
235 if (write
&& ret
== 0) {
236 if (sscanf(tbl
.data
, "%x-%x-%x-%x", user_key
, user_key
+ 1,
237 user_key
+ 2, user_key
+ 3) != 4) {
241 /* Generate a dummy secret but don't publish it. This
242 * is needed so we don't regenerate a new key on the
243 * first invocation of tcp_fastopen_cookie_gen
245 tcp_fastopen_init_key_once(false);
246 tcp_fastopen_reset_cipher(user_key
, TCP_FASTOPEN_KEY_LENGTH
);
250 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
251 user_key
[0], user_key
[1], user_key
[2], user_key
[3],
252 (char *)tbl
.data
, ret
);
257 static struct ctl_table ipv4_table
[] = {
259 .procname
= "tcp_timestamps",
260 .data
= &sysctl_tcp_timestamps
,
261 .maxlen
= sizeof(int),
263 .proc_handler
= proc_dointvec
266 .procname
= "tcp_window_scaling",
267 .data
= &sysctl_tcp_window_scaling
,
268 .maxlen
= sizeof(int),
270 .proc_handler
= proc_dointvec
273 .procname
= "tcp_sack",
274 .data
= &sysctl_tcp_sack
,
275 .maxlen
= sizeof(int),
277 .proc_handler
= proc_dointvec
280 .procname
= "tcp_retrans_collapse",
281 .data
= &sysctl_tcp_retrans_collapse
,
282 .maxlen
= sizeof(int),
284 .proc_handler
= proc_dointvec
287 .procname
= "ip_default_ttl",
288 .data
= &sysctl_ip_default_ttl
,
289 .maxlen
= sizeof(int),
291 .proc_handler
= proc_dointvec_minmax
,
292 .extra1
= &ip_ttl_min
,
293 .extra2
= &ip_ttl_max
,
296 .procname
= "tcp_syn_retries",
297 .data
= &sysctl_tcp_syn_retries
,
298 .maxlen
= sizeof(int),
300 .proc_handler
= proc_dointvec_minmax
,
301 .extra1
= &tcp_syn_retries_min
,
302 .extra2
= &tcp_syn_retries_max
305 .procname
= "tcp_synack_retries",
306 .data
= &sysctl_tcp_synack_retries
,
307 .maxlen
= sizeof(int),
309 .proc_handler
= proc_dointvec
312 .procname
= "tcp_max_orphans",
313 .data
= &sysctl_tcp_max_orphans
,
314 .maxlen
= sizeof(int),
316 .proc_handler
= proc_dointvec
319 .procname
= "tcp_max_tw_buckets",
320 .data
= &tcp_death_row
.sysctl_max_tw_buckets
,
321 .maxlen
= sizeof(int),
323 .proc_handler
= proc_dointvec
326 .procname
= "ip_early_demux",
327 .data
= &sysctl_ip_early_demux
,
328 .maxlen
= sizeof(int),
330 .proc_handler
= proc_dointvec
333 .procname
= "ip_dynaddr",
334 .data
= &sysctl_ip_dynaddr
,
335 .maxlen
= sizeof(int),
337 .proc_handler
= proc_dointvec
340 .procname
= "tcp_keepalive_time",
341 .data
= &sysctl_tcp_keepalive_time
,
342 .maxlen
= sizeof(int),
344 .proc_handler
= proc_dointvec_jiffies
,
347 .procname
= "tcp_keepalive_probes",
348 .data
= &sysctl_tcp_keepalive_probes
,
349 .maxlen
= sizeof(int),
351 .proc_handler
= proc_dointvec
354 .procname
= "tcp_keepalive_intvl",
355 .data
= &sysctl_tcp_keepalive_intvl
,
356 .maxlen
= sizeof(int),
358 .proc_handler
= proc_dointvec_jiffies
,
361 .procname
= "tcp_retries1",
362 .data
= &sysctl_tcp_retries1
,
363 .maxlen
= sizeof(int),
365 .proc_handler
= proc_dointvec_minmax
,
366 .extra2
= &tcp_retr1_max
369 .procname
= "tcp_retries2",
370 .data
= &sysctl_tcp_retries2
,
371 .maxlen
= sizeof(int),
373 .proc_handler
= proc_dointvec
376 .procname
= "tcp_fin_timeout",
377 .data
= &sysctl_tcp_fin_timeout
,
378 .maxlen
= sizeof(int),
380 .proc_handler
= proc_dointvec_jiffies
,
382 #ifdef CONFIG_SYN_COOKIES
384 .procname
= "tcp_syncookies",
385 .data
= &sysctl_tcp_syncookies
,
386 .maxlen
= sizeof(int),
388 .proc_handler
= proc_dointvec
392 .procname
= "tcp_fastopen",
393 .data
= &sysctl_tcp_fastopen
,
394 .maxlen
= sizeof(int),
396 .proc_handler
= proc_dointvec
,
399 .procname
= "tcp_fastopen_key",
401 .maxlen
= ((TCP_FASTOPEN_KEY_LENGTH
* 2) + 10),
402 .proc_handler
= proc_tcp_fastopen_key
,
405 .procname
= "tcp_tw_recycle",
406 .data
= &tcp_death_row
.sysctl_tw_recycle
,
407 .maxlen
= sizeof(int),
409 .proc_handler
= proc_dointvec
412 .procname
= "tcp_abort_on_overflow",
413 .data
= &sysctl_tcp_abort_on_overflow
,
414 .maxlen
= sizeof(int),
416 .proc_handler
= proc_dointvec
419 .procname
= "tcp_stdurg",
420 .data
= &sysctl_tcp_stdurg
,
421 .maxlen
= sizeof(int),
423 .proc_handler
= proc_dointvec
426 .procname
= "tcp_rfc1337",
427 .data
= &sysctl_tcp_rfc1337
,
428 .maxlen
= sizeof(int),
430 .proc_handler
= proc_dointvec
433 .procname
= "tcp_max_syn_backlog",
434 .data
= &sysctl_max_syn_backlog
,
435 .maxlen
= sizeof(int),
437 .proc_handler
= proc_dointvec
440 .procname
= "igmp_max_memberships",
441 .data
= &sysctl_igmp_max_memberships
,
442 .maxlen
= sizeof(int),
444 .proc_handler
= proc_dointvec
447 .procname
= "igmp_max_msf",
448 .data
= &sysctl_igmp_max_msf
,
449 .maxlen
= sizeof(int),
451 .proc_handler
= proc_dointvec
453 #ifdef CONFIG_IP_MULTICAST
455 .procname
= "igmp_qrv",
456 .data
= &sysctl_igmp_qrv
,
457 .maxlen
= sizeof(int),
459 .proc_handler
= proc_dointvec_minmax
,
464 .procname
= "inet_peer_threshold",
465 .data
= &inet_peer_threshold
,
466 .maxlen
= sizeof(int),
468 .proc_handler
= proc_dointvec
471 .procname
= "inet_peer_minttl",
472 .data
= &inet_peer_minttl
,
473 .maxlen
= sizeof(int),
475 .proc_handler
= proc_dointvec_jiffies
,
478 .procname
= "inet_peer_maxttl",
479 .data
= &inet_peer_maxttl
,
480 .maxlen
= sizeof(int),
482 .proc_handler
= proc_dointvec_jiffies
,
485 .procname
= "tcp_orphan_retries",
486 .data
= &sysctl_tcp_orphan_retries
,
487 .maxlen
= sizeof(int),
489 .proc_handler
= proc_dointvec
492 .procname
= "tcp_fack",
493 .data
= &sysctl_tcp_fack
,
494 .maxlen
= sizeof(int),
496 .proc_handler
= proc_dointvec
499 .procname
= "tcp_recovery",
500 .data
= &sysctl_tcp_recovery
,
501 .maxlen
= sizeof(int),
503 .proc_handler
= proc_dointvec
,
506 .procname
= "tcp_reordering",
507 .data
= &sysctl_tcp_reordering
,
508 .maxlen
= sizeof(int),
510 .proc_handler
= proc_dointvec
513 .procname
= "tcp_max_reordering",
514 .data
= &sysctl_tcp_max_reordering
,
515 .maxlen
= sizeof(int),
517 .proc_handler
= proc_dointvec
520 .procname
= "tcp_dsack",
521 .data
= &sysctl_tcp_dsack
,
522 .maxlen
= sizeof(int),
524 .proc_handler
= proc_dointvec
527 .procname
= "tcp_mem",
528 .maxlen
= sizeof(sysctl_tcp_mem
),
529 .data
= &sysctl_tcp_mem
,
531 .proc_handler
= proc_doulongvec_minmax
,
534 .procname
= "tcp_wmem",
535 .data
= &sysctl_tcp_wmem
,
536 .maxlen
= sizeof(sysctl_tcp_wmem
),
538 .proc_handler
= proc_dointvec_minmax
,
542 .procname
= "tcp_notsent_lowat",
543 .data
= &sysctl_tcp_notsent_lowat
,
544 .maxlen
= sizeof(sysctl_tcp_notsent_lowat
),
546 .proc_handler
= proc_dointvec
,
549 .procname
= "tcp_rmem",
550 .data
= &sysctl_tcp_rmem
,
551 .maxlen
= sizeof(sysctl_tcp_rmem
),
553 .proc_handler
= proc_dointvec_minmax
,
557 .procname
= "tcp_app_win",
558 .data
= &sysctl_tcp_app_win
,
559 .maxlen
= sizeof(int),
561 .proc_handler
= proc_dointvec
564 .procname
= "tcp_adv_win_scale",
565 .data
= &sysctl_tcp_adv_win_scale
,
566 .maxlen
= sizeof(int),
568 .proc_handler
= proc_dointvec_minmax
,
569 .extra1
= &tcp_adv_win_scale_min
,
570 .extra2
= &tcp_adv_win_scale_max
,
573 .procname
= "tcp_tw_reuse",
574 .data
= &sysctl_tcp_tw_reuse
,
575 .maxlen
= sizeof(int),
577 .proc_handler
= proc_dointvec
580 .procname
= "tcp_frto",
581 .data
= &sysctl_tcp_frto
,
582 .maxlen
= sizeof(int),
584 .proc_handler
= proc_dointvec
587 .procname
= "tcp_min_rtt_wlen",
588 .data
= &sysctl_tcp_min_rtt_wlen
,
589 .maxlen
= sizeof(int),
591 .proc_handler
= proc_dointvec
594 .procname
= "tcp_low_latency",
595 .data
= &sysctl_tcp_low_latency
,
596 .maxlen
= sizeof(int),
598 .proc_handler
= proc_dointvec
601 .procname
= "tcp_no_metrics_save",
602 .data
= &sysctl_tcp_nometrics_save
,
603 .maxlen
= sizeof(int),
605 .proc_handler
= proc_dointvec
,
608 .procname
= "tcp_moderate_rcvbuf",
609 .data
= &sysctl_tcp_moderate_rcvbuf
,
610 .maxlen
= sizeof(int),
612 .proc_handler
= proc_dointvec
,
615 .procname
= "tcp_tso_win_divisor",
616 .data
= &sysctl_tcp_tso_win_divisor
,
617 .maxlen
= sizeof(int),
619 .proc_handler
= proc_dointvec
,
622 .procname
= "tcp_congestion_control",
624 .maxlen
= TCP_CA_NAME_MAX
,
625 .proc_handler
= proc_tcp_congestion_control
,
628 .procname
= "tcp_workaround_signed_windows",
629 .data
= &sysctl_tcp_workaround_signed_windows
,
630 .maxlen
= sizeof(int),
632 .proc_handler
= proc_dointvec
635 .procname
= "tcp_limit_output_bytes",
636 .data
= &sysctl_tcp_limit_output_bytes
,
637 .maxlen
= sizeof(int),
639 .proc_handler
= proc_dointvec
642 .procname
= "tcp_challenge_ack_limit",
643 .data
= &sysctl_tcp_challenge_ack_limit
,
644 .maxlen
= sizeof(int),
646 .proc_handler
= proc_dointvec
649 .procname
= "tcp_slow_start_after_idle",
650 .data
= &sysctl_tcp_slow_start_after_idle
,
651 .maxlen
= sizeof(int),
653 .proc_handler
= proc_dointvec
655 #ifdef CONFIG_NETLABEL
657 .procname
= "cipso_cache_enable",
658 .data
= &cipso_v4_cache_enabled
,
659 .maxlen
= sizeof(int),
661 .proc_handler
= proc_dointvec
,
664 .procname
= "cipso_cache_bucket_size",
665 .data
= &cipso_v4_cache_bucketsize
,
666 .maxlen
= sizeof(int),
668 .proc_handler
= proc_dointvec
,
671 .procname
= "cipso_rbm_optfmt",
672 .data
= &cipso_v4_rbm_optfmt
,
673 .maxlen
= sizeof(int),
675 .proc_handler
= proc_dointvec
,
678 .procname
= "cipso_rbm_strictvalid",
679 .data
= &cipso_v4_rbm_strictvalid
,
680 .maxlen
= sizeof(int),
682 .proc_handler
= proc_dointvec
,
684 #endif /* CONFIG_NETLABEL */
686 .procname
= "tcp_available_congestion_control",
687 .maxlen
= TCP_CA_BUF_MAX
,
689 .proc_handler
= proc_tcp_available_congestion_control
,
692 .procname
= "tcp_allowed_congestion_control",
693 .maxlen
= TCP_CA_BUF_MAX
,
695 .proc_handler
= proc_allowed_congestion_control
,
698 .procname
= "tcp_thin_linear_timeouts",
699 .data
= &sysctl_tcp_thin_linear_timeouts
,
700 .maxlen
= sizeof(int),
702 .proc_handler
= proc_dointvec
705 .procname
= "tcp_thin_dupack",
706 .data
= &sysctl_tcp_thin_dupack
,
707 .maxlen
= sizeof(int),
709 .proc_handler
= proc_dointvec
712 .procname
= "tcp_early_retrans",
713 .data
= &sysctl_tcp_early_retrans
,
714 .maxlen
= sizeof(int),
716 .proc_handler
= proc_dointvec_minmax
,
721 .procname
= "tcp_min_tso_segs",
722 .data
= &sysctl_tcp_min_tso_segs
,
723 .maxlen
= sizeof(int),
725 .proc_handler
= proc_dointvec_minmax
,
727 .extra2
= &gso_max_segs
,
730 .procname
= "tcp_pacing_ss_ratio",
731 .data
= &sysctl_tcp_pacing_ss_ratio
,
732 .maxlen
= sizeof(int),
734 .proc_handler
= proc_dointvec_minmax
,
739 .procname
= "tcp_pacing_ca_ratio",
740 .data
= &sysctl_tcp_pacing_ca_ratio
,
741 .maxlen
= sizeof(int),
743 .proc_handler
= proc_dointvec_minmax
,
748 .procname
= "tcp_autocorking",
749 .data
= &sysctl_tcp_autocorking
,
750 .maxlen
= sizeof(int),
752 .proc_handler
= proc_dointvec_minmax
,
757 .procname
= "tcp_invalid_ratelimit",
758 .data
= &sysctl_tcp_invalid_ratelimit
,
759 .maxlen
= sizeof(int),
761 .proc_handler
= proc_dointvec_ms_jiffies
,
764 .procname
= "icmp_msgs_per_sec",
765 .data
= &sysctl_icmp_msgs_per_sec
,
766 .maxlen
= sizeof(int),
768 .proc_handler
= proc_dointvec_minmax
,
772 .procname
= "icmp_msgs_burst",
773 .data
= &sysctl_icmp_msgs_burst
,
774 .maxlen
= sizeof(int),
776 .proc_handler
= proc_dointvec_minmax
,
780 .procname
= "udp_mem",
781 .data
= &sysctl_udp_mem
,
782 .maxlen
= sizeof(sysctl_udp_mem
),
784 .proc_handler
= proc_doulongvec_minmax
,
787 .procname
= "udp_rmem_min",
788 .data
= &sysctl_udp_rmem_min
,
789 .maxlen
= sizeof(sysctl_udp_rmem_min
),
791 .proc_handler
= proc_dointvec_minmax
,
795 .procname
= "udp_wmem_min",
796 .data
= &sysctl_udp_wmem_min
,
797 .maxlen
= sizeof(sysctl_udp_wmem_min
),
799 .proc_handler
= proc_dointvec_minmax
,
805 static struct ctl_table ipv4_net_table
[] = {
807 .procname
= "icmp_echo_ignore_all",
808 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_all
,
809 .maxlen
= sizeof(int),
811 .proc_handler
= proc_dointvec
814 .procname
= "icmp_echo_ignore_broadcasts",
815 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_broadcasts
,
816 .maxlen
= sizeof(int),
818 .proc_handler
= proc_dointvec
821 .procname
= "icmp_ignore_bogus_error_responses",
822 .data
= &init_net
.ipv4
.sysctl_icmp_ignore_bogus_error_responses
,
823 .maxlen
= sizeof(int),
825 .proc_handler
= proc_dointvec
828 .procname
= "icmp_errors_use_inbound_ifaddr",
829 .data
= &init_net
.ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
,
830 .maxlen
= sizeof(int),
832 .proc_handler
= proc_dointvec
835 .procname
= "icmp_ratelimit",
836 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
837 .maxlen
= sizeof(int),
839 .proc_handler
= proc_dointvec_ms_jiffies
,
842 .procname
= "icmp_ratemask",
843 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
844 .maxlen
= sizeof(int),
846 .proc_handler
= proc_dointvec
849 .procname
= "ping_group_range",
850 .data
= &init_net
.ipv4
.ping_group_range
.range
,
851 .maxlen
= sizeof(gid_t
)*2,
853 .proc_handler
= ipv4_ping_group_range
,
856 .procname
= "tcp_ecn",
857 .data
= &init_net
.ipv4
.sysctl_tcp_ecn
,
858 .maxlen
= sizeof(int),
860 .proc_handler
= proc_dointvec
863 .procname
= "tcp_ecn_fallback",
864 .data
= &init_net
.ipv4
.sysctl_tcp_ecn_fallback
,
865 .maxlen
= sizeof(int),
867 .proc_handler
= proc_dointvec
870 .procname
= "ip_local_port_range",
871 .maxlen
= sizeof(init_net
.ipv4
.ip_local_ports
.range
),
872 .data
= &init_net
.ipv4
.ip_local_ports
.range
,
874 .proc_handler
= ipv4_local_port_range
,
877 .procname
= "ip_local_reserved_ports",
878 .data
= &init_net
.ipv4
.sysctl_local_reserved_ports
,
881 .proc_handler
= proc_do_large_bitmap
,
884 .procname
= "ip_no_pmtu_disc",
885 .data
= &init_net
.ipv4
.sysctl_ip_no_pmtu_disc
,
886 .maxlen
= sizeof(int),
888 .proc_handler
= proc_dointvec
891 .procname
= "ip_forward_use_pmtu",
892 .data
= &init_net
.ipv4
.sysctl_ip_fwd_use_pmtu
,
893 .maxlen
= sizeof(int),
895 .proc_handler
= proc_dointvec
,
898 .procname
= "ip_nonlocal_bind",
899 .data
= &init_net
.ipv4
.sysctl_ip_nonlocal_bind
,
900 .maxlen
= sizeof(int),
902 .proc_handler
= proc_dointvec
905 .procname
= "fwmark_reflect",
906 .data
= &init_net
.ipv4
.sysctl_fwmark_reflect
,
907 .maxlen
= sizeof(int),
909 .proc_handler
= proc_dointvec
,
912 .procname
= "tcp_fwmark_accept",
913 .data
= &init_net
.ipv4
.sysctl_tcp_fwmark_accept
,
914 .maxlen
= sizeof(int),
916 .proc_handler
= proc_dointvec
,
919 .procname
= "tcp_mtu_probing",
920 .data
= &init_net
.ipv4
.sysctl_tcp_mtu_probing
,
921 .maxlen
= sizeof(int),
923 .proc_handler
= proc_dointvec
,
926 .procname
= "tcp_base_mss",
927 .data
= &init_net
.ipv4
.sysctl_tcp_base_mss
,
928 .maxlen
= sizeof(int),
930 .proc_handler
= proc_dointvec
,
933 .procname
= "tcp_probe_threshold",
934 .data
= &init_net
.ipv4
.sysctl_tcp_probe_threshold
,
935 .maxlen
= sizeof(int),
937 .proc_handler
= proc_dointvec
,
940 .procname
= "tcp_probe_interval",
941 .data
= &init_net
.ipv4
.sysctl_tcp_probe_interval
,
942 .maxlen
= sizeof(int),
944 .proc_handler
= proc_dointvec
,
947 .procname
= "igmp_link_local_mcast_reports",
948 .data
= &sysctl_igmp_llm_reports
,
949 .maxlen
= sizeof(int),
951 .proc_handler
= proc_dointvec
956 static __net_init
int ipv4_sysctl_init_net(struct net
*net
)
958 struct ctl_table
*table
;
960 table
= ipv4_net_table
;
961 if (!net_eq(net
, &init_net
)) {
964 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
968 /* Update the variables to point into the current struct net */
969 for (i
= 0; i
< ARRAY_SIZE(ipv4_net_table
) - 1; i
++)
970 table
[i
].data
+= (void *)net
- (void *)&init_net
;
973 net
->ipv4
.ipv4_hdr
= register_net_sysctl(net
, "net/ipv4", table
);
974 if (!net
->ipv4
.ipv4_hdr
)
977 net
->ipv4
.sysctl_local_reserved_ports
= kzalloc(65536 / 8, GFP_KERNEL
);
978 if (!net
->ipv4
.sysctl_local_reserved_ports
)
984 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
986 if (!net_eq(net
, &init_net
))
992 static __net_exit
void ipv4_sysctl_exit_net(struct net
*net
)
994 struct ctl_table
*table
;
996 kfree(net
->ipv4
.sysctl_local_reserved_ports
);
997 table
= net
->ipv4
.ipv4_hdr
->ctl_table_arg
;
998 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
1002 static __net_initdata
struct pernet_operations ipv4_sysctl_ops
= {
1003 .init
= ipv4_sysctl_init_net
,
1004 .exit
= ipv4_sysctl_exit_net
,
1007 static __init
int sysctl_ipv4_init(void)
1009 struct ctl_table_header
*hdr
;
1011 hdr
= register_net_sysctl(&init_net
, "net/ipv4", ipv4_table
);
1015 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
1016 unregister_net_sysctl_table(hdr
);
1023 __initcall(sysctl_ipv4_init
);