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/config.h>
16 #include <net/route.h>
20 extern int sysctl_ip_nonlocal_bind;
23 extern int sysctl_icmp_echo_ignore_all;
24 extern int sysctl_icmp_echo_ignore_broadcasts;
25 extern int sysctl_icmp_ignore_bogus_error_responses;
27 /* From ip_fragment.c */
28 extern int sysctl_ipfrag_low_thresh;
29 extern int sysctl_ipfrag_high_thresh;
30 extern int sysctl_ipfrag_time;
31 extern int sysctl_ipfrag_secret_interval;
33 /* From ip_output.c */
34 extern int sysctl_ip_dynaddr;
37 extern int sysctl_icmp_ratelimit;
38 extern int sysctl_icmp_ratemask;
41 extern int sysctl_igmp_max_memberships;
42 extern int sysctl_igmp_max_msf;
45 extern int inet_peer_threshold;
46 extern int inet_peer_minttl;
47 extern int inet_peer_maxttl;
48 extern int inet_peer_gc_mintime;
49 extern int inet_peer_gc_maxtime;
52 static int tcp_retr1_max = 255;
53 static int ip_local_port_range_min[] = { 1, 1 };
54 static int ip_local_port_range_max[] = { 65535, 65535 };
57 struct ipv4_config ipv4_config;
59 extern ctl_table ipv4_route_table[];
64 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
65 void __user *buffer, size_t *lenp, loff_t *ppos)
67 int val = ipv4_devconf.forwarding;
70 ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
72 if (write && ipv4_devconf.forwarding != val)
73 inet_forward_change();
78 static int ipv4_sysctl_forward_strategy(ctl_table *table,
79 int __user *name, int nlen,
80 void __user *oldval, size_t __user *oldlenp,
81 void __user *newval, size_t newlen,
84 int *valp = table->data;
87 if (!newval || !newlen)
90 if (newlen != sizeof(int))
93 if (get_user(new, (int __user *)newval))
99 if (oldval && oldlenp) {
102 if (get_user(len, oldlenp))
106 if (len > table->maxlen)
108 if (copy_to_user(oldval, valp, len))
110 if (put_user(len, oldlenp))
116 inet_forward_change();
120 ctl_table ipv4_table[] = {
122 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
123 .procname = "tcp_timestamps",
124 .data = &sysctl_tcp_timestamps,
125 .maxlen = sizeof(int),
127 .proc_handler = &proc_dointvec
130 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING,
131 .procname = "tcp_window_scaling",
132 .data = &sysctl_tcp_window_scaling,
133 .maxlen = sizeof(int),
135 .proc_handler = &proc_dointvec
138 .ctl_name = NET_IPV4_TCP_SACK,
139 .procname = "tcp_sack",
140 .data = &sysctl_tcp_sack,
141 .maxlen = sizeof(int),
143 .proc_handler = &proc_dointvec
146 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE,
147 .procname = "tcp_retrans_collapse",
148 .data = &sysctl_tcp_retrans_collapse,
149 .maxlen = sizeof(int),
151 .proc_handler = &proc_dointvec
154 .ctl_name = NET_IPV4_FORWARD,
155 .procname = "ip_forward",
156 .data = &ipv4_devconf.forwarding,
157 .maxlen = sizeof(int),
159 .proc_handler = &ipv4_sysctl_forward,
160 .strategy = &ipv4_sysctl_forward_strategy
163 .ctl_name = NET_IPV4_DEFAULT_TTL,
164 .procname = "ip_default_ttl",
165 .data = &sysctl_ip_default_ttl,
166 .maxlen = sizeof(int),
168 .proc_handler = &ipv4_doint_and_flush,
169 .strategy = &ipv4_doint_and_flush_strategy,
172 .ctl_name = NET_IPV4_AUTOCONFIG,
173 .procname = "ip_autoconfig",
174 .data = &ipv4_config.autoconfig,
175 .maxlen = sizeof(int),
177 .proc_handler = &proc_dointvec
180 .ctl_name = NET_IPV4_NO_PMTU_DISC,
181 .procname = "ip_no_pmtu_disc",
182 .data = &ipv4_config.no_pmtu_disc,
183 .maxlen = sizeof(int),
185 .proc_handler = &proc_dointvec
188 .ctl_name = NET_IPV4_NONLOCAL_BIND,
189 .procname = "ip_nonlocal_bind",
190 .data = &sysctl_ip_nonlocal_bind,
191 .maxlen = sizeof(int),
193 .proc_handler = &proc_dointvec
196 .ctl_name = NET_IPV4_TCP_SYN_RETRIES,
197 .procname = "tcp_syn_retries",
198 .data = &sysctl_tcp_syn_retries,
199 .maxlen = sizeof(int),
201 .proc_handler = &proc_dointvec
204 .ctl_name = NET_TCP_SYNACK_RETRIES,
205 .procname = "tcp_synack_retries",
206 .data = &sysctl_tcp_synack_retries,
207 .maxlen = sizeof(int),
209 .proc_handler = &proc_dointvec
212 .ctl_name = NET_TCP_MAX_ORPHANS,
213 .procname = "tcp_max_orphans",
214 .data = &sysctl_tcp_max_orphans,
215 .maxlen = sizeof(int),
217 .proc_handler = &proc_dointvec
220 .ctl_name = NET_TCP_MAX_TW_BUCKETS,
221 .procname = "tcp_max_tw_buckets",
222 .data = &sysctl_tcp_max_tw_buckets,
223 .maxlen = sizeof(int),
225 .proc_handler = &proc_dointvec
228 .ctl_name = NET_IPV4_IPFRAG_HIGH_THRESH,
229 .procname = "ipfrag_high_thresh",
230 .data = &sysctl_ipfrag_high_thresh,
231 .maxlen = sizeof(int),
233 .proc_handler = &proc_dointvec
236 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH,
237 .procname = "ipfrag_low_thresh",
238 .data = &sysctl_ipfrag_low_thresh,
239 .maxlen = sizeof(int),
241 .proc_handler = &proc_dointvec
244 .ctl_name = NET_IPV4_DYNADDR,
245 .procname = "ip_dynaddr",
246 .data = &sysctl_ip_dynaddr,
247 .maxlen = sizeof(int),
249 .proc_handler = &proc_dointvec
252 .ctl_name = NET_IPV4_IPFRAG_TIME,
253 .procname = "ipfrag_time",
254 .data = &sysctl_ipfrag_time,
255 .maxlen = sizeof(int),
257 .proc_handler = &proc_dointvec_jiffies,
258 .strategy = &sysctl_jiffies
261 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME,
262 .procname = "tcp_keepalive_time",
263 .data = &sysctl_tcp_keepalive_time,
264 .maxlen = sizeof(int),
266 .proc_handler = &proc_dointvec_jiffies,
267 .strategy = &sysctl_jiffies
270 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES,
271 .procname = "tcp_keepalive_probes",
272 .data = &sysctl_tcp_keepalive_probes,
273 .maxlen = sizeof(int),
275 .proc_handler = &proc_dointvec
278 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL,
279 .procname = "tcp_keepalive_intvl",
280 .data = &sysctl_tcp_keepalive_intvl,
281 .maxlen = sizeof(int),
283 .proc_handler = &proc_dointvec_jiffies,
284 .strategy = &sysctl_jiffies
287 .ctl_name = NET_IPV4_TCP_RETRIES1,
288 .procname = "tcp_retries1",
289 .data = &sysctl_tcp_retries1,
290 .maxlen = sizeof(int),
292 .proc_handler = &proc_dointvec_minmax,
293 .strategy = &sysctl_intvec,
294 .extra2 = &tcp_retr1_max
297 .ctl_name = NET_IPV4_TCP_RETRIES2,
298 .procname = "tcp_retries2",
299 .data = &sysctl_tcp_retries2,
300 .maxlen = sizeof(int),
302 .proc_handler = &proc_dointvec
305 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT,
306 .procname = "tcp_fin_timeout",
307 .data = &sysctl_tcp_fin_timeout,
308 .maxlen = sizeof(int),
310 .proc_handler = &proc_dointvec_jiffies,
311 .strategy = &sysctl_jiffies
313 #ifdef CONFIG_SYN_COOKIES
315 .ctl_name = NET_TCP_SYNCOOKIES,
316 .procname = "tcp_syncookies",
317 .data = &sysctl_tcp_syncookies,
318 .maxlen = sizeof(int),
320 .proc_handler = &proc_dointvec
324 .ctl_name = NET_TCP_TW_RECYCLE,
325 .procname = "tcp_tw_recycle",
326 .data = &sysctl_tcp_tw_recycle,
327 .maxlen = sizeof(int),
329 .proc_handler = &proc_dointvec
332 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW,
333 .procname = "tcp_abort_on_overflow",
334 .data = &sysctl_tcp_abort_on_overflow,
335 .maxlen = sizeof(int),
337 .proc_handler = &proc_dointvec
340 .ctl_name = NET_TCP_STDURG,
341 .procname = "tcp_stdurg",
342 .data = &sysctl_tcp_stdurg,
343 .maxlen = sizeof(int),
345 .proc_handler = &proc_dointvec
348 .ctl_name = NET_TCP_RFC1337,
349 .procname = "tcp_rfc1337",
350 .data = &sysctl_tcp_rfc1337,
351 .maxlen = sizeof(int),
353 .proc_handler = &proc_dointvec
356 .ctl_name = NET_TCP_MAX_SYN_BACKLOG,
357 .procname = "tcp_max_syn_backlog",
358 .data = &sysctl_max_syn_backlog,
359 .maxlen = sizeof(int),
361 .proc_handler = &proc_dointvec
364 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE,
365 .procname = "ip_local_port_range",
366 .data = &sysctl_local_port_range,
367 .maxlen = sizeof(sysctl_local_port_range),
369 .proc_handler = &proc_dointvec_minmax,
370 .strategy = &sysctl_intvec,
371 .extra1 = ip_local_port_range_min,
372 .extra2 = ip_local_port_range_max
375 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
376 .procname = "icmp_echo_ignore_all",
377 .data = &sysctl_icmp_echo_ignore_all,
378 .maxlen = sizeof(int),
380 .proc_handler = &proc_dointvec
383 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
384 .procname = "icmp_echo_ignore_broadcasts",
385 .data = &sysctl_icmp_echo_ignore_broadcasts,
386 .maxlen = sizeof(int),
388 .proc_handler = &proc_dointvec
391 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
392 .procname = "icmp_ignore_bogus_error_responses",
393 .data = &sysctl_icmp_ignore_bogus_error_responses,
394 .maxlen = sizeof(int),
396 .proc_handler = &proc_dointvec
399 .ctl_name = NET_IPV4_ROUTE,
403 .child = ipv4_route_table
405 #ifdef CONFIG_IP_MULTICAST
407 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
408 .procname = "igmp_max_memberships",
409 .data = &sysctl_igmp_max_memberships,
410 .maxlen = sizeof(int),
412 .proc_handler = &proc_dointvec
417 .ctl_name = NET_IPV4_IGMP_MAX_MSF,
418 .procname = "igmp_max_msf",
419 .data = &sysctl_igmp_max_msf,
420 .maxlen = sizeof(int),
422 .proc_handler = &proc_dointvec
425 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD,
426 .procname = "inet_peer_threshold",
427 .data = &inet_peer_threshold,
428 .maxlen = sizeof(int),
430 .proc_handler = &proc_dointvec
433 .ctl_name = NET_IPV4_INET_PEER_MINTTL,
434 .procname = "inet_peer_minttl",
435 .data = &inet_peer_minttl,
436 .maxlen = sizeof(int),
438 .proc_handler = &proc_dointvec_jiffies,
439 .strategy = &sysctl_jiffies
442 .ctl_name = NET_IPV4_INET_PEER_MAXTTL,
443 .procname = "inet_peer_maxttl",
444 .data = &inet_peer_maxttl,
445 .maxlen = sizeof(int),
447 .proc_handler = &proc_dointvec_jiffies,
448 .strategy = &sysctl_jiffies
451 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME,
452 .procname = "inet_peer_gc_mintime",
453 .data = &inet_peer_gc_mintime,
454 .maxlen = sizeof(int),
456 .proc_handler = &proc_dointvec_jiffies,
457 .strategy = &sysctl_jiffies
460 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME,
461 .procname = "inet_peer_gc_maxtime",
462 .data = &inet_peer_gc_maxtime,
463 .maxlen = sizeof(int),
465 .proc_handler = &proc_dointvec_jiffies,
466 .strategy = &sysctl_jiffies
469 .ctl_name = NET_TCP_ORPHAN_RETRIES,
470 .procname = "tcp_orphan_retries",
471 .data = &sysctl_tcp_orphan_retries,
472 .maxlen = sizeof(int),
474 .proc_handler = &proc_dointvec
477 .ctl_name = NET_TCP_FACK,
478 .procname = "tcp_fack",
479 .data = &sysctl_tcp_fack,
480 .maxlen = sizeof(int),
482 .proc_handler = &proc_dointvec
485 .ctl_name = NET_TCP_REORDERING,
486 .procname = "tcp_reordering",
487 .data = &sysctl_tcp_reordering,
488 .maxlen = sizeof(int),
490 .proc_handler = &proc_dointvec
493 .ctl_name = NET_TCP_ECN,
494 .procname = "tcp_ecn",
495 .data = &sysctl_tcp_ecn,
496 .maxlen = sizeof(int),
498 .proc_handler = &proc_dointvec
501 .ctl_name = NET_TCP_DSACK,
502 .procname = "tcp_dsack",
503 .data = &sysctl_tcp_dsack,
504 .maxlen = sizeof(int),
506 .proc_handler = &proc_dointvec
509 .ctl_name = NET_TCP_MEM,
510 .procname = "tcp_mem",
511 .data = &sysctl_tcp_mem,
512 .maxlen = sizeof(sysctl_tcp_mem),
514 .proc_handler = &proc_dointvec
517 .ctl_name = NET_TCP_WMEM,
518 .procname = "tcp_wmem",
519 .data = &sysctl_tcp_wmem,
520 .maxlen = sizeof(sysctl_tcp_wmem),
522 .proc_handler = &proc_dointvec
525 .ctl_name = NET_TCP_RMEM,
526 .procname = "tcp_rmem",
527 .data = &sysctl_tcp_rmem,
528 .maxlen = sizeof(sysctl_tcp_rmem),
530 .proc_handler = &proc_dointvec
533 .ctl_name = NET_TCP_APP_WIN,
534 .procname = "tcp_app_win",
535 .data = &sysctl_tcp_app_win,
536 .maxlen = sizeof(int),
538 .proc_handler = &proc_dointvec
541 .ctl_name = NET_TCP_ADV_WIN_SCALE,
542 .procname = "tcp_adv_win_scale",
543 .data = &sysctl_tcp_adv_win_scale,
544 .maxlen = sizeof(int),
546 .proc_handler = &proc_dointvec
549 .ctl_name = NET_IPV4_ICMP_RATELIMIT,
550 .procname = "icmp_ratelimit",
551 .data = &sysctl_icmp_ratelimit,
552 .maxlen = sizeof(int),
554 .proc_handler = &proc_dointvec
557 .ctl_name = NET_IPV4_ICMP_RATEMASK,
558 .procname = "icmp_ratemask",
559 .data = &sysctl_icmp_ratemask,
560 .maxlen = sizeof(int),
562 .proc_handler = &proc_dointvec
565 .ctl_name = NET_TCP_TW_REUSE,
566 .procname = "tcp_tw_reuse",
567 .data = &sysctl_tcp_tw_reuse,
568 .maxlen = sizeof(int),
570 .proc_handler = &proc_dointvec
573 .ctl_name = NET_TCP_FRTO,
574 .procname = "tcp_frto",
575 .data = &sysctl_tcp_frto,
576 .maxlen = sizeof(int),
578 .proc_handler = &proc_dointvec
581 .ctl_name = NET_TCP_LOW_LATENCY,
582 .procname = "tcp_low_latency",
583 .data = &sysctl_tcp_low_latency,
584 .maxlen = sizeof(int),
586 .proc_handler = &proc_dointvec
589 .ctl_name = NET_IPV4_IPFRAG_SECRET_INTERVAL,
590 .procname = "ipfrag_secret_interval",
591 .data = &sysctl_ipfrag_secret_interval,
592 .maxlen = sizeof(int),
594 .proc_handler = &proc_dointvec_jiffies,
595 .strategy = &sysctl_jiffies
598 .ctl_name = NET_TCP_NO_METRICS_SAVE,
599 .procname = "tcp_no_metrics_save",
600 .data = &sysctl_tcp_nometrics_save,
601 .maxlen = sizeof(int),
603 .proc_handler = &proc_dointvec,
606 .ctl_name = NET_TCP_WESTWOOD,
607 .procname = "tcp_westwood",
608 .data = &sysctl_tcp_westwood,
609 .maxlen = sizeof(int),
611 .proc_handler = &proc_dointvec,
614 .ctl_name = NET_TCP_VEGAS,
615 .procname = "tcp_vegas_cong_avoid",
616 .data = &sysctl_tcp_vegas_cong_avoid,
617 .maxlen = sizeof(int),
619 .proc_handler = &proc_dointvec,
622 .ctl_name = NET_TCP_VEGAS_ALPHA,
623 .procname = "tcp_vegas_alpha",
624 .data = &sysctl_tcp_vegas_alpha,
625 .maxlen = sizeof(int),
627 .proc_handler = &proc_dointvec,
630 .ctl_name = NET_TCP_VEGAS_BETA,
631 .procname = "tcp_vegas_beta",
632 .data = &sysctl_tcp_vegas_beta,
633 .maxlen = sizeof(int),
635 .proc_handler = &proc_dointvec,
638 .ctl_name = NET_TCP_VEGAS_GAMMA,
639 .procname = "tcp_vegas_gamma",
640 .data = &sysctl_tcp_vegas_gamma,
641 .maxlen = sizeof(int),
643 .proc_handler = &proc_dointvec,
646 .ctl_name = NET_TCP_BIC,
647 .procname = "tcp_bic",
648 .data = &sysctl_tcp_bic,
649 .maxlen = sizeof(int),
651 .proc_handler = &proc_dointvec,
654 .ctl_name = NET_TCP_BIC_FAST_CONVERGENCE,
655 .procname = "tcp_bic_fast_convergence",
656 .data = &sysctl_tcp_bic_fast_convergence,
657 .maxlen = sizeof(int),
659 .proc_handler = &proc_dointvec,
662 .ctl_name = NET_TCP_BIC_LOW_WINDOW,
663 .procname = "tcp_bic_low_window",
664 .data = &sysctl_tcp_bic_low_window,
665 .maxlen = sizeof(int),
667 .proc_handler = &proc_dointvec,
670 .ctl_name = NET_TCP_MODERATE_RCVBUF,
671 .procname = "tcp_moderate_rcvbuf",
672 .data = &sysctl_tcp_moderate_rcvbuf,
673 .maxlen = sizeof(int),
675 .proc_handler = &proc_dointvec,
678 .ctl_name = NET_TCP_TSO_WIN_DIVISOR,
679 .procname = "tcp_tso_win_divisor",
680 .data = &sysctl_tcp_tso_win_divisor,
681 .maxlen = sizeof(int),
683 .proc_handler = &proc_dointvec,
686 .ctl_name = NET_TCP_BIC_BETA,
687 .procname = "tcp_bic_beta",
688 .data = &sysctl_tcp_bic_beta,
689 .maxlen = sizeof(int),
691 .proc_handler = &proc_dointvec,
696 #endif /* CONFIG_SYSCTL */
698 EXPORT_SYMBOL(ipv4_config);