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 gso_max_segs
= GSO_MAX_SEGS
;
33 static int tcp_retr1_max
= 255;
34 static int ip_local_port_range_min
[] = { 1, 1 };
35 static int ip_local_port_range_max
[] = { 65535, 65535 };
36 static int tcp_adv_win_scale_min
= -31;
37 static int tcp_adv_win_scale_max
= 31;
38 static int ip_ttl_min
= 1;
39 static int ip_ttl_max
= 255;
40 static int tcp_syn_retries_min
= 1;
41 static int tcp_syn_retries_max
= MAX_TCP_SYNCNT
;
42 static int ip_ping_group_range_min
[] = { 0, 0 };
43 static int ip_ping_group_range_max
[] = { GID_T_MAX
, GID_T_MAX
};
45 /* Update system visible IP port range */
46 static void set_local_port_range(struct net
*net
, int range
[2])
48 write_seqlock(&net
->ipv4
.ip_local_ports
.lock
);
49 net
->ipv4
.ip_local_ports
.range
[0] = range
[0];
50 net
->ipv4
.ip_local_ports
.range
[1] = range
[1];
51 write_sequnlock(&net
->ipv4
.ip_local_ports
.lock
);
54 /* Validate changes from /proc interface. */
55 static int ipv4_local_port_range(struct ctl_table
*table
, int write
,
57 size_t *lenp
, loff_t
*ppos
)
60 container_of(table
->data
, struct net
, ipv4
.ip_local_ports
.range
);
63 struct ctl_table tmp
= {
65 .maxlen
= sizeof(range
),
67 .extra1
= &ip_local_port_range_min
,
68 .extra2
= &ip_local_port_range_max
,
71 inet_get_local_port_range(net
, &range
[0], &range
[1]);
73 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
75 if (write
&& ret
== 0) {
76 if (range
[1] < range
[0])
79 set_local_port_range(net
, range
);
86 static void inet_get_ping_group_range_table(struct ctl_table
*table
, kgid_t
*low
, kgid_t
*high
)
88 kgid_t
*data
= table
->data
;
90 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
93 seq
= read_seqbegin(&net
->ipv4
.ip_local_ports
.lock
);
97 } while (read_seqretry(&net
->ipv4
.ip_local_ports
.lock
, seq
));
100 /* Update system visible IP port range */
101 static void set_ping_group_range(struct ctl_table
*table
, kgid_t low
, kgid_t high
)
103 kgid_t
*data
= table
->data
;
105 container_of(table
->data
, struct net
, ipv4
.ping_group_range
.range
);
106 write_seqlock(&net
->ipv4
.ip_local_ports
.lock
);
109 write_sequnlock(&net
->ipv4
.ip_local_ports
.lock
);
112 /* Validate changes from /proc interface. */
113 static int ipv4_ping_group_range(struct ctl_table
*table
, int write
,
115 size_t *lenp
, loff_t
*ppos
)
117 struct user_namespace
*user_ns
= current_user_ns();
121 struct ctl_table tmp
= {
123 .maxlen
= sizeof(urange
),
125 .extra1
= &ip_ping_group_range_min
,
126 .extra2
= &ip_ping_group_range_max
,
129 inet_get_ping_group_range_table(table
, &low
, &high
);
130 urange
[0] = from_kgid_munged(user_ns
, low
);
131 urange
[1] = from_kgid_munged(user_ns
, high
);
132 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
134 if (write
&& ret
== 0) {
135 low
= make_kgid(user_ns
, urange
[0]);
136 high
= make_kgid(user_ns
, urange
[1]);
137 if (!gid_valid(low
) || !gid_valid(high
) ||
138 (urange
[1] < urange
[0]) || gid_lt(high
, low
)) {
139 low
= make_kgid(&init_user_ns
, 1);
140 high
= make_kgid(&init_user_ns
, 0);
142 set_ping_group_range(table
, low
, high
);
148 static int proc_tcp_congestion_control(struct ctl_table
*ctl
, int write
,
149 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
151 char val
[TCP_CA_NAME_MAX
];
152 struct ctl_table tbl
= {
154 .maxlen
= TCP_CA_NAME_MAX
,
158 tcp_get_default_congestion_control(val
);
160 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
161 if (write
&& ret
== 0)
162 ret
= tcp_set_default_congestion_control(val
);
166 static int proc_tcp_available_congestion_control(struct ctl_table
*ctl
,
168 void __user
*buffer
, size_t *lenp
,
171 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
174 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
177 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
178 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
183 static int proc_allowed_congestion_control(struct ctl_table
*ctl
,
185 void __user
*buffer
, size_t *lenp
,
188 struct ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
191 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
195 tcp_get_allowed_congestion_control(tbl
.data
, tbl
.maxlen
);
196 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
197 if (write
&& ret
== 0)
198 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
203 static int proc_tcp_fastopen_key(struct ctl_table
*ctl
, int write
,
204 void __user
*buffer
, size_t *lenp
,
207 struct ctl_table tbl
= { .maxlen
= (TCP_FASTOPEN_KEY_LENGTH
* 2 + 10) };
208 struct tcp_fastopen_context
*ctxt
;
210 u32 user_key
[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
212 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_KERNEL
);
217 ctxt
= rcu_dereference(tcp_fastopen_ctx
);
219 memcpy(user_key
, ctxt
->key
, TCP_FASTOPEN_KEY_LENGTH
);
221 memset(user_key
, 0, sizeof(user_key
));
224 snprintf(tbl
.data
, tbl
.maxlen
, "%08x-%08x-%08x-%08x",
225 user_key
[0], user_key
[1], user_key
[2], user_key
[3]);
226 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
228 if (write
&& ret
== 0) {
229 if (sscanf(tbl
.data
, "%x-%x-%x-%x", user_key
, user_key
+ 1,
230 user_key
+ 2, user_key
+ 3) != 4) {
234 /* Generate a dummy secret but don't publish it. This
235 * is needed so we don't regenerate a new key on the
236 * first invocation of tcp_fastopen_cookie_gen
238 tcp_fastopen_init_key_once(false);
239 tcp_fastopen_reset_cipher(user_key
, TCP_FASTOPEN_KEY_LENGTH
);
243 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
244 user_key
[0], user_key
[1], user_key
[2], user_key
[3],
245 (char *)tbl
.data
, ret
);
250 static struct ctl_table ipv4_table
[] = {
252 .procname
= "tcp_timestamps",
253 .data
= &sysctl_tcp_timestamps
,
254 .maxlen
= sizeof(int),
256 .proc_handler
= proc_dointvec
259 .procname
= "tcp_window_scaling",
260 .data
= &sysctl_tcp_window_scaling
,
261 .maxlen
= sizeof(int),
263 .proc_handler
= proc_dointvec
266 .procname
= "tcp_sack",
267 .data
= &sysctl_tcp_sack
,
268 .maxlen
= sizeof(int),
270 .proc_handler
= proc_dointvec
273 .procname
= "tcp_retrans_collapse",
274 .data
= &sysctl_tcp_retrans_collapse
,
275 .maxlen
= sizeof(int),
277 .proc_handler
= proc_dointvec
280 .procname
= "ip_default_ttl",
281 .data
= &sysctl_ip_default_ttl
,
282 .maxlen
= sizeof(int),
284 .proc_handler
= proc_dointvec_minmax
,
285 .extra1
= &ip_ttl_min
,
286 .extra2
= &ip_ttl_max
,
289 .procname
= "ip_nonlocal_bind",
290 .data
= &sysctl_ip_nonlocal_bind
,
291 .maxlen
= sizeof(int),
293 .proc_handler
= proc_dointvec
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
454 .procname
= "inet_peer_threshold",
455 .data
= &inet_peer_threshold
,
456 .maxlen
= sizeof(int),
458 .proc_handler
= proc_dointvec
461 .procname
= "inet_peer_minttl",
462 .data
= &inet_peer_minttl
,
463 .maxlen
= sizeof(int),
465 .proc_handler
= proc_dointvec_jiffies
,
468 .procname
= "inet_peer_maxttl",
469 .data
= &inet_peer_maxttl
,
470 .maxlen
= sizeof(int),
472 .proc_handler
= proc_dointvec_jiffies
,
475 .procname
= "tcp_orphan_retries",
476 .data
= &sysctl_tcp_orphan_retries
,
477 .maxlen
= sizeof(int),
479 .proc_handler
= proc_dointvec
482 .procname
= "tcp_fack",
483 .data
= &sysctl_tcp_fack
,
484 .maxlen
= sizeof(int),
486 .proc_handler
= proc_dointvec
489 .procname
= "tcp_reordering",
490 .data
= &sysctl_tcp_reordering
,
491 .maxlen
= sizeof(int),
493 .proc_handler
= proc_dointvec
496 .procname
= "tcp_dsack",
497 .data
= &sysctl_tcp_dsack
,
498 .maxlen
= sizeof(int),
500 .proc_handler
= proc_dointvec
503 .procname
= "tcp_mem",
504 .maxlen
= sizeof(sysctl_tcp_mem
),
505 .data
= &sysctl_tcp_mem
,
507 .proc_handler
= proc_doulongvec_minmax
,
510 .procname
= "tcp_wmem",
511 .data
= &sysctl_tcp_wmem
,
512 .maxlen
= sizeof(sysctl_tcp_wmem
),
514 .proc_handler
= proc_dointvec_minmax
,
518 .procname
= "tcp_notsent_lowat",
519 .data
= &sysctl_tcp_notsent_lowat
,
520 .maxlen
= sizeof(sysctl_tcp_notsent_lowat
),
522 .proc_handler
= proc_dointvec
,
525 .procname
= "tcp_rmem",
526 .data
= &sysctl_tcp_rmem
,
527 .maxlen
= sizeof(sysctl_tcp_rmem
),
529 .proc_handler
= proc_dointvec_minmax
,
533 .procname
= "tcp_app_win",
534 .data
= &sysctl_tcp_app_win
,
535 .maxlen
= sizeof(int),
537 .proc_handler
= proc_dointvec
540 .procname
= "tcp_adv_win_scale",
541 .data
= &sysctl_tcp_adv_win_scale
,
542 .maxlen
= sizeof(int),
544 .proc_handler
= proc_dointvec_minmax
,
545 .extra1
= &tcp_adv_win_scale_min
,
546 .extra2
= &tcp_adv_win_scale_max
,
549 .procname
= "tcp_tw_reuse",
550 .data
= &sysctl_tcp_tw_reuse
,
551 .maxlen
= sizeof(int),
553 .proc_handler
= proc_dointvec
556 .procname
= "tcp_frto",
557 .data
= &sysctl_tcp_frto
,
558 .maxlen
= sizeof(int),
560 .proc_handler
= proc_dointvec
563 .procname
= "tcp_low_latency",
564 .data
= &sysctl_tcp_low_latency
,
565 .maxlen
= sizeof(int),
567 .proc_handler
= proc_dointvec
570 .procname
= "tcp_no_metrics_save",
571 .data
= &sysctl_tcp_nometrics_save
,
572 .maxlen
= sizeof(int),
574 .proc_handler
= proc_dointvec
,
577 .procname
= "tcp_moderate_rcvbuf",
578 .data
= &sysctl_tcp_moderate_rcvbuf
,
579 .maxlen
= sizeof(int),
581 .proc_handler
= proc_dointvec
,
584 .procname
= "tcp_tso_win_divisor",
585 .data
= &sysctl_tcp_tso_win_divisor
,
586 .maxlen
= sizeof(int),
588 .proc_handler
= proc_dointvec
,
591 .procname
= "tcp_congestion_control",
593 .maxlen
= TCP_CA_NAME_MAX
,
594 .proc_handler
= proc_tcp_congestion_control
,
597 .procname
= "tcp_mtu_probing",
598 .data
= &sysctl_tcp_mtu_probing
,
599 .maxlen
= sizeof(int),
601 .proc_handler
= proc_dointvec
,
604 .procname
= "tcp_base_mss",
605 .data
= &sysctl_tcp_base_mss
,
606 .maxlen
= sizeof(int),
608 .proc_handler
= proc_dointvec
,
611 .procname
= "tcp_workaround_signed_windows",
612 .data
= &sysctl_tcp_workaround_signed_windows
,
613 .maxlen
= sizeof(int),
615 .proc_handler
= proc_dointvec
618 .procname
= "tcp_limit_output_bytes",
619 .data
= &sysctl_tcp_limit_output_bytes
,
620 .maxlen
= sizeof(int),
622 .proc_handler
= proc_dointvec
625 .procname
= "tcp_challenge_ack_limit",
626 .data
= &sysctl_tcp_challenge_ack_limit
,
627 .maxlen
= sizeof(int),
629 .proc_handler
= proc_dointvec
631 #ifdef CONFIG_NET_DMA
633 .procname
= "tcp_dma_copybreak",
634 .data
= &sysctl_tcp_dma_copybreak
,
635 .maxlen
= sizeof(int),
637 .proc_handler
= proc_dointvec
641 .procname
= "tcp_slow_start_after_idle",
642 .data
= &sysctl_tcp_slow_start_after_idle
,
643 .maxlen
= sizeof(int),
645 .proc_handler
= proc_dointvec
647 #ifdef CONFIG_NETLABEL
649 .procname
= "cipso_cache_enable",
650 .data
= &cipso_v4_cache_enabled
,
651 .maxlen
= sizeof(int),
653 .proc_handler
= proc_dointvec
,
656 .procname
= "cipso_cache_bucket_size",
657 .data
= &cipso_v4_cache_bucketsize
,
658 .maxlen
= sizeof(int),
660 .proc_handler
= proc_dointvec
,
663 .procname
= "cipso_rbm_optfmt",
664 .data
= &cipso_v4_rbm_optfmt
,
665 .maxlen
= sizeof(int),
667 .proc_handler
= proc_dointvec
,
670 .procname
= "cipso_rbm_strictvalid",
671 .data
= &cipso_v4_rbm_strictvalid
,
672 .maxlen
= sizeof(int),
674 .proc_handler
= proc_dointvec
,
676 #endif /* CONFIG_NETLABEL */
678 .procname
= "tcp_available_congestion_control",
679 .maxlen
= TCP_CA_BUF_MAX
,
681 .proc_handler
= proc_tcp_available_congestion_control
,
684 .procname
= "tcp_allowed_congestion_control",
685 .maxlen
= TCP_CA_BUF_MAX
,
687 .proc_handler
= proc_allowed_congestion_control
,
690 .procname
= "tcp_thin_linear_timeouts",
691 .data
= &sysctl_tcp_thin_linear_timeouts
,
692 .maxlen
= sizeof(int),
694 .proc_handler
= proc_dointvec
697 .procname
= "tcp_thin_dupack",
698 .data
= &sysctl_tcp_thin_dupack
,
699 .maxlen
= sizeof(int),
701 .proc_handler
= proc_dointvec
704 .procname
= "tcp_early_retrans",
705 .data
= &sysctl_tcp_early_retrans
,
706 .maxlen
= sizeof(int),
708 .proc_handler
= proc_dointvec_minmax
,
713 .procname
= "tcp_min_tso_segs",
714 .data
= &sysctl_tcp_min_tso_segs
,
715 .maxlen
= sizeof(int),
717 .proc_handler
= proc_dointvec_minmax
,
719 .extra2
= &gso_max_segs
,
722 .procname
= "tcp_autocorking",
723 .data
= &sysctl_tcp_autocorking
,
724 .maxlen
= sizeof(int),
726 .proc_handler
= proc_dointvec_minmax
,
731 .procname
= "udp_mem",
732 .data
= &sysctl_udp_mem
,
733 .maxlen
= sizeof(sysctl_udp_mem
),
735 .proc_handler
= proc_doulongvec_minmax
,
738 .procname
= "udp_rmem_min",
739 .data
= &sysctl_udp_rmem_min
,
740 .maxlen
= sizeof(sysctl_udp_rmem_min
),
742 .proc_handler
= proc_dointvec_minmax
,
746 .procname
= "udp_wmem_min",
747 .data
= &sysctl_udp_wmem_min
,
748 .maxlen
= sizeof(sysctl_udp_wmem_min
),
750 .proc_handler
= proc_dointvec_minmax
,
756 static struct ctl_table ipv4_net_table
[] = {
758 .procname
= "icmp_echo_ignore_all",
759 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_all
,
760 .maxlen
= sizeof(int),
762 .proc_handler
= proc_dointvec
765 .procname
= "icmp_echo_ignore_broadcasts",
766 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_broadcasts
,
767 .maxlen
= sizeof(int),
769 .proc_handler
= proc_dointvec
772 .procname
= "icmp_ignore_bogus_error_responses",
773 .data
= &init_net
.ipv4
.sysctl_icmp_ignore_bogus_error_responses
,
774 .maxlen
= sizeof(int),
776 .proc_handler
= proc_dointvec
779 .procname
= "icmp_errors_use_inbound_ifaddr",
780 .data
= &init_net
.ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
,
781 .maxlen
= sizeof(int),
783 .proc_handler
= proc_dointvec
786 .procname
= "icmp_ratelimit",
787 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
788 .maxlen
= sizeof(int),
790 .proc_handler
= proc_dointvec_ms_jiffies
,
793 .procname
= "icmp_ratemask",
794 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
795 .maxlen
= sizeof(int),
797 .proc_handler
= proc_dointvec
800 .procname
= "ping_group_range",
801 .data
= &init_net
.ipv4
.ping_group_range
.range
,
802 .maxlen
= sizeof(gid_t
)*2,
804 .proc_handler
= ipv4_ping_group_range
,
807 .procname
= "tcp_ecn",
808 .data
= &init_net
.ipv4
.sysctl_tcp_ecn
,
809 .maxlen
= sizeof(int),
811 .proc_handler
= proc_dointvec
814 .procname
= "ip_local_port_range",
815 .maxlen
= sizeof(init_net
.ipv4
.ip_local_ports
.range
),
816 .data
= &init_net
.ipv4
.ip_local_ports
.range
,
818 .proc_handler
= ipv4_local_port_range
,
821 .procname
= "ip_local_reserved_ports",
822 .data
= &init_net
.ipv4
.sysctl_local_reserved_ports
,
825 .proc_handler
= proc_do_large_bitmap
,
828 .procname
= "ip_no_pmtu_disc",
829 .data
= &init_net
.ipv4
.sysctl_ip_no_pmtu_disc
,
830 .maxlen
= sizeof(int),
832 .proc_handler
= proc_dointvec
835 .procname
= "ip_forward_use_pmtu",
836 .data
= &init_net
.ipv4
.sysctl_ip_fwd_use_pmtu
,
837 .maxlen
= sizeof(int),
839 .proc_handler
= proc_dointvec
,
842 .procname
= "fwmark_reflect",
843 .data
= &init_net
.ipv4
.sysctl_fwmark_reflect
,
844 .maxlen
= sizeof(int),
846 .proc_handler
= proc_dointvec
,
849 .procname
= "tcp_fwmark_accept",
850 .data
= &init_net
.ipv4
.sysctl_tcp_fwmark_accept
,
851 .maxlen
= sizeof(int),
853 .proc_handler
= proc_dointvec
,
858 static __net_init
int ipv4_sysctl_init_net(struct net
*net
)
860 struct ctl_table
*table
;
862 table
= ipv4_net_table
;
863 if (!net_eq(net
, &init_net
)) {
866 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
870 /* Update the variables to point into the current struct net */
871 for (i
= 0; i
< ARRAY_SIZE(ipv4_net_table
) - 1; i
++)
872 table
[i
].data
+= (void *)net
- (void *)&init_net
;
875 net
->ipv4
.ipv4_hdr
= register_net_sysctl(net
, "net/ipv4", table
);
876 if (net
->ipv4
.ipv4_hdr
== NULL
)
879 net
->ipv4
.sysctl_local_reserved_ports
= kzalloc(65536 / 8, GFP_KERNEL
);
880 if (!net
->ipv4
.sysctl_local_reserved_ports
)
886 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
888 if (!net_eq(net
, &init_net
))
894 static __net_exit
void ipv4_sysctl_exit_net(struct net
*net
)
896 struct ctl_table
*table
;
898 kfree(net
->ipv4
.sysctl_local_reserved_ports
);
899 table
= net
->ipv4
.ipv4_hdr
->ctl_table_arg
;
900 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
904 static __net_initdata
struct pernet_operations ipv4_sysctl_ops
= {
905 .init
= ipv4_sysctl_init_net
,
906 .exit
= ipv4_sysctl_exit_net
,
909 static __init
int sysctl_ipv4_init(void)
911 struct ctl_table_header
*hdr
;
913 hdr
= register_net_sysctl(&init_net
, "net/ipv4", ipv4_table
);
917 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
918 unregister_net_sysctl_table(hdr
);
925 __initcall(sysctl_ipv4_init
);