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;
26 extern int sysctl_icmp_errors_use_inbound_ifaddr;
28 /* From ip_fragment.c */
29 extern int sysctl_ipfrag_low_thresh;
30 extern int sysctl_ipfrag_high_thresh;
31 extern int sysctl_ipfrag_time;
32 extern int sysctl_ipfrag_secret_interval;
34 /* From ip_output.c */
35 extern int sysctl_ip_dynaddr;
38 extern int sysctl_icmp_ratelimit;
39 extern int sysctl_icmp_ratemask;
42 extern int sysctl_igmp_max_memberships;
43 extern int sysctl_igmp_max_msf;
46 extern int inet_peer_threshold;
47 extern int inet_peer_minttl;
48 extern int inet_peer_maxttl;
49 extern int inet_peer_gc_mintime;
50 extern int inet_peer_gc_maxtime;
53 static int tcp_retr1_max = 255;
54 static int ip_local_port_range_min[] = { 1, 1 };
55 static int ip_local_port_range_max[] = { 65535, 65535 };
58 struct ipv4_config ipv4_config;
60 extern ctl_table ipv4_route_table[];
65 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
66 void __user *buffer, size_t *lenp, loff_t *ppos)
68 int val = ipv4_devconf.forwarding;
71 ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
73 if (write && ipv4_devconf.forwarding != val)
74 inet_forward_change();
79 static int ipv4_sysctl_forward_strategy(ctl_table *table,
80 int __user *name, int nlen,
81 void __user *oldval, size_t __user *oldlenp,
82 void __user *newval, size_t newlen,
85 int *valp = table->data;
88 if (!newval || !newlen)
91 if (newlen != sizeof(int))
94 if (get_user(new, (int __user *)newval))
100 if (oldval && oldlenp) {
103 if (get_user(len, oldlenp))
107 if (len > table->maxlen)
109 if (copy_to_user(oldval, valp, len))
111 if (put_user(len, oldlenp))
117 inet_forward_change();
121 ctl_table ipv4_table[] = {
123 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
124 .procname = "tcp_timestamps",
125 .data = &sysctl_tcp_timestamps,
126 .maxlen = sizeof(int),
128 .proc_handler = &proc_dointvec
131 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING,
132 .procname = "tcp_window_scaling",
133 .data = &sysctl_tcp_window_scaling,
134 .maxlen = sizeof(int),
136 .proc_handler = &proc_dointvec
139 .ctl_name = NET_IPV4_TCP_SACK,
140 .procname = "tcp_sack",
141 .data = &sysctl_tcp_sack,
142 .maxlen = sizeof(int),
144 .proc_handler = &proc_dointvec
147 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE,
148 .procname = "tcp_retrans_collapse",
149 .data = &sysctl_tcp_retrans_collapse,
150 .maxlen = sizeof(int),
152 .proc_handler = &proc_dointvec
155 .ctl_name = NET_IPV4_FORWARD,
156 .procname = "ip_forward",
157 .data = &ipv4_devconf.forwarding,
158 .maxlen = sizeof(int),
160 .proc_handler = &ipv4_sysctl_forward,
161 .strategy = &ipv4_sysctl_forward_strategy
164 .ctl_name = NET_IPV4_DEFAULT_TTL,
165 .procname = "ip_default_ttl",
166 .data = &sysctl_ip_default_ttl,
167 .maxlen = sizeof(int),
169 .proc_handler = &ipv4_doint_and_flush,
170 .strategy = &ipv4_doint_and_flush_strategy,
173 .ctl_name = NET_IPV4_AUTOCONFIG,
174 .procname = "ip_autoconfig",
175 .data = &ipv4_config.autoconfig,
176 .maxlen = sizeof(int),
178 .proc_handler = &proc_dointvec
181 .ctl_name = NET_IPV4_NO_PMTU_DISC,
182 .procname = "ip_no_pmtu_disc",
183 .data = &ipv4_config.no_pmtu_disc,
184 .maxlen = sizeof(int),
186 .proc_handler = &proc_dointvec
189 .ctl_name = NET_IPV4_NONLOCAL_BIND,
190 .procname = "ip_nonlocal_bind",
191 .data = &sysctl_ip_nonlocal_bind,
192 .maxlen = sizeof(int),
194 .proc_handler = &proc_dointvec
197 .ctl_name = NET_IPV4_TCP_SYN_RETRIES,
198 .procname = "tcp_syn_retries",
199 .data = &sysctl_tcp_syn_retries,
200 .maxlen = sizeof(int),
202 .proc_handler = &proc_dointvec
205 .ctl_name = NET_TCP_SYNACK_RETRIES,
206 .procname = "tcp_synack_retries",
207 .data = &sysctl_tcp_synack_retries,
208 .maxlen = sizeof(int),
210 .proc_handler = &proc_dointvec
213 .ctl_name = NET_TCP_MAX_ORPHANS,
214 .procname = "tcp_max_orphans",
215 .data = &sysctl_tcp_max_orphans,
216 .maxlen = sizeof(int),
218 .proc_handler = &proc_dointvec
221 .ctl_name = NET_TCP_MAX_TW_BUCKETS,
222 .procname = "tcp_max_tw_buckets",
223 .data = &sysctl_tcp_max_tw_buckets,
224 .maxlen = sizeof(int),
226 .proc_handler = &proc_dointvec
229 .ctl_name = NET_IPV4_IPFRAG_HIGH_THRESH,
230 .procname = "ipfrag_high_thresh",
231 .data = &sysctl_ipfrag_high_thresh,
232 .maxlen = sizeof(int),
234 .proc_handler = &proc_dointvec
237 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH,
238 .procname = "ipfrag_low_thresh",
239 .data = &sysctl_ipfrag_low_thresh,
240 .maxlen = sizeof(int),
242 .proc_handler = &proc_dointvec
245 .ctl_name = NET_IPV4_DYNADDR,
246 .procname = "ip_dynaddr",
247 .data = &sysctl_ip_dynaddr,
248 .maxlen = sizeof(int),
250 .proc_handler = &proc_dointvec
253 .ctl_name = NET_IPV4_IPFRAG_TIME,
254 .procname = "ipfrag_time",
255 .data = &sysctl_ipfrag_time,
256 .maxlen = sizeof(int),
258 .proc_handler = &proc_dointvec_jiffies,
259 .strategy = &sysctl_jiffies
262 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME,
263 .procname = "tcp_keepalive_time",
264 .data = &sysctl_tcp_keepalive_time,
265 .maxlen = sizeof(int),
267 .proc_handler = &proc_dointvec_jiffies,
268 .strategy = &sysctl_jiffies
271 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES,
272 .procname = "tcp_keepalive_probes",
273 .data = &sysctl_tcp_keepalive_probes,
274 .maxlen = sizeof(int),
276 .proc_handler = &proc_dointvec
279 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL,
280 .procname = "tcp_keepalive_intvl",
281 .data = &sysctl_tcp_keepalive_intvl,
282 .maxlen = sizeof(int),
284 .proc_handler = &proc_dointvec_jiffies,
285 .strategy = &sysctl_jiffies
288 .ctl_name = NET_IPV4_TCP_RETRIES1,
289 .procname = "tcp_retries1",
290 .data = &sysctl_tcp_retries1,
291 .maxlen = sizeof(int),
293 .proc_handler = &proc_dointvec_minmax,
294 .strategy = &sysctl_intvec,
295 .extra2 = &tcp_retr1_max
298 .ctl_name = NET_IPV4_TCP_RETRIES2,
299 .procname = "tcp_retries2",
300 .data = &sysctl_tcp_retries2,
301 .maxlen = sizeof(int),
303 .proc_handler = &proc_dointvec
306 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT,
307 .procname = "tcp_fin_timeout",
308 .data = &sysctl_tcp_fin_timeout,
309 .maxlen = sizeof(int),
311 .proc_handler = &proc_dointvec_jiffies,
312 .strategy = &sysctl_jiffies
314 #ifdef CONFIG_SYN_COOKIES
316 .ctl_name = NET_TCP_SYNCOOKIES,
317 .procname = "tcp_syncookies",
318 .data = &sysctl_tcp_syncookies,
319 .maxlen = sizeof(int),
321 .proc_handler = &proc_dointvec
325 .ctl_name = NET_TCP_TW_RECYCLE,
326 .procname = "tcp_tw_recycle",
327 .data = &sysctl_tcp_tw_recycle,
328 .maxlen = sizeof(int),
330 .proc_handler = &proc_dointvec
333 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW,
334 .procname = "tcp_abort_on_overflow",
335 .data = &sysctl_tcp_abort_on_overflow,
336 .maxlen = sizeof(int),
338 .proc_handler = &proc_dointvec
341 .ctl_name = NET_TCP_STDURG,
342 .procname = "tcp_stdurg",
343 .data = &sysctl_tcp_stdurg,
344 .maxlen = sizeof(int),
346 .proc_handler = &proc_dointvec
349 .ctl_name = NET_TCP_RFC1337,
350 .procname = "tcp_rfc1337",
351 .data = &sysctl_tcp_rfc1337,
352 .maxlen = sizeof(int),
354 .proc_handler = &proc_dointvec
357 .ctl_name = NET_TCP_MAX_SYN_BACKLOG,
358 .procname = "tcp_max_syn_backlog",
359 .data = &sysctl_max_syn_backlog,
360 .maxlen = sizeof(int),
362 .proc_handler = &proc_dointvec
365 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE,
366 .procname = "ip_local_port_range",
367 .data = &sysctl_local_port_range,
368 .maxlen = sizeof(sysctl_local_port_range),
370 .proc_handler = &proc_dointvec_minmax,
371 .strategy = &sysctl_intvec,
372 .extra1 = ip_local_port_range_min,
373 .extra2 = ip_local_port_range_max
376 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
377 .procname = "icmp_echo_ignore_all",
378 .data = &sysctl_icmp_echo_ignore_all,
379 .maxlen = sizeof(int),
381 .proc_handler = &proc_dointvec
384 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
385 .procname = "icmp_echo_ignore_broadcasts",
386 .data = &sysctl_icmp_echo_ignore_broadcasts,
387 .maxlen = sizeof(int),
389 .proc_handler = &proc_dointvec
392 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
393 .procname = "icmp_ignore_bogus_error_responses",
394 .data = &sysctl_icmp_ignore_bogus_error_responses,
395 .maxlen = sizeof(int),
397 .proc_handler = &proc_dointvec
400 .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
401 .procname = "icmp_errors_use_inbound_ifaddr",
402 .data = &sysctl_icmp_errors_use_inbound_ifaddr,
403 .maxlen = sizeof(int),
405 .proc_handler = &proc_dointvec
408 .ctl_name = NET_IPV4_ROUTE,
412 .child = ipv4_route_table
414 #ifdef CONFIG_IP_MULTICAST
416 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
417 .procname = "igmp_max_memberships",
418 .data = &sysctl_igmp_max_memberships,
419 .maxlen = sizeof(int),
421 .proc_handler = &proc_dointvec
426 .ctl_name = NET_IPV4_IGMP_MAX_MSF,
427 .procname = "igmp_max_msf",
428 .data = &sysctl_igmp_max_msf,
429 .maxlen = sizeof(int),
431 .proc_handler = &proc_dointvec
434 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD,
435 .procname = "inet_peer_threshold",
436 .data = &inet_peer_threshold,
437 .maxlen = sizeof(int),
439 .proc_handler = &proc_dointvec
442 .ctl_name = NET_IPV4_INET_PEER_MINTTL,
443 .procname = "inet_peer_minttl",
444 .data = &inet_peer_minttl,
445 .maxlen = sizeof(int),
447 .proc_handler = &proc_dointvec_jiffies,
448 .strategy = &sysctl_jiffies
451 .ctl_name = NET_IPV4_INET_PEER_MAXTTL,
452 .procname = "inet_peer_maxttl",
453 .data = &inet_peer_maxttl,
454 .maxlen = sizeof(int),
456 .proc_handler = &proc_dointvec_jiffies,
457 .strategy = &sysctl_jiffies
460 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME,
461 .procname = "inet_peer_gc_mintime",
462 .data = &inet_peer_gc_mintime,
463 .maxlen = sizeof(int),
465 .proc_handler = &proc_dointvec_jiffies,
466 .strategy = &sysctl_jiffies
469 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME,
470 .procname = "inet_peer_gc_maxtime",
471 .data = &inet_peer_gc_maxtime,
472 .maxlen = sizeof(int),
474 .proc_handler = &proc_dointvec_jiffies,
475 .strategy = &sysctl_jiffies
478 .ctl_name = NET_TCP_ORPHAN_RETRIES,
479 .procname = "tcp_orphan_retries",
480 .data = &sysctl_tcp_orphan_retries,
481 .maxlen = sizeof(int),
483 .proc_handler = &proc_dointvec
486 .ctl_name = NET_TCP_FACK,
487 .procname = "tcp_fack",
488 .data = &sysctl_tcp_fack,
489 .maxlen = sizeof(int),
491 .proc_handler = &proc_dointvec
494 .ctl_name = NET_TCP_REORDERING,
495 .procname = "tcp_reordering",
496 .data = &sysctl_tcp_reordering,
497 .maxlen = sizeof(int),
499 .proc_handler = &proc_dointvec
502 .ctl_name = NET_TCP_ECN,
503 .procname = "tcp_ecn",
504 .data = &sysctl_tcp_ecn,
505 .maxlen = sizeof(int),
507 .proc_handler = &proc_dointvec
510 .ctl_name = NET_TCP_DSACK,
511 .procname = "tcp_dsack",
512 .data = &sysctl_tcp_dsack,
513 .maxlen = sizeof(int),
515 .proc_handler = &proc_dointvec
518 .ctl_name = NET_TCP_MEM,
519 .procname = "tcp_mem",
520 .data = &sysctl_tcp_mem,
521 .maxlen = sizeof(sysctl_tcp_mem),
523 .proc_handler = &proc_dointvec
526 .ctl_name = NET_TCP_WMEM,
527 .procname = "tcp_wmem",
528 .data = &sysctl_tcp_wmem,
529 .maxlen = sizeof(sysctl_tcp_wmem),
531 .proc_handler = &proc_dointvec
534 .ctl_name = NET_TCP_RMEM,
535 .procname = "tcp_rmem",
536 .data = &sysctl_tcp_rmem,
537 .maxlen = sizeof(sysctl_tcp_rmem),
539 .proc_handler = &proc_dointvec
542 .ctl_name = NET_TCP_APP_WIN,
543 .procname = "tcp_app_win",
544 .data = &sysctl_tcp_app_win,
545 .maxlen = sizeof(int),
547 .proc_handler = &proc_dointvec
550 .ctl_name = NET_TCP_ADV_WIN_SCALE,
551 .procname = "tcp_adv_win_scale",
552 .data = &sysctl_tcp_adv_win_scale,
553 .maxlen = sizeof(int),
555 .proc_handler = &proc_dointvec
558 .ctl_name = NET_IPV4_ICMP_RATELIMIT,
559 .procname = "icmp_ratelimit",
560 .data = &sysctl_icmp_ratelimit,
561 .maxlen = sizeof(int),
563 .proc_handler = &proc_dointvec
566 .ctl_name = NET_IPV4_ICMP_RATEMASK,
567 .procname = "icmp_ratemask",
568 .data = &sysctl_icmp_ratemask,
569 .maxlen = sizeof(int),
571 .proc_handler = &proc_dointvec
574 .ctl_name = NET_TCP_TW_REUSE,
575 .procname = "tcp_tw_reuse",
576 .data = &sysctl_tcp_tw_reuse,
577 .maxlen = sizeof(int),
579 .proc_handler = &proc_dointvec
582 .ctl_name = NET_TCP_FRTO,
583 .procname = "tcp_frto",
584 .data = &sysctl_tcp_frto,
585 .maxlen = sizeof(int),
587 .proc_handler = &proc_dointvec
590 .ctl_name = NET_TCP_LOW_LATENCY,
591 .procname = "tcp_low_latency",
592 .data = &sysctl_tcp_low_latency,
593 .maxlen = sizeof(int),
595 .proc_handler = &proc_dointvec
598 .ctl_name = NET_IPV4_IPFRAG_SECRET_INTERVAL,
599 .procname = "ipfrag_secret_interval",
600 .data = &sysctl_ipfrag_secret_interval,
601 .maxlen = sizeof(int),
603 .proc_handler = &proc_dointvec_jiffies,
604 .strategy = &sysctl_jiffies
607 .ctl_name = NET_TCP_NO_METRICS_SAVE,
608 .procname = "tcp_no_metrics_save",
609 .data = &sysctl_tcp_nometrics_save,
610 .maxlen = sizeof(int),
612 .proc_handler = &proc_dointvec,
615 .ctl_name = NET_TCP_WESTWOOD,
616 .procname = "tcp_westwood",
617 .data = &sysctl_tcp_westwood,
618 .maxlen = sizeof(int),
620 .proc_handler = &proc_dointvec,
623 .ctl_name = NET_TCP_VEGAS,
624 .procname = "tcp_vegas_cong_avoid",
625 .data = &sysctl_tcp_vegas_cong_avoid,
626 .maxlen = sizeof(int),
628 .proc_handler = &proc_dointvec,
631 .ctl_name = NET_TCP_VEGAS_ALPHA,
632 .procname = "tcp_vegas_alpha",
633 .data = &sysctl_tcp_vegas_alpha,
634 .maxlen = sizeof(int),
636 .proc_handler = &proc_dointvec,
639 .ctl_name = NET_TCP_VEGAS_BETA,
640 .procname = "tcp_vegas_beta",
641 .data = &sysctl_tcp_vegas_beta,
642 .maxlen = sizeof(int),
644 .proc_handler = &proc_dointvec,
647 .ctl_name = NET_TCP_VEGAS_GAMMA,
648 .procname = "tcp_vegas_gamma",
649 .data = &sysctl_tcp_vegas_gamma,
650 .maxlen = sizeof(int),
652 .proc_handler = &proc_dointvec,
655 .ctl_name = NET_TCP_BIC,
656 .procname = "tcp_bic",
657 .data = &sysctl_tcp_bic,
658 .maxlen = sizeof(int),
660 .proc_handler = &proc_dointvec,
663 .ctl_name = NET_TCP_BIC_FAST_CONVERGENCE,
664 .procname = "tcp_bic_fast_convergence",
665 .data = &sysctl_tcp_bic_fast_convergence,
666 .maxlen = sizeof(int),
668 .proc_handler = &proc_dointvec,
671 .ctl_name = NET_TCP_BIC_LOW_WINDOW,
672 .procname = "tcp_bic_low_window",
673 .data = &sysctl_tcp_bic_low_window,
674 .maxlen = sizeof(int),
676 .proc_handler = &proc_dointvec,
679 .ctl_name = NET_TCP_MODERATE_RCVBUF,
680 .procname = "tcp_moderate_rcvbuf",
681 .data = &sysctl_tcp_moderate_rcvbuf,
682 .maxlen = sizeof(int),
684 .proc_handler = &proc_dointvec,
687 .ctl_name = NET_TCP_TSO_WIN_DIVISOR,
688 .procname = "tcp_tso_win_divisor",
689 .data = &sysctl_tcp_tso_win_divisor,
690 .maxlen = sizeof(int),
692 .proc_handler = &proc_dointvec,
695 .ctl_name = NET_TCP_BIC_BETA,
696 .procname = "tcp_bic_beta",
697 .data = &sysctl_tcp_bic_beta,
698 .maxlen = sizeof(int),
700 .proc_handler = &proc_dointvec,
705 #endif /* CONFIG_SYSCTL */
707 EXPORT_SYMBOL(ipv4_config);