2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4 * $Id: sysctl_net_ipv4.c,v 1.50 2001/10/20 00:00:11 davem Exp $
6 * Begun April 1, 1996, Mike Shaver.
7 * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
11 #include <linux/module.h>
12 #include <linux/sysctl.h>
13 #include <linux/igmp.h>
14 #include <linux/inetdevice.h>
18 #include <net/route.h>
20 #include <net/cipso_ipv4.h>
23 extern int sysctl_ip_nonlocal_bind
;
27 static int tcp_retr1_max
= 255;
28 static int ip_local_port_range_min
[] = { 1, 1 };
29 static int ip_local_port_range_max
[] = { 65535, 65535 };
32 struct ipv4_config ipv4_config
;
37 int ipv4_sysctl_forward(ctl_table
*ctl
, int write
, struct file
* filp
,
38 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
40 int val
= ipv4_devconf
.forwarding
;
43 ret
= proc_dointvec(ctl
, write
, filp
, buffer
, lenp
, ppos
);
45 if (write
&& ipv4_devconf
.forwarding
!= val
)
46 inet_forward_change();
51 static int ipv4_sysctl_forward_strategy(ctl_table
*table
,
52 int __user
*name
, int nlen
,
53 void __user
*oldval
, size_t __user
*oldlenp
,
54 void __user
*newval
, size_t newlen
,
57 int *valp
= table
->data
;
60 if (!newval
|| !newlen
)
63 if (newlen
!= sizeof(int))
66 if (get_user(new, (int __user
*)newval
))
72 if (oldval
&& oldlenp
) {
75 if (get_user(len
, oldlenp
))
79 if (len
> table
->maxlen
)
81 if (copy_to_user(oldval
, valp
, len
))
83 if (put_user(len
, oldlenp
))
89 inet_forward_change();
93 static int proc_tcp_congestion_control(ctl_table
*ctl
, int write
, struct file
* filp
,
94 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
96 char val
[TCP_CA_NAME_MAX
];
99 .maxlen
= TCP_CA_NAME_MAX
,
103 tcp_get_default_congestion_control(val
);
105 ret
= proc_dostring(&tbl
, write
, filp
, buffer
, lenp
, ppos
);
106 if (write
&& ret
== 0)
107 ret
= tcp_set_default_congestion_control(val
);
111 static int sysctl_tcp_congestion_control(ctl_table
*table
, int __user
*name
,
112 int nlen
, void __user
*oldval
,
113 size_t __user
*oldlenp
,
114 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
, name
, nlen
, oldval
, oldlenp
, newval
, newlen
,
127 if (ret
== 0 && newval
&& newlen
)
128 ret
= tcp_set_default_congestion_control(val
);
132 ctl_table ipv4_table
[] = {
134 .ctl_name
= NET_IPV4_TCP_TIMESTAMPS
,
135 .procname
= "tcp_timestamps",
136 .data
= &sysctl_tcp_timestamps
,
137 .maxlen
= sizeof(int),
139 .proc_handler
= &proc_dointvec
142 .ctl_name
= NET_IPV4_TCP_WINDOW_SCALING
,
143 .procname
= "tcp_window_scaling",
144 .data
= &sysctl_tcp_window_scaling
,
145 .maxlen
= sizeof(int),
147 .proc_handler
= &proc_dointvec
150 .ctl_name
= NET_IPV4_TCP_SACK
,
151 .procname
= "tcp_sack",
152 .data
= &sysctl_tcp_sack
,
153 .maxlen
= sizeof(int),
155 .proc_handler
= &proc_dointvec
158 .ctl_name
= NET_IPV4_TCP_RETRANS_COLLAPSE
,
159 .procname
= "tcp_retrans_collapse",
160 .data
= &sysctl_tcp_retrans_collapse
,
161 .maxlen
= sizeof(int),
163 .proc_handler
= &proc_dointvec
166 .ctl_name
= NET_IPV4_FORWARD
,
167 .procname
= "ip_forward",
168 .data
= &ipv4_devconf
.forwarding
,
169 .maxlen
= sizeof(int),
171 .proc_handler
= &ipv4_sysctl_forward
,
172 .strategy
= &ipv4_sysctl_forward_strategy
175 .ctl_name
= NET_IPV4_DEFAULT_TTL
,
176 .procname
= "ip_default_ttl",
177 .data
= &sysctl_ip_default_ttl
,
178 .maxlen
= sizeof(int),
180 .proc_handler
= &ipv4_doint_and_flush
,
181 .strategy
= &ipv4_doint_and_flush_strategy
,
184 .ctl_name
= NET_IPV4_NO_PMTU_DISC
,
185 .procname
= "ip_no_pmtu_disc",
186 .data
= &ipv4_config
.no_pmtu_disc
,
187 .maxlen
= sizeof(int),
189 .proc_handler
= &proc_dointvec
192 .ctl_name
= NET_IPV4_NONLOCAL_BIND
,
193 .procname
= "ip_nonlocal_bind",
194 .data
= &sysctl_ip_nonlocal_bind
,
195 .maxlen
= sizeof(int),
197 .proc_handler
= &proc_dointvec
200 .ctl_name
= NET_IPV4_TCP_SYN_RETRIES
,
201 .procname
= "tcp_syn_retries",
202 .data
= &sysctl_tcp_syn_retries
,
203 .maxlen
= sizeof(int),
205 .proc_handler
= &proc_dointvec
208 .ctl_name
= NET_TCP_SYNACK_RETRIES
,
209 .procname
= "tcp_synack_retries",
210 .data
= &sysctl_tcp_synack_retries
,
211 .maxlen
= sizeof(int),
213 .proc_handler
= &proc_dointvec
216 .ctl_name
= NET_TCP_MAX_ORPHANS
,
217 .procname
= "tcp_max_orphans",
218 .data
= &sysctl_tcp_max_orphans
,
219 .maxlen
= sizeof(int),
221 .proc_handler
= &proc_dointvec
224 .ctl_name
= NET_TCP_MAX_TW_BUCKETS
,
225 .procname
= "tcp_max_tw_buckets",
226 .data
= &tcp_death_row
.sysctl_max_tw_buckets
,
227 .maxlen
= sizeof(int),
229 .proc_handler
= &proc_dointvec
232 .ctl_name
= NET_IPV4_IPFRAG_HIGH_THRESH
,
233 .procname
= "ipfrag_high_thresh",
234 .data
= &sysctl_ipfrag_high_thresh
,
235 .maxlen
= sizeof(int),
237 .proc_handler
= &proc_dointvec
240 .ctl_name
= NET_IPV4_IPFRAG_LOW_THRESH
,
241 .procname
= "ipfrag_low_thresh",
242 .data
= &sysctl_ipfrag_low_thresh
,
243 .maxlen
= sizeof(int),
245 .proc_handler
= &proc_dointvec
248 .ctl_name
= NET_IPV4_DYNADDR
,
249 .procname
= "ip_dynaddr",
250 .data
= &sysctl_ip_dynaddr
,
251 .maxlen
= sizeof(int),
253 .proc_handler
= &proc_dointvec
256 .ctl_name
= NET_IPV4_IPFRAG_TIME
,
257 .procname
= "ipfrag_time",
258 .data
= &sysctl_ipfrag_time
,
259 .maxlen
= sizeof(int),
261 .proc_handler
= &proc_dointvec_jiffies
,
262 .strategy
= &sysctl_jiffies
265 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_TIME
,
266 .procname
= "tcp_keepalive_time",
267 .data
= &sysctl_tcp_keepalive_time
,
268 .maxlen
= sizeof(int),
270 .proc_handler
= &proc_dointvec_jiffies
,
271 .strategy
= &sysctl_jiffies
274 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_PROBES
,
275 .procname
= "tcp_keepalive_probes",
276 .data
= &sysctl_tcp_keepalive_probes
,
277 .maxlen
= sizeof(int),
279 .proc_handler
= &proc_dointvec
282 .ctl_name
= NET_IPV4_TCP_KEEPALIVE_INTVL
,
283 .procname
= "tcp_keepalive_intvl",
284 .data
= &sysctl_tcp_keepalive_intvl
,
285 .maxlen
= sizeof(int),
287 .proc_handler
= &proc_dointvec_jiffies
,
288 .strategy
= &sysctl_jiffies
291 .ctl_name
= NET_IPV4_TCP_RETRIES1
,
292 .procname
= "tcp_retries1",
293 .data
= &sysctl_tcp_retries1
,
294 .maxlen
= sizeof(int),
296 .proc_handler
= &proc_dointvec_minmax
,
297 .strategy
= &sysctl_intvec
,
298 .extra2
= &tcp_retr1_max
301 .ctl_name
= NET_IPV4_TCP_RETRIES2
,
302 .procname
= "tcp_retries2",
303 .data
= &sysctl_tcp_retries2
,
304 .maxlen
= sizeof(int),
306 .proc_handler
= &proc_dointvec
309 .ctl_name
= NET_IPV4_TCP_FIN_TIMEOUT
,
310 .procname
= "tcp_fin_timeout",
311 .data
= &sysctl_tcp_fin_timeout
,
312 .maxlen
= sizeof(int),
314 .proc_handler
= &proc_dointvec_jiffies
,
315 .strategy
= &sysctl_jiffies
317 #ifdef CONFIG_SYN_COOKIES
319 .ctl_name
= NET_TCP_SYNCOOKIES
,
320 .procname
= "tcp_syncookies",
321 .data
= &sysctl_tcp_syncookies
,
322 .maxlen
= sizeof(int),
324 .proc_handler
= &proc_dointvec
328 .ctl_name
= NET_TCP_TW_RECYCLE
,
329 .procname
= "tcp_tw_recycle",
330 .data
= &tcp_death_row
.sysctl_tw_recycle
,
331 .maxlen
= sizeof(int),
333 .proc_handler
= &proc_dointvec
336 .ctl_name
= NET_TCP_ABORT_ON_OVERFLOW
,
337 .procname
= "tcp_abort_on_overflow",
338 .data
= &sysctl_tcp_abort_on_overflow
,
339 .maxlen
= sizeof(int),
341 .proc_handler
= &proc_dointvec
344 .ctl_name
= NET_TCP_STDURG
,
345 .procname
= "tcp_stdurg",
346 .data
= &sysctl_tcp_stdurg
,
347 .maxlen
= sizeof(int),
349 .proc_handler
= &proc_dointvec
352 .ctl_name
= NET_TCP_RFC1337
,
353 .procname
= "tcp_rfc1337",
354 .data
= &sysctl_tcp_rfc1337
,
355 .maxlen
= sizeof(int),
357 .proc_handler
= &proc_dointvec
360 .ctl_name
= NET_TCP_MAX_SYN_BACKLOG
,
361 .procname
= "tcp_max_syn_backlog",
362 .data
= &sysctl_max_syn_backlog
,
363 .maxlen
= sizeof(int),
365 .proc_handler
= &proc_dointvec
368 .ctl_name
= NET_IPV4_LOCAL_PORT_RANGE
,
369 .procname
= "ip_local_port_range",
370 .data
= &sysctl_local_port_range
,
371 .maxlen
= sizeof(sysctl_local_port_range
),
373 .proc_handler
= &proc_dointvec_minmax
,
374 .strategy
= &sysctl_intvec
,
375 .extra1
= ip_local_port_range_min
,
376 .extra2
= ip_local_port_range_max
379 .ctl_name
= NET_IPV4_ICMP_ECHO_IGNORE_ALL
,
380 .procname
= "icmp_echo_ignore_all",
381 .data
= &sysctl_icmp_echo_ignore_all
,
382 .maxlen
= sizeof(int),
384 .proc_handler
= &proc_dointvec
387 .ctl_name
= NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS
,
388 .procname
= "icmp_echo_ignore_broadcasts",
389 .data
= &sysctl_icmp_echo_ignore_broadcasts
,
390 .maxlen
= sizeof(int),
392 .proc_handler
= &proc_dointvec
395 .ctl_name
= NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES
,
396 .procname
= "icmp_ignore_bogus_error_responses",
397 .data
= &sysctl_icmp_ignore_bogus_error_responses
,
398 .maxlen
= sizeof(int),
400 .proc_handler
= &proc_dointvec
403 .ctl_name
= NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR
,
404 .procname
= "icmp_errors_use_inbound_ifaddr",
405 .data
= &sysctl_icmp_errors_use_inbound_ifaddr
,
406 .maxlen
= sizeof(int),
408 .proc_handler
= &proc_dointvec
411 .ctl_name
= NET_IPV4_ROUTE
,
415 .child
= ipv4_route_table
417 #ifdef CONFIG_IP_MULTICAST
419 .ctl_name
= NET_IPV4_IGMP_MAX_MEMBERSHIPS
,
420 .procname
= "igmp_max_memberships",
421 .data
= &sysctl_igmp_max_memberships
,
422 .maxlen
= sizeof(int),
424 .proc_handler
= &proc_dointvec
429 .ctl_name
= NET_IPV4_IGMP_MAX_MSF
,
430 .procname
= "igmp_max_msf",
431 .data
= &sysctl_igmp_max_msf
,
432 .maxlen
= sizeof(int),
434 .proc_handler
= &proc_dointvec
437 .ctl_name
= NET_IPV4_INET_PEER_THRESHOLD
,
438 .procname
= "inet_peer_threshold",
439 .data
= &inet_peer_threshold
,
440 .maxlen
= sizeof(int),
442 .proc_handler
= &proc_dointvec
445 .ctl_name
= NET_IPV4_INET_PEER_MINTTL
,
446 .procname
= "inet_peer_minttl",
447 .data
= &inet_peer_minttl
,
448 .maxlen
= sizeof(int),
450 .proc_handler
= &proc_dointvec_jiffies
,
451 .strategy
= &sysctl_jiffies
454 .ctl_name
= NET_IPV4_INET_PEER_MAXTTL
,
455 .procname
= "inet_peer_maxttl",
456 .data
= &inet_peer_maxttl
,
457 .maxlen
= sizeof(int),
459 .proc_handler
= &proc_dointvec_jiffies
,
460 .strategy
= &sysctl_jiffies
463 .ctl_name
= NET_IPV4_INET_PEER_GC_MINTIME
,
464 .procname
= "inet_peer_gc_mintime",
465 .data
= &inet_peer_gc_mintime
,
466 .maxlen
= sizeof(int),
468 .proc_handler
= &proc_dointvec_jiffies
,
469 .strategy
= &sysctl_jiffies
472 .ctl_name
= NET_IPV4_INET_PEER_GC_MAXTIME
,
473 .procname
= "inet_peer_gc_maxtime",
474 .data
= &inet_peer_gc_maxtime
,
475 .maxlen
= sizeof(int),
477 .proc_handler
= &proc_dointvec_jiffies
,
478 .strategy
= &sysctl_jiffies
481 .ctl_name
= NET_TCP_ORPHAN_RETRIES
,
482 .procname
= "tcp_orphan_retries",
483 .data
= &sysctl_tcp_orphan_retries
,
484 .maxlen
= sizeof(int),
486 .proc_handler
= &proc_dointvec
489 .ctl_name
= NET_TCP_FACK
,
490 .procname
= "tcp_fack",
491 .data
= &sysctl_tcp_fack
,
492 .maxlen
= sizeof(int),
494 .proc_handler
= &proc_dointvec
497 .ctl_name
= NET_TCP_REORDERING
,
498 .procname
= "tcp_reordering",
499 .data
= &sysctl_tcp_reordering
,
500 .maxlen
= sizeof(int),
502 .proc_handler
= &proc_dointvec
505 .ctl_name
= NET_TCP_ECN
,
506 .procname
= "tcp_ecn",
507 .data
= &sysctl_tcp_ecn
,
508 .maxlen
= sizeof(int),
510 .proc_handler
= &proc_dointvec
513 .ctl_name
= NET_TCP_DSACK
,
514 .procname
= "tcp_dsack",
515 .data
= &sysctl_tcp_dsack
,
516 .maxlen
= sizeof(int),
518 .proc_handler
= &proc_dointvec
521 .ctl_name
= NET_TCP_MEM
,
522 .procname
= "tcp_mem",
523 .data
= &sysctl_tcp_mem
,
524 .maxlen
= sizeof(sysctl_tcp_mem
),
526 .proc_handler
= &proc_dointvec
529 .ctl_name
= NET_TCP_WMEM
,
530 .procname
= "tcp_wmem",
531 .data
= &sysctl_tcp_wmem
,
532 .maxlen
= sizeof(sysctl_tcp_wmem
),
534 .proc_handler
= &proc_dointvec
537 .ctl_name
= NET_TCP_RMEM
,
538 .procname
= "tcp_rmem",
539 .data
= &sysctl_tcp_rmem
,
540 .maxlen
= sizeof(sysctl_tcp_rmem
),
542 .proc_handler
= &proc_dointvec
545 .ctl_name
= NET_TCP_APP_WIN
,
546 .procname
= "tcp_app_win",
547 .data
= &sysctl_tcp_app_win
,
548 .maxlen
= sizeof(int),
550 .proc_handler
= &proc_dointvec
553 .ctl_name
= NET_TCP_ADV_WIN_SCALE
,
554 .procname
= "tcp_adv_win_scale",
555 .data
= &sysctl_tcp_adv_win_scale
,
556 .maxlen
= sizeof(int),
558 .proc_handler
= &proc_dointvec
561 .ctl_name
= NET_IPV4_ICMP_RATELIMIT
,
562 .procname
= "icmp_ratelimit",
563 .data
= &sysctl_icmp_ratelimit
,
564 .maxlen
= sizeof(int),
566 .proc_handler
= &proc_dointvec
569 .ctl_name
= NET_IPV4_ICMP_RATEMASK
,
570 .procname
= "icmp_ratemask",
571 .data
= &sysctl_icmp_ratemask
,
572 .maxlen
= sizeof(int),
574 .proc_handler
= &proc_dointvec
577 .ctl_name
= NET_TCP_TW_REUSE
,
578 .procname
= "tcp_tw_reuse",
579 .data
= &sysctl_tcp_tw_reuse
,
580 .maxlen
= sizeof(int),
582 .proc_handler
= &proc_dointvec
585 .ctl_name
= NET_TCP_FRTO
,
586 .procname
= "tcp_frto",
587 .data
= &sysctl_tcp_frto
,
588 .maxlen
= sizeof(int),
590 .proc_handler
= &proc_dointvec
593 .ctl_name
= NET_TCP_LOW_LATENCY
,
594 .procname
= "tcp_low_latency",
595 .data
= &sysctl_tcp_low_latency
,
596 .maxlen
= sizeof(int),
598 .proc_handler
= &proc_dointvec
601 .ctl_name
= NET_IPV4_IPFRAG_SECRET_INTERVAL
,
602 .procname
= "ipfrag_secret_interval",
603 .data
= &sysctl_ipfrag_secret_interval
,
604 .maxlen
= sizeof(int),
606 .proc_handler
= &proc_dointvec_jiffies
,
607 .strategy
= &sysctl_jiffies
610 .ctl_name
= NET_IPV4_IPFRAG_MAX_DIST
,
611 .procname
= "ipfrag_max_dist",
612 .data
= &sysctl_ipfrag_max_dist
,
613 .maxlen
= sizeof(int),
615 .proc_handler
= &proc_dointvec_minmax
,
619 .ctl_name
= NET_TCP_NO_METRICS_SAVE
,
620 .procname
= "tcp_no_metrics_save",
621 .data
= &sysctl_tcp_nometrics_save
,
622 .maxlen
= sizeof(int),
624 .proc_handler
= &proc_dointvec
,
627 .ctl_name
= NET_TCP_MODERATE_RCVBUF
,
628 .procname
= "tcp_moderate_rcvbuf",
629 .data
= &sysctl_tcp_moderate_rcvbuf
,
630 .maxlen
= sizeof(int),
632 .proc_handler
= &proc_dointvec
,
635 .ctl_name
= NET_TCP_TSO_WIN_DIVISOR
,
636 .procname
= "tcp_tso_win_divisor",
637 .data
= &sysctl_tcp_tso_win_divisor
,
638 .maxlen
= sizeof(int),
640 .proc_handler
= &proc_dointvec
,
643 .ctl_name
= NET_TCP_CONG_CONTROL
,
644 .procname
= "tcp_congestion_control",
646 .maxlen
= TCP_CA_NAME_MAX
,
647 .proc_handler
= &proc_tcp_congestion_control
,
648 .strategy
= &sysctl_tcp_congestion_control
,
651 .ctl_name
= NET_TCP_ABC
,
652 .procname
= "tcp_abc",
653 .data
= &sysctl_tcp_abc
,
654 .maxlen
= sizeof(int),
656 .proc_handler
= &proc_dointvec
,
659 .ctl_name
= NET_TCP_MTU_PROBING
,
660 .procname
= "tcp_mtu_probing",
661 .data
= &sysctl_tcp_mtu_probing
,
662 .maxlen
= sizeof(int),
664 .proc_handler
= &proc_dointvec
,
667 .ctl_name
= NET_TCP_BASE_MSS
,
668 .procname
= "tcp_base_mss",
669 .data
= &sysctl_tcp_base_mss
,
670 .maxlen
= sizeof(int),
672 .proc_handler
= &proc_dointvec
,
675 .ctl_name
= NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS
,
676 .procname
= "tcp_workaround_signed_windows",
677 .data
= &sysctl_tcp_workaround_signed_windows
,
678 .maxlen
= sizeof(int),
680 .proc_handler
= &proc_dointvec
682 #ifdef CONFIG_NET_DMA
684 .ctl_name
= NET_TCP_DMA_COPYBREAK
,
685 .procname
= "tcp_dma_copybreak",
686 .data
= &sysctl_tcp_dma_copybreak
,
687 .maxlen
= sizeof(int),
689 .proc_handler
= &proc_dointvec
693 .ctl_name
= NET_TCP_SLOW_START_AFTER_IDLE
,
694 .procname
= "tcp_slow_start_after_idle",
695 .data
= &sysctl_tcp_slow_start_after_idle
,
696 .maxlen
= sizeof(int),
698 .proc_handler
= &proc_dointvec
700 #ifdef CONFIG_NETLABEL
702 .ctl_name
= NET_CIPSOV4_CACHE_ENABLE
,
703 .procname
= "cipso_cache_enable",
704 .data
= &cipso_v4_cache_enabled
,
705 .maxlen
= sizeof(int),
707 .proc_handler
= &proc_dointvec
,
710 .ctl_name
= NET_CIPSOV4_CACHE_BUCKET_SIZE
,
711 .procname
= "cipso_cache_bucket_size",
712 .data
= &cipso_v4_cache_bucketsize
,
713 .maxlen
= sizeof(int),
715 .proc_handler
= &proc_dointvec
,
718 .ctl_name
= NET_CIPSOV4_RBM_OPTFMT
,
719 .procname
= "cipso_rbm_optfmt",
720 .data
= &cipso_v4_rbm_optfmt
,
721 .maxlen
= sizeof(int),
723 .proc_handler
= &proc_dointvec
,
726 .ctl_name
= NET_CIPSOV4_RBM_STRICTVALID
,
727 .procname
= "cipso_rbm_strictvalid",
728 .data
= &cipso_v4_rbm_strictvalid
,
729 .maxlen
= sizeof(int),
731 .proc_handler
= &proc_dointvec
,
733 #endif /* CONFIG_NETLABEL */
737 #endif /* CONFIG_SYSCTL */
739 EXPORT_SYMBOL(ipv4_config
);