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>
18 #include <net/route.h>
21 #include <net/cipso_ipv4.h>
22 #include <net/inet_frag.h>
25 static int tcp_retr1_max
= 255;
26 static int ip_local_port_range_min
[] = { 1, 1 };
27 static int ip_local_port_range_max
[] = { 65535, 65535 };
29 /* Update system visible IP port range */
30 static void set_local_port_range(int range
[2])
32 write_seqlock(&sysctl_local_ports
.lock
);
33 sysctl_local_ports
.range
[0] = range
[0];
34 sysctl_local_ports
.range
[1] = range
[1];
35 write_sequnlock(&sysctl_local_ports
.lock
);
38 /* Validate changes from /proc interface. */
39 static int ipv4_local_port_range(ctl_table
*table
, int write
, struct file
*filp
,
41 size_t *lenp
, loff_t
*ppos
)
47 .maxlen
= sizeof(range
),
49 .extra1
= &ip_local_port_range_min
,
50 .extra2
= &ip_local_port_range_max
,
53 inet_get_local_port_range(range
, range
+ 1);
54 ret
= proc_dointvec_minmax(&tmp
, write
, filp
, buffer
, lenp
, ppos
);
56 if (write
&& ret
== 0) {
57 if (range
[1] < range
[0])
60 set_local_port_range(range
);
66 /* Validate changes from sysctl interface. */
67 static int ipv4_sysctl_local_port_range(ctl_table
*table
,
69 size_t __user
*oldlenp
,
70 void __user
*newval
, size_t newlen
)
76 .maxlen
= sizeof(range
),
78 .extra1
= &ip_local_port_range_min
,
79 .extra2
= &ip_local_port_range_max
,
82 inet_get_local_port_range(range
, range
+ 1);
83 ret
= sysctl_intvec(&tmp
, oldval
, oldlenp
, newval
, newlen
);
84 if (ret
== 0 && newval
&& newlen
) {
85 if (range
[1] < range
[0])
88 set_local_port_range(range
);
94 static int proc_tcp_congestion_control(ctl_table
*ctl
, int write
, struct file
* filp
,
95 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
97 char val
[TCP_CA_NAME_MAX
];
100 .maxlen
= TCP_CA_NAME_MAX
,
104 tcp_get_default_congestion_control(val
);
106 ret
= proc_dostring(&tbl
, write
, filp
, buffer
, lenp
, ppos
);
107 if (write
&& ret
== 0)
108 ret
= tcp_set_default_congestion_control(val
);
112 static int sysctl_tcp_congestion_control(ctl_table
*table
,
114 size_t __user
*oldlenp
,
115 void __user
*newval
, size_t newlen
)
117 char val
[TCP_CA_NAME_MAX
];
120 .maxlen
= TCP_CA_NAME_MAX
,
124 tcp_get_default_congestion_control(val
);
125 ret
= sysctl_string(&tbl
, oldval
, oldlenp
, newval
, newlen
);
126 if (ret
== 1 && newval
&& newlen
)
127 ret
= tcp_set_default_congestion_control(val
);
131 static int proc_tcp_available_congestion_control(ctl_table
*ctl
,
132 int write
, struct file
* filp
,
133 void __user
*buffer
, size_t *lenp
,
136 ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
, };
139 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
142 tcp_get_available_congestion_control(tbl
.data
, TCP_CA_BUF_MAX
);
143 ret
= proc_dostring(&tbl
, write
, filp
, buffer
, lenp
, ppos
);
148 static int proc_allowed_congestion_control(ctl_table
*ctl
,
149 int write
, struct file
* filp
,
150 void __user
*buffer
, size_t *lenp
,
153 ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
156 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
160 tcp_get_allowed_congestion_control(tbl
.data
, tbl
.maxlen
);
161 ret
= proc_dostring(&tbl
, write
, filp
, buffer
, lenp
, ppos
);
162 if (write
&& ret
== 0)
163 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
168 static int strategy_allowed_congestion_control(ctl_table
*table
,
170 size_t __user
*oldlenp
,
174 ctl_table tbl
= { .maxlen
= TCP_CA_BUF_MAX
};
177 tbl
.data
= kmalloc(tbl
.maxlen
, GFP_USER
);
181 tcp_get_available_congestion_control(tbl
.data
, tbl
.maxlen
);
182 ret
= sysctl_string(&tbl
, oldval
, oldlenp
, newval
, newlen
);
183 if (ret
== 1 && newval
&& newlen
)
184 ret
= tcp_set_allowed_congestion_control(tbl
.data
);
191 static struct ctl_table ipv4_table
[] = {
193 .ctl_name
= NET_IPV4_TCP_TIMESTAMPS
,
194 .procname
= "tcp_timestamps",
195 .data
= &sysctl_tcp_timestamps
,
196 .maxlen
= sizeof(int),
198 .proc_handler
= &proc_dointvec
201 .ctl_name
= NET_IPV4_TCP_WINDOW_SCALING
,
202 .procname
= "tcp_window_scaling",
203 .data
= &sysctl_tcp_window_scaling
,
204 .maxlen
= sizeof(int),
206 .proc_handler
= &proc_dointvec
209 .ctl_name
= NET_IPV4_TCP_SACK
,
210 .procname
= "tcp_sack",
211 .data
= &sysctl_tcp_sack
,
212 .maxlen
= sizeof(int),
214 .proc_handler
= &proc_dointvec
217 .ctl_name
= NET_IPV4_TCP_RETRANS_COLLAPSE
,
218 .procname
= "tcp_retrans_collapse",
219 .data
= &sysctl_tcp_retrans_collapse
,
220 .maxlen
= sizeof(int),
222 .proc_handler
= &proc_dointvec
225 .ctl_name
= NET_IPV4_DEFAULT_TTL
,
226 .procname
= "ip_default_ttl",
227 .data
= &sysctl_ip_default_ttl
,
228 .maxlen
= sizeof(int),
230 .proc_handler
= &ipv4_doint_and_flush
,
231 .strategy
= &ipv4_doint_and_flush_strategy
,
235 .ctl_name
= NET_IPV4_NO_PMTU_DISC
,
236 .procname
= "ip_no_pmtu_disc",
237 .data
= &ipv4_config
.no_pmtu_disc
,
238 .maxlen
= sizeof(int),
240 .proc_handler
= &proc_dointvec
243 .ctl_name
= NET_IPV4_NONLOCAL_BIND
,
244 .procname
= "ip_nonlocal_bind",
245 .data
= &sysctl_ip_nonlocal_bind
,
246 .maxlen
= sizeof(int),
248 .proc_handler
= &proc_dointvec
251 .ctl_name
= NET_IPV4_TCP_SYN_RETRIES
,
252 .procname
= "tcp_syn_retries",
253 .data
= &sysctl_tcp_syn_retries
,
254 .maxlen
= sizeof(int),
256 .proc_handler
= &proc_dointvec
259 .ctl_name
= NET_TCP_SYNACK_RETRIES
,
260 .procname
= "tcp_synack_retries",
261 .data
= &sysctl_tcp_synack_retries
,
262 .maxlen
= sizeof(int),
264 .proc_handler
= &proc_dointvec
267 .ctl_name
= NET_TCP_MAX_ORPHANS
,
268 .procname
= "tcp_max_orphans",
269 .data
= &sysctl_tcp_max_orphans
,
270 .maxlen
= sizeof(int),
272 .proc_handler
= &proc_dointvec
275 .ctl_name
= NET_TCP_MAX_TW_BUCKETS
,
276 .procname
= "tcp_max_tw_buckets",
277 .data
= &tcp_death_row
.sysctl_max_tw_buckets
,
278 .maxlen
= sizeof(int),
280 .proc_handler
= &proc_dointvec
283 .ctl_name
= NET_IPV4_DYNADDR
,
284 .procname
= "ip_dynaddr",
285 .data
= &sysctl_ip_dynaddr
,
286 .maxlen
= sizeof(int),
288 .proc_handler
= &proc_dointvec
291 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_TIME
,
292 .procname
= "tcp_keepalive_time",
293 .data
= &sysctl_tcp_keepalive_time
,
294 .maxlen
= sizeof(int),
296 .proc_handler
= &proc_dointvec_jiffies
,
297 .strategy
= &sysctl_jiffies
300 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_PROBES
,
301 .procname
= "tcp_keepalive_probes",
302 .data
= &sysctl_tcp_keepalive_probes
,
303 .maxlen
= sizeof(int),
305 .proc_handler
= &proc_dointvec
308 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_INTVL
,
309 .procname
= "tcp_keepalive_intvl",
310 .data
= &sysctl_tcp_keepalive_intvl
,
311 .maxlen
= sizeof(int),
313 .proc_handler
= &proc_dointvec_jiffies
,
314 .strategy
= &sysctl_jiffies
317 .ctl_name
= NET_IPV4_TCP_RETRIES1
,
318 .procname
= "tcp_retries1",
319 .data
= &sysctl_tcp_retries1
,
320 .maxlen
= sizeof(int),
322 .proc_handler
= &proc_dointvec_minmax
,
323 .strategy
= &sysctl_intvec
,
324 .extra2
= &tcp_retr1_max
327 .ctl_name
= NET_IPV4_TCP_RETRIES2
,
328 .procname
= "tcp_retries2",
329 .data
= &sysctl_tcp_retries2
,
330 .maxlen
= sizeof(int),
332 .proc_handler
= &proc_dointvec
335 .ctl_name
= NET_IPV4_TCP_FIN_TIMEOUT
,
336 .procname
= "tcp_fin_timeout",
337 .data
= &sysctl_tcp_fin_timeout
,
338 .maxlen
= sizeof(int),
340 .proc_handler
= &proc_dointvec_jiffies
,
341 .strategy
= &sysctl_jiffies
343 #ifdef CONFIG_SYN_COOKIES
345 .ctl_name
= NET_TCP_SYNCOOKIES
,
346 .procname
= "tcp_syncookies",
347 .data
= &sysctl_tcp_syncookies
,
348 .maxlen
= sizeof(int),
350 .proc_handler
= &proc_dointvec
354 .ctl_name
= NET_TCP_TW_RECYCLE
,
355 .procname
= "tcp_tw_recycle",
356 .data
= &tcp_death_row
.sysctl_tw_recycle
,
357 .maxlen
= sizeof(int),
359 .proc_handler
= &proc_dointvec
362 .ctl_name
= NET_TCP_ABORT_ON_OVERFLOW
,
363 .procname
= "tcp_abort_on_overflow",
364 .data
= &sysctl_tcp_abort_on_overflow
,
365 .maxlen
= sizeof(int),
367 .proc_handler
= &proc_dointvec
370 .ctl_name
= NET_TCP_STDURG
,
371 .procname
= "tcp_stdurg",
372 .data
= &sysctl_tcp_stdurg
,
373 .maxlen
= sizeof(int),
375 .proc_handler
= &proc_dointvec
378 .ctl_name
= NET_TCP_RFC1337
,
379 .procname
= "tcp_rfc1337",
380 .data
= &sysctl_tcp_rfc1337
,
381 .maxlen
= sizeof(int),
383 .proc_handler
= &proc_dointvec
386 .ctl_name
= NET_TCP_MAX_SYN_BACKLOG
,
387 .procname
= "tcp_max_syn_backlog",
388 .data
= &sysctl_max_syn_backlog
,
389 .maxlen
= sizeof(int),
391 .proc_handler
= &proc_dointvec
394 .ctl_name
= NET_IPV4_LOCAL_PORT_RANGE
,
395 .procname
= "ip_local_port_range",
396 .data
= &sysctl_local_ports
.range
,
397 .maxlen
= sizeof(sysctl_local_ports
.range
),
399 .proc_handler
= &ipv4_local_port_range
,
400 .strategy
= &ipv4_sysctl_local_port_range
,
402 #ifdef CONFIG_IP_MULTICAST
404 .ctl_name
= NET_IPV4_IGMP_MAX_MEMBERSHIPS
,
405 .procname
= "igmp_max_memberships",
406 .data
= &sysctl_igmp_max_memberships
,
407 .maxlen
= sizeof(int),
409 .proc_handler
= &proc_dointvec
414 .ctl_name
= NET_IPV4_IGMP_MAX_MSF
,
415 .procname
= "igmp_max_msf",
416 .data
= &sysctl_igmp_max_msf
,
417 .maxlen
= sizeof(int),
419 .proc_handler
= &proc_dointvec
422 .ctl_name
= NET_IPV4_INET_PEER_THRESHOLD
,
423 .procname
= "inet_peer_threshold",
424 .data
= &inet_peer_threshold
,
425 .maxlen
= sizeof(int),
427 .proc_handler
= &proc_dointvec
430 .ctl_name
= NET_IPV4_INET_PEER_MINTTL
,
431 .procname
= "inet_peer_minttl",
432 .data
= &inet_peer_minttl
,
433 .maxlen
= sizeof(int),
435 .proc_handler
= &proc_dointvec_jiffies
,
436 .strategy
= &sysctl_jiffies
439 .ctl_name
= NET_IPV4_INET_PEER_MAXTTL
,
440 .procname
= "inet_peer_maxttl",
441 .data
= &inet_peer_maxttl
,
442 .maxlen
= sizeof(int),
444 .proc_handler
= &proc_dointvec_jiffies
,
445 .strategy
= &sysctl_jiffies
448 .ctl_name
= NET_IPV4_INET_PEER_GC_MINTIME
,
449 .procname
= "inet_peer_gc_mintime",
450 .data
= &inet_peer_gc_mintime
,
451 .maxlen
= sizeof(int),
453 .proc_handler
= &proc_dointvec_jiffies
,
454 .strategy
= &sysctl_jiffies
457 .ctl_name
= NET_IPV4_INET_PEER_GC_MAXTIME
,
458 .procname
= "inet_peer_gc_maxtime",
459 .data
= &inet_peer_gc_maxtime
,
460 .maxlen
= sizeof(int),
462 .proc_handler
= &proc_dointvec_jiffies
,
463 .strategy
= &sysctl_jiffies
466 .ctl_name
= NET_TCP_ORPHAN_RETRIES
,
467 .procname
= "tcp_orphan_retries",
468 .data
= &sysctl_tcp_orphan_retries
,
469 .maxlen
= sizeof(int),
471 .proc_handler
= &proc_dointvec
474 .ctl_name
= NET_TCP_FACK
,
475 .procname
= "tcp_fack",
476 .data
= &sysctl_tcp_fack
,
477 .maxlen
= sizeof(int),
479 .proc_handler
= &proc_dointvec
482 .ctl_name
= NET_TCP_REORDERING
,
483 .procname
= "tcp_reordering",
484 .data
= &sysctl_tcp_reordering
,
485 .maxlen
= sizeof(int),
487 .proc_handler
= &proc_dointvec
490 .ctl_name
= NET_TCP_ECN
,
491 .procname
= "tcp_ecn",
492 .data
= &sysctl_tcp_ecn
,
493 .maxlen
= sizeof(int),
495 .proc_handler
= &proc_dointvec
498 .ctl_name
= NET_TCP_DSACK
,
499 .procname
= "tcp_dsack",
500 .data
= &sysctl_tcp_dsack
,
501 .maxlen
= sizeof(int),
503 .proc_handler
= &proc_dointvec
506 .ctl_name
= NET_TCP_MEM
,
507 .procname
= "tcp_mem",
508 .data
= &sysctl_tcp_mem
,
509 .maxlen
= sizeof(sysctl_tcp_mem
),
511 .proc_handler
= &proc_dointvec
514 .ctl_name
= NET_TCP_WMEM
,
515 .procname
= "tcp_wmem",
516 .data
= &sysctl_tcp_wmem
,
517 .maxlen
= sizeof(sysctl_tcp_wmem
),
519 .proc_handler
= &proc_dointvec
522 .ctl_name
= NET_TCP_RMEM
,
523 .procname
= "tcp_rmem",
524 .data
= &sysctl_tcp_rmem
,
525 .maxlen
= sizeof(sysctl_tcp_rmem
),
527 .proc_handler
= &proc_dointvec
530 .ctl_name
= NET_TCP_APP_WIN
,
531 .procname
= "tcp_app_win",
532 .data
= &sysctl_tcp_app_win
,
533 .maxlen
= sizeof(int),
535 .proc_handler
= &proc_dointvec
538 .ctl_name
= NET_TCP_ADV_WIN_SCALE
,
539 .procname
= "tcp_adv_win_scale",
540 .data
= &sysctl_tcp_adv_win_scale
,
541 .maxlen
= sizeof(int),
543 .proc_handler
= &proc_dointvec
546 .ctl_name
= NET_TCP_TW_REUSE
,
547 .procname
= "tcp_tw_reuse",
548 .data
= &sysctl_tcp_tw_reuse
,
549 .maxlen
= sizeof(int),
551 .proc_handler
= &proc_dointvec
554 .ctl_name
= NET_TCP_FRTO
,
555 .procname
= "tcp_frto",
556 .data
= &sysctl_tcp_frto
,
557 .maxlen
= sizeof(int),
559 .proc_handler
= &proc_dointvec
562 .ctl_name
= NET_TCP_FRTO_RESPONSE
,
563 .procname
= "tcp_frto_response",
564 .data
= &sysctl_tcp_frto_response
,
565 .maxlen
= sizeof(int),
567 .proc_handler
= &proc_dointvec
570 .ctl_name
= NET_TCP_LOW_LATENCY
,
571 .procname
= "tcp_low_latency",
572 .data
= &sysctl_tcp_low_latency
,
573 .maxlen
= sizeof(int),
575 .proc_handler
= &proc_dointvec
578 .ctl_name
= NET_TCP_NO_METRICS_SAVE
,
579 .procname
= "tcp_no_metrics_save",
580 .data
= &sysctl_tcp_nometrics_save
,
581 .maxlen
= sizeof(int),
583 .proc_handler
= &proc_dointvec
,
586 .ctl_name
= NET_TCP_MODERATE_RCVBUF
,
587 .procname
= "tcp_moderate_rcvbuf",
588 .data
= &sysctl_tcp_moderate_rcvbuf
,
589 .maxlen
= sizeof(int),
591 .proc_handler
= &proc_dointvec
,
594 .ctl_name
= NET_TCP_TSO_WIN_DIVISOR
,
595 .procname
= "tcp_tso_win_divisor",
596 .data
= &sysctl_tcp_tso_win_divisor
,
597 .maxlen
= sizeof(int),
599 .proc_handler
= &proc_dointvec
,
602 .ctl_name
= NET_TCP_CONG_CONTROL
,
603 .procname
= "tcp_congestion_control",
605 .maxlen
= TCP_CA_NAME_MAX
,
606 .proc_handler
= &proc_tcp_congestion_control
,
607 .strategy
= &sysctl_tcp_congestion_control
,
610 .ctl_name
= NET_TCP_ABC
,
611 .procname
= "tcp_abc",
612 .data
= &sysctl_tcp_abc
,
613 .maxlen
= sizeof(int),
615 .proc_handler
= &proc_dointvec
,
618 .ctl_name
= NET_TCP_MTU_PROBING
,
619 .procname
= "tcp_mtu_probing",
620 .data
= &sysctl_tcp_mtu_probing
,
621 .maxlen
= sizeof(int),
623 .proc_handler
= &proc_dointvec
,
626 .ctl_name
= NET_TCP_BASE_MSS
,
627 .procname
= "tcp_base_mss",
628 .data
= &sysctl_tcp_base_mss
,
629 .maxlen
= sizeof(int),
631 .proc_handler
= &proc_dointvec
,
634 .ctl_name
= NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS
,
635 .procname
= "tcp_workaround_signed_windows",
636 .data
= &sysctl_tcp_workaround_signed_windows
,
637 .maxlen
= sizeof(int),
639 .proc_handler
= &proc_dointvec
641 #ifdef CONFIG_NET_DMA
643 .ctl_name
= NET_TCP_DMA_COPYBREAK
,
644 .procname
= "tcp_dma_copybreak",
645 .data
= &sysctl_tcp_dma_copybreak
,
646 .maxlen
= sizeof(int),
648 .proc_handler
= &proc_dointvec
652 .ctl_name
= NET_TCP_SLOW_START_AFTER_IDLE
,
653 .procname
= "tcp_slow_start_after_idle",
654 .data
= &sysctl_tcp_slow_start_after_idle
,
655 .maxlen
= sizeof(int),
657 .proc_handler
= &proc_dointvec
659 #ifdef CONFIG_NETLABEL
661 .ctl_name
= NET_CIPSOV4_CACHE_ENABLE
,
662 .procname
= "cipso_cache_enable",
663 .data
= &cipso_v4_cache_enabled
,
664 .maxlen
= sizeof(int),
666 .proc_handler
= &proc_dointvec
,
669 .ctl_name
= NET_CIPSOV4_CACHE_BUCKET_SIZE
,
670 .procname
= "cipso_cache_bucket_size",
671 .data
= &cipso_v4_cache_bucketsize
,
672 .maxlen
= sizeof(int),
674 .proc_handler
= &proc_dointvec
,
677 .ctl_name
= NET_CIPSOV4_RBM_OPTFMT
,
678 .procname
= "cipso_rbm_optfmt",
679 .data
= &cipso_v4_rbm_optfmt
,
680 .maxlen
= sizeof(int),
682 .proc_handler
= &proc_dointvec
,
685 .ctl_name
= NET_CIPSOV4_RBM_STRICTVALID
,
686 .procname
= "cipso_rbm_strictvalid",
687 .data
= &cipso_v4_rbm_strictvalid
,
688 .maxlen
= sizeof(int),
690 .proc_handler
= &proc_dointvec
,
692 #endif /* CONFIG_NETLABEL */
694 .procname
= "tcp_available_congestion_control",
695 .maxlen
= TCP_CA_BUF_MAX
,
697 .proc_handler
= &proc_tcp_available_congestion_control
,
700 .ctl_name
= NET_TCP_ALLOWED_CONG_CONTROL
,
701 .procname
= "tcp_allowed_congestion_control",
702 .maxlen
= TCP_CA_BUF_MAX
,
704 .proc_handler
= &proc_allowed_congestion_control
,
705 .strategy
= &strategy_allowed_congestion_control
,
708 .ctl_name
= NET_TCP_MAX_SSTHRESH
,
709 .procname
= "tcp_max_ssthresh",
710 .data
= &sysctl_tcp_max_ssthresh
,
711 .maxlen
= sizeof(int),
713 .proc_handler
= &proc_dointvec
,
716 .ctl_name
= CTL_UNNUMBERED
,
717 .procname
= "udp_mem",
718 .data
= &sysctl_udp_mem
,
719 .maxlen
= sizeof(sysctl_udp_mem
),
721 .proc_handler
= &proc_dointvec_minmax
,
722 .strategy
= &sysctl_intvec
,
726 .ctl_name
= CTL_UNNUMBERED
,
727 .procname
= "udp_rmem_min",
728 .data
= &sysctl_udp_rmem_min
,
729 .maxlen
= sizeof(sysctl_udp_rmem_min
),
731 .proc_handler
= &proc_dointvec_minmax
,
732 .strategy
= &sysctl_intvec
,
736 .ctl_name
= CTL_UNNUMBERED
,
737 .procname
= "udp_wmem_min",
738 .data
= &sysctl_udp_wmem_min
,
739 .maxlen
= sizeof(sysctl_udp_wmem_min
),
741 .proc_handler
= &proc_dointvec_minmax
,
742 .strategy
= &sysctl_intvec
,
748 static struct ctl_table ipv4_net_table
[] = {
750 .ctl_name
= NET_IPV4_ICMP_ECHO_IGNORE_ALL
,
751 .procname
= "icmp_echo_ignore_all",
752 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_all
,
753 .maxlen
= sizeof(int),
755 .proc_handler
= &proc_dointvec
758 .ctl_name
= NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS
,
759 .procname
= "icmp_echo_ignore_broadcasts",
760 .data
= &init_net
.ipv4
.sysctl_icmp_echo_ignore_broadcasts
,
761 .maxlen
= sizeof(int),
763 .proc_handler
= &proc_dointvec
766 .ctl_name
= NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES
,
767 .procname
= "icmp_ignore_bogus_error_responses",
768 .data
= &init_net
.ipv4
.sysctl_icmp_ignore_bogus_error_responses
,
769 .maxlen
= sizeof(int),
771 .proc_handler
= &proc_dointvec
774 .ctl_name
= NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR
,
775 .procname
= "icmp_errors_use_inbound_ifaddr",
776 .data
= &init_net
.ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
,
777 .maxlen
= sizeof(int),
779 .proc_handler
= &proc_dointvec
782 .ctl_name
= NET_IPV4_ICMP_RATELIMIT
,
783 .procname
= "icmp_ratelimit",
784 .data
= &init_net
.ipv4
.sysctl_icmp_ratelimit
,
785 .maxlen
= sizeof(int),
787 .proc_handler
= &proc_dointvec_ms_jiffies
,
788 .strategy
= &sysctl_ms_jiffies
791 .ctl_name
= NET_IPV4_ICMP_RATEMASK
,
792 .procname
= "icmp_ratemask",
793 .data
= &init_net
.ipv4
.sysctl_icmp_ratemask
,
794 .maxlen
= sizeof(int),
796 .proc_handler
= &proc_dointvec
801 struct ctl_path net_ipv4_ctl_path
[] = {
802 { .procname
= "net", .ctl_name
= CTL_NET
, },
803 { .procname
= "ipv4", .ctl_name
= NET_IPV4
, },
806 EXPORT_SYMBOL_GPL(net_ipv4_ctl_path
);
808 static __net_init
int ipv4_sysctl_init_net(struct net
*net
)
810 struct ctl_table
*table
;
812 table
= ipv4_net_table
;
813 if (net
!= &init_net
) {
814 table
= kmemdup(table
, sizeof(ipv4_net_table
), GFP_KERNEL
);
819 &net
->ipv4
.sysctl_icmp_echo_ignore_all
;
821 &net
->ipv4
.sysctl_icmp_echo_ignore_broadcasts
;
823 &net
->ipv4
.sysctl_icmp_ignore_bogus_error_responses
;
825 &net
->ipv4
.sysctl_icmp_errors_use_inbound_ifaddr
;
827 &net
->ipv4
.sysctl_icmp_ratelimit
;
829 &net
->ipv4
.sysctl_icmp_ratemask
;
832 net
->ipv4
.ipv4_hdr
= register_net_sysctl_table(net
,
833 net_ipv4_ctl_path
, table
);
834 if (net
->ipv4
.ipv4_hdr
== NULL
)
840 if (net
!= &init_net
)
846 static __net_exit
void ipv4_sysctl_exit_net(struct net
*net
)
848 struct ctl_table
*table
;
850 table
= net
->ipv4
.ipv4_hdr
->ctl_table_arg
;
851 unregister_net_sysctl_table(net
->ipv4
.ipv4_hdr
);
855 static __net_initdata
struct pernet_operations ipv4_sysctl_ops
= {
856 .init
= ipv4_sysctl_init_net
,
857 .exit
= ipv4_sysctl_exit_net
,
860 static __init
int sysctl_ipv4_init(void)
862 struct ctl_table_header
*hdr
;
864 hdr
= register_sysctl_paths(net_ipv4_ctl_path
, ipv4_table
);
868 if (register_pernet_subsys(&ipv4_sysctl_ops
)) {
869 unregister_sysctl_table(hdr
);
876 __initcall(sysctl_ipv4_init
);