[PATCH] w1: Userspace communication protocol over connector.
[linux-2.6/verdex.git] / net / ipv4 / sysctl_net_ipv4.c
blobce4cd5f355116e2d0d30e96aff51a2f6f2c0e90f
1 /*
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]
8 */
10 #include <linux/mm.h>
11 #include <linux/module.h>
12 #include <linux/sysctl.h>
13 #include <linux/config.h>
14 #include <linux/igmp.h>
15 #include <linux/inetdevice.h>
16 #include <net/snmp.h>
17 #include <net/icmp.h>
18 #include <net/ip.h>
19 #include <net/route.h>
20 #include <net/tcp.h>
22 /* From af_inet.c */
23 extern int sysctl_ip_nonlocal_bind;
25 #ifdef CONFIG_SYSCTL
26 static int zero;
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 };
30 #endif
32 struct ipv4_config ipv4_config;
34 #ifdef CONFIG_SYSCTL
36 static
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;
41 int ret;
43 ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
45 if (write && ipv4_devconf.forwarding != val)
46 inet_forward_change();
48 return ret;
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,
55 void **context)
57 int *valp = table->data;
58 int new;
60 if (!newval || !newlen)
61 return 0;
63 if (newlen != sizeof(int))
64 return -EINVAL;
66 if (get_user(new, (int __user *)newval))
67 return -EFAULT;
69 if (new == *valp)
70 return 0;
72 if (oldval && oldlenp) {
73 size_t len;
75 if (get_user(len, oldlenp))
76 return -EFAULT;
78 if (len) {
79 if (len > table->maxlen)
80 len = table->maxlen;
81 if (copy_to_user(oldval, valp, len))
82 return -EFAULT;
83 if (put_user(len, oldlenp))
84 return -EFAULT;
88 *valp = new;
89 inet_forward_change();
90 return 1;
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];
97 ctl_table tbl = {
98 .data = val,
99 .maxlen = TCP_CA_NAME_MAX,
101 int ret;
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);
108 return ret;
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,
115 void **context)
117 char val[TCP_CA_NAME_MAX];
118 ctl_table tbl = {
119 .data = val,
120 .maxlen = TCP_CA_NAME_MAX,
122 int ret;
124 tcp_get_default_congestion_control(val);
125 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen,
126 context);
127 if (ret == 0 && newval && newlen)
128 ret = tcp_set_default_congestion_control(val);
129 return ret;
133 ctl_table ipv4_table[] = {
135 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
136 .procname = "tcp_timestamps",
137 .data = &sysctl_tcp_timestamps,
138 .maxlen = sizeof(int),
139 .mode = 0644,
140 .proc_handler = &proc_dointvec
143 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING,
144 .procname = "tcp_window_scaling",
145 .data = &sysctl_tcp_window_scaling,
146 .maxlen = sizeof(int),
147 .mode = 0644,
148 .proc_handler = &proc_dointvec
151 .ctl_name = NET_IPV4_TCP_SACK,
152 .procname = "tcp_sack",
153 .data = &sysctl_tcp_sack,
154 .maxlen = sizeof(int),
155 .mode = 0644,
156 .proc_handler = &proc_dointvec
159 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE,
160 .procname = "tcp_retrans_collapse",
161 .data = &sysctl_tcp_retrans_collapse,
162 .maxlen = sizeof(int),
163 .mode = 0644,
164 .proc_handler = &proc_dointvec
167 .ctl_name = NET_IPV4_FORWARD,
168 .procname = "ip_forward",
169 .data = &ipv4_devconf.forwarding,
170 .maxlen = sizeof(int),
171 .mode = 0644,
172 .proc_handler = &ipv4_sysctl_forward,
173 .strategy = &ipv4_sysctl_forward_strategy
176 .ctl_name = NET_IPV4_DEFAULT_TTL,
177 .procname = "ip_default_ttl",
178 .data = &sysctl_ip_default_ttl,
179 .maxlen = sizeof(int),
180 .mode = 0644,
181 .proc_handler = &ipv4_doint_and_flush,
182 .strategy = &ipv4_doint_and_flush_strategy,
185 .ctl_name = NET_IPV4_NO_PMTU_DISC,
186 .procname = "ip_no_pmtu_disc",
187 .data = &ipv4_config.no_pmtu_disc,
188 .maxlen = sizeof(int),
189 .mode = 0644,
190 .proc_handler = &proc_dointvec
193 .ctl_name = NET_IPV4_NONLOCAL_BIND,
194 .procname = "ip_nonlocal_bind",
195 .data = &sysctl_ip_nonlocal_bind,
196 .maxlen = sizeof(int),
197 .mode = 0644,
198 .proc_handler = &proc_dointvec
201 .ctl_name = NET_IPV4_TCP_SYN_RETRIES,
202 .procname = "tcp_syn_retries",
203 .data = &sysctl_tcp_syn_retries,
204 .maxlen = sizeof(int),
205 .mode = 0644,
206 .proc_handler = &proc_dointvec
209 .ctl_name = NET_TCP_SYNACK_RETRIES,
210 .procname = "tcp_synack_retries",
211 .data = &sysctl_tcp_synack_retries,
212 .maxlen = sizeof(int),
213 .mode = 0644,
214 .proc_handler = &proc_dointvec
217 .ctl_name = NET_TCP_MAX_ORPHANS,
218 .procname = "tcp_max_orphans",
219 .data = &sysctl_tcp_max_orphans,
220 .maxlen = sizeof(int),
221 .mode = 0644,
222 .proc_handler = &proc_dointvec
225 .ctl_name = NET_TCP_MAX_TW_BUCKETS,
226 .procname = "tcp_max_tw_buckets",
227 .data = &tcp_death_row.sysctl_max_tw_buckets,
228 .maxlen = sizeof(int),
229 .mode = 0644,
230 .proc_handler = &proc_dointvec
233 .ctl_name = NET_IPV4_IPFRAG_HIGH_THRESH,
234 .procname = "ipfrag_high_thresh",
235 .data = &sysctl_ipfrag_high_thresh,
236 .maxlen = sizeof(int),
237 .mode = 0644,
238 .proc_handler = &proc_dointvec
241 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH,
242 .procname = "ipfrag_low_thresh",
243 .data = &sysctl_ipfrag_low_thresh,
244 .maxlen = sizeof(int),
245 .mode = 0644,
246 .proc_handler = &proc_dointvec
249 .ctl_name = NET_IPV4_DYNADDR,
250 .procname = "ip_dynaddr",
251 .data = &sysctl_ip_dynaddr,
252 .maxlen = sizeof(int),
253 .mode = 0644,
254 .proc_handler = &proc_dointvec
257 .ctl_name = NET_IPV4_IPFRAG_TIME,
258 .procname = "ipfrag_time",
259 .data = &sysctl_ipfrag_time,
260 .maxlen = sizeof(int),
261 .mode = 0644,
262 .proc_handler = &proc_dointvec_jiffies,
263 .strategy = &sysctl_jiffies
266 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME,
267 .procname = "tcp_keepalive_time",
268 .data = &sysctl_tcp_keepalive_time,
269 .maxlen = sizeof(int),
270 .mode = 0644,
271 .proc_handler = &proc_dointvec_jiffies,
272 .strategy = &sysctl_jiffies
275 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES,
276 .procname = "tcp_keepalive_probes",
277 .data = &sysctl_tcp_keepalive_probes,
278 .maxlen = sizeof(int),
279 .mode = 0644,
280 .proc_handler = &proc_dointvec
283 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL,
284 .procname = "tcp_keepalive_intvl",
285 .data = &sysctl_tcp_keepalive_intvl,
286 .maxlen = sizeof(int),
287 .mode = 0644,
288 .proc_handler = &proc_dointvec_jiffies,
289 .strategy = &sysctl_jiffies
292 .ctl_name = NET_IPV4_TCP_RETRIES1,
293 .procname = "tcp_retries1",
294 .data = &sysctl_tcp_retries1,
295 .maxlen = sizeof(int),
296 .mode = 0644,
297 .proc_handler = &proc_dointvec_minmax,
298 .strategy = &sysctl_intvec,
299 .extra2 = &tcp_retr1_max
302 .ctl_name = NET_IPV4_TCP_RETRIES2,
303 .procname = "tcp_retries2",
304 .data = &sysctl_tcp_retries2,
305 .maxlen = sizeof(int),
306 .mode = 0644,
307 .proc_handler = &proc_dointvec
310 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT,
311 .procname = "tcp_fin_timeout",
312 .data = &sysctl_tcp_fin_timeout,
313 .maxlen = sizeof(int),
314 .mode = 0644,
315 .proc_handler = &proc_dointvec_jiffies,
316 .strategy = &sysctl_jiffies
318 #ifdef CONFIG_SYN_COOKIES
320 .ctl_name = NET_TCP_SYNCOOKIES,
321 .procname = "tcp_syncookies",
322 .data = &sysctl_tcp_syncookies,
323 .maxlen = sizeof(int),
324 .mode = 0644,
325 .proc_handler = &proc_dointvec
327 #endif
329 .ctl_name = NET_TCP_TW_RECYCLE,
330 .procname = "tcp_tw_recycle",
331 .data = &tcp_death_row.sysctl_tw_recycle,
332 .maxlen = sizeof(int),
333 .mode = 0644,
334 .proc_handler = &proc_dointvec
337 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW,
338 .procname = "tcp_abort_on_overflow",
339 .data = &sysctl_tcp_abort_on_overflow,
340 .maxlen = sizeof(int),
341 .mode = 0644,
342 .proc_handler = &proc_dointvec
345 .ctl_name = NET_TCP_STDURG,
346 .procname = "tcp_stdurg",
347 .data = &sysctl_tcp_stdurg,
348 .maxlen = sizeof(int),
349 .mode = 0644,
350 .proc_handler = &proc_dointvec
353 .ctl_name = NET_TCP_RFC1337,
354 .procname = "tcp_rfc1337",
355 .data = &sysctl_tcp_rfc1337,
356 .maxlen = sizeof(int),
357 .mode = 0644,
358 .proc_handler = &proc_dointvec
361 .ctl_name = NET_TCP_MAX_SYN_BACKLOG,
362 .procname = "tcp_max_syn_backlog",
363 .data = &sysctl_max_syn_backlog,
364 .maxlen = sizeof(int),
365 .mode = 0644,
366 .proc_handler = &proc_dointvec
369 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE,
370 .procname = "ip_local_port_range",
371 .data = &sysctl_local_port_range,
372 .maxlen = sizeof(sysctl_local_port_range),
373 .mode = 0644,
374 .proc_handler = &proc_dointvec_minmax,
375 .strategy = &sysctl_intvec,
376 .extra1 = ip_local_port_range_min,
377 .extra2 = ip_local_port_range_max
380 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
381 .procname = "icmp_echo_ignore_all",
382 .data = &sysctl_icmp_echo_ignore_all,
383 .maxlen = sizeof(int),
384 .mode = 0644,
385 .proc_handler = &proc_dointvec
388 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
389 .procname = "icmp_echo_ignore_broadcasts",
390 .data = &sysctl_icmp_echo_ignore_broadcasts,
391 .maxlen = sizeof(int),
392 .mode = 0644,
393 .proc_handler = &proc_dointvec
396 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
397 .procname = "icmp_ignore_bogus_error_responses",
398 .data = &sysctl_icmp_ignore_bogus_error_responses,
399 .maxlen = sizeof(int),
400 .mode = 0644,
401 .proc_handler = &proc_dointvec
404 .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
405 .procname = "icmp_errors_use_inbound_ifaddr",
406 .data = &sysctl_icmp_errors_use_inbound_ifaddr,
407 .maxlen = sizeof(int),
408 .mode = 0644,
409 .proc_handler = &proc_dointvec
412 .ctl_name = NET_IPV4_ROUTE,
413 .procname = "route",
414 .maxlen = 0,
415 .mode = 0555,
416 .child = ipv4_route_table
418 #ifdef CONFIG_IP_MULTICAST
420 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
421 .procname = "igmp_max_memberships",
422 .data = &sysctl_igmp_max_memberships,
423 .maxlen = sizeof(int),
424 .mode = 0644,
425 .proc_handler = &proc_dointvec
428 #endif
430 .ctl_name = NET_IPV4_IGMP_MAX_MSF,
431 .procname = "igmp_max_msf",
432 .data = &sysctl_igmp_max_msf,
433 .maxlen = sizeof(int),
434 .mode = 0644,
435 .proc_handler = &proc_dointvec
438 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD,
439 .procname = "inet_peer_threshold",
440 .data = &inet_peer_threshold,
441 .maxlen = sizeof(int),
442 .mode = 0644,
443 .proc_handler = &proc_dointvec
446 .ctl_name = NET_IPV4_INET_PEER_MINTTL,
447 .procname = "inet_peer_minttl",
448 .data = &inet_peer_minttl,
449 .maxlen = sizeof(int),
450 .mode = 0644,
451 .proc_handler = &proc_dointvec_jiffies,
452 .strategy = &sysctl_jiffies
455 .ctl_name = NET_IPV4_INET_PEER_MAXTTL,
456 .procname = "inet_peer_maxttl",
457 .data = &inet_peer_maxttl,
458 .maxlen = sizeof(int),
459 .mode = 0644,
460 .proc_handler = &proc_dointvec_jiffies,
461 .strategy = &sysctl_jiffies
464 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME,
465 .procname = "inet_peer_gc_mintime",
466 .data = &inet_peer_gc_mintime,
467 .maxlen = sizeof(int),
468 .mode = 0644,
469 .proc_handler = &proc_dointvec_jiffies,
470 .strategy = &sysctl_jiffies
473 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME,
474 .procname = "inet_peer_gc_maxtime",
475 .data = &inet_peer_gc_maxtime,
476 .maxlen = sizeof(int),
477 .mode = 0644,
478 .proc_handler = &proc_dointvec_jiffies,
479 .strategy = &sysctl_jiffies
482 .ctl_name = NET_TCP_ORPHAN_RETRIES,
483 .procname = "tcp_orphan_retries",
484 .data = &sysctl_tcp_orphan_retries,
485 .maxlen = sizeof(int),
486 .mode = 0644,
487 .proc_handler = &proc_dointvec
490 .ctl_name = NET_TCP_FACK,
491 .procname = "tcp_fack",
492 .data = &sysctl_tcp_fack,
493 .maxlen = sizeof(int),
494 .mode = 0644,
495 .proc_handler = &proc_dointvec
498 .ctl_name = NET_TCP_REORDERING,
499 .procname = "tcp_reordering",
500 .data = &sysctl_tcp_reordering,
501 .maxlen = sizeof(int),
502 .mode = 0644,
503 .proc_handler = &proc_dointvec
506 .ctl_name = NET_TCP_ECN,
507 .procname = "tcp_ecn",
508 .data = &sysctl_tcp_ecn,
509 .maxlen = sizeof(int),
510 .mode = 0644,
511 .proc_handler = &proc_dointvec
514 .ctl_name = NET_TCP_DSACK,
515 .procname = "tcp_dsack",
516 .data = &sysctl_tcp_dsack,
517 .maxlen = sizeof(int),
518 .mode = 0644,
519 .proc_handler = &proc_dointvec
522 .ctl_name = NET_TCP_MEM,
523 .procname = "tcp_mem",
524 .data = &sysctl_tcp_mem,
525 .maxlen = sizeof(sysctl_tcp_mem),
526 .mode = 0644,
527 .proc_handler = &proc_dointvec
530 .ctl_name = NET_TCP_WMEM,
531 .procname = "tcp_wmem",
532 .data = &sysctl_tcp_wmem,
533 .maxlen = sizeof(sysctl_tcp_wmem),
534 .mode = 0644,
535 .proc_handler = &proc_dointvec
538 .ctl_name = NET_TCP_RMEM,
539 .procname = "tcp_rmem",
540 .data = &sysctl_tcp_rmem,
541 .maxlen = sizeof(sysctl_tcp_rmem),
542 .mode = 0644,
543 .proc_handler = &proc_dointvec
546 .ctl_name = NET_TCP_APP_WIN,
547 .procname = "tcp_app_win",
548 .data = &sysctl_tcp_app_win,
549 .maxlen = sizeof(int),
550 .mode = 0644,
551 .proc_handler = &proc_dointvec
554 .ctl_name = NET_TCP_ADV_WIN_SCALE,
555 .procname = "tcp_adv_win_scale",
556 .data = &sysctl_tcp_adv_win_scale,
557 .maxlen = sizeof(int),
558 .mode = 0644,
559 .proc_handler = &proc_dointvec
562 .ctl_name = NET_IPV4_ICMP_RATELIMIT,
563 .procname = "icmp_ratelimit",
564 .data = &sysctl_icmp_ratelimit,
565 .maxlen = sizeof(int),
566 .mode = 0644,
567 .proc_handler = &proc_dointvec
570 .ctl_name = NET_IPV4_ICMP_RATEMASK,
571 .procname = "icmp_ratemask",
572 .data = &sysctl_icmp_ratemask,
573 .maxlen = sizeof(int),
574 .mode = 0644,
575 .proc_handler = &proc_dointvec
578 .ctl_name = NET_TCP_TW_REUSE,
579 .procname = "tcp_tw_reuse",
580 .data = &sysctl_tcp_tw_reuse,
581 .maxlen = sizeof(int),
582 .mode = 0644,
583 .proc_handler = &proc_dointvec
586 .ctl_name = NET_TCP_FRTO,
587 .procname = "tcp_frto",
588 .data = &sysctl_tcp_frto,
589 .maxlen = sizeof(int),
590 .mode = 0644,
591 .proc_handler = &proc_dointvec
594 .ctl_name = NET_TCP_LOW_LATENCY,
595 .procname = "tcp_low_latency",
596 .data = &sysctl_tcp_low_latency,
597 .maxlen = sizeof(int),
598 .mode = 0644,
599 .proc_handler = &proc_dointvec
602 .ctl_name = NET_IPV4_IPFRAG_SECRET_INTERVAL,
603 .procname = "ipfrag_secret_interval",
604 .data = &sysctl_ipfrag_secret_interval,
605 .maxlen = sizeof(int),
606 .mode = 0644,
607 .proc_handler = &proc_dointvec_jiffies,
608 .strategy = &sysctl_jiffies
611 .ctl_name = NET_IPV4_IPFRAG_MAX_DIST,
612 .procname = "ipfrag_max_dist",
613 .data = &sysctl_ipfrag_max_dist,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 .proc_handler = &proc_dointvec_minmax,
617 .extra1 = &zero
620 .ctl_name = NET_TCP_NO_METRICS_SAVE,
621 .procname = "tcp_no_metrics_save",
622 .data = &sysctl_tcp_nometrics_save,
623 .maxlen = sizeof(int),
624 .mode = 0644,
625 .proc_handler = &proc_dointvec,
628 .ctl_name = NET_TCP_MODERATE_RCVBUF,
629 .procname = "tcp_moderate_rcvbuf",
630 .data = &sysctl_tcp_moderate_rcvbuf,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 .proc_handler = &proc_dointvec,
636 .ctl_name = NET_TCP_TSO_WIN_DIVISOR,
637 .procname = "tcp_tso_win_divisor",
638 .data = &sysctl_tcp_tso_win_divisor,
639 .maxlen = sizeof(int),
640 .mode = 0644,
641 .proc_handler = &proc_dointvec,
644 .ctl_name = NET_TCP_CONG_CONTROL,
645 .procname = "tcp_congestion_control",
646 .mode = 0644,
647 .maxlen = TCP_CA_NAME_MAX,
648 .proc_handler = &proc_tcp_congestion_control,
649 .strategy = &sysctl_tcp_congestion_control,
652 .ctl_name = NET_TCP_ABC,
653 .procname = "tcp_abc",
654 .data = &sysctl_tcp_abc,
655 .maxlen = sizeof(int),
656 .mode = 0644,
657 .proc_handler = &proc_dointvec,
660 .ctl_name = NET_TCP_MTU_PROBING,
661 .procname = "tcp_mtu_probing",
662 .data = &sysctl_tcp_mtu_probing,
663 .maxlen = sizeof(int),
664 .mode = 0644,
665 .proc_handler = &proc_dointvec,
668 .ctl_name = NET_TCP_BASE_MSS,
669 .procname = "tcp_base_mss",
670 .data = &sysctl_tcp_base_mss,
671 .maxlen = sizeof(int),
672 .mode = 0644,
673 .proc_handler = &proc_dointvec,
676 .ctl_name = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
677 .procname = "tcp_workaround_signed_windows",
678 .data = &sysctl_tcp_workaround_signed_windows,
679 .maxlen = sizeof(int),
680 .mode = 0644,
681 .proc_handler = &proc_dointvec
683 #ifdef CONFIG_NET_DMA
685 .ctl_name = NET_TCP_DMA_COPYBREAK,
686 .procname = "tcp_dma_copybreak",
687 .data = &sysctl_tcp_dma_copybreak,
688 .maxlen = sizeof(int),
689 .mode = 0644,
690 .proc_handler = &proc_dointvec
692 #endif
694 .ctl_name = NET_TCP_SLOW_START_AFTER_IDLE,
695 .procname = "tcp_slow_start_after_idle",
696 .data = &sysctl_tcp_slow_start_after_idle,
697 .maxlen = sizeof(int),
698 .mode = 0644,
699 .proc_handler = &proc_dointvec
701 { .ctl_name = 0 }
704 #endif /* CONFIG_SYSCTL */
706 EXPORT_SYMBOL(ipv4_config);