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>
14 #include <linux/igmp.h>
18 #include <net/route.h>
22 extern int sysctl_ip_nonlocal_bind;
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 };
30 struct ipv4_config ipv4_config;
35 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
36 void __user *buffer, size_t *lenp, loff_t *ppos)
38 int val = ipv4_devconf.forwarding;
41 ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
43 if (write && ipv4_devconf.forwarding != val)
44 inet_forward_change();
49 static int ipv4_sysctl_forward_strategy(ctl_table *table,
50 int __user *name, int nlen,
51 void __user *oldval, size_t __user *oldlenp,
52 void __user *newval, size_t newlen,
55 int *valp = table->data;
58 if (!newval || !newlen)
61 if (newlen != sizeof(int))
64 if (get_user(new, (int __user *)newval))
70 if (oldval && oldlenp) {
73 if (get_user(len, oldlenp))
77 if (len > table->maxlen)
79 if (copy_to_user(oldval, valp, len))
81 if (put_user(len, oldlenp))
87 inet_forward_change();
91 static int proc_tcp_congestion_control(ctl_table *ctl, int write, struct file * filp,
92 void __user *buffer, size_t *lenp, loff_t *ppos)
94 char val[TCP_CA_NAME_MAX];
97 .maxlen = TCP_CA_NAME_MAX,
101 tcp_get_default_congestion_control(val);
103 ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
104 if (write && ret == 0)
105 ret = tcp_set_default_congestion_control(val);
109 static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
110 int nlen, void __user *oldval,
111 size_t __user *oldlenp,
112 void __user *newval, size_t newlen,
115 char val[TCP_CA_NAME_MAX];
118 .maxlen = TCP_CA_NAME_MAX,
122 tcp_get_default_congestion_control(val);
123 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen,
125 if (ret == 0 && newval && newlen)
126 ret = tcp_set_default_congestion_control(val);
131 ctl_table ipv4_table[] = {
133 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
134 .procname = "tcp_timestamps",
135 .data = &sysctl_tcp_timestamps,
136 .maxlen = sizeof(int),
138 .proc_handler = &proc_dointvec
141 .ctl_name = NET_IPV4_TCP_WINDOW_SCALING,
142 .procname = "tcp_window_scaling",
143 .data = &sysctl_tcp_window_scaling,
144 .maxlen = sizeof(int),
146 .proc_handler = &proc_dointvec
149 .ctl_name = NET_IPV4_TCP_SACK,
150 .procname = "tcp_sack",
151 .data = &sysctl_tcp_sack,
152 .maxlen = sizeof(int),
154 .proc_handler = &proc_dointvec
157 .ctl_name = NET_IPV4_TCP_RETRANS_COLLAPSE,
158 .procname = "tcp_retrans_collapse",
159 .data = &sysctl_tcp_retrans_collapse,
160 .maxlen = sizeof(int),
162 .proc_handler = &proc_dointvec
165 .ctl_name = NET_IPV4_FORWARD,
166 .procname = "ip_forward",
167 .data = &ipv4_devconf.forwarding,
168 .maxlen = sizeof(int),
170 .proc_handler = &ipv4_sysctl_forward,
171 .strategy = &ipv4_sysctl_forward_strategy
174 .ctl_name = NET_IPV4_DEFAULT_TTL,
175 .procname = "ip_default_ttl",
176 .data = &sysctl_ip_default_ttl,
177 .maxlen = sizeof(int),
179 .proc_handler = &ipv4_doint_and_flush,
180 .strategy = &ipv4_doint_and_flush_strategy,
183 .ctl_name = NET_IPV4_AUTOCONFIG,
184 .procname = "ip_autoconfig",
185 .data = &ipv4_config.autoconfig,
186 .maxlen = sizeof(int),
188 .proc_handler = &proc_dointvec
191 .ctl_name = NET_IPV4_NO_PMTU_DISC,
192 .procname = "ip_no_pmtu_disc",
193 .data = &ipv4_config.no_pmtu_disc,
194 .maxlen = sizeof(int),
196 .proc_handler = &proc_dointvec
199 .ctl_name = NET_IPV4_NONLOCAL_BIND,
200 .procname = "ip_nonlocal_bind",
201 .data = &sysctl_ip_nonlocal_bind,
202 .maxlen = sizeof(int),
204 .proc_handler = &proc_dointvec
207 .ctl_name = NET_IPV4_TCP_SYN_RETRIES,
208 .procname = "tcp_syn_retries",
209 .data = &sysctl_tcp_syn_retries,
210 .maxlen = sizeof(int),
212 .proc_handler = &proc_dointvec
215 .ctl_name = NET_TCP_SYNACK_RETRIES,
216 .procname = "tcp_synack_retries",
217 .data = &sysctl_tcp_synack_retries,
218 .maxlen = sizeof(int),
220 .proc_handler = &proc_dointvec
223 .ctl_name = NET_TCP_MAX_ORPHANS,
224 .procname = "tcp_max_orphans",
225 .data = &sysctl_tcp_max_orphans,
226 .maxlen = sizeof(int),
228 .proc_handler = &proc_dointvec
231 .ctl_name = NET_TCP_MAX_TW_BUCKETS,
232 .procname = "tcp_max_tw_buckets",
233 .data = &tcp_death_row.sysctl_max_tw_buckets,
234 .maxlen = sizeof(int),
236 .proc_handler = &proc_dointvec
239 .ctl_name = NET_IPV4_IPFRAG_HIGH_THRESH,
240 .procname = "ipfrag_high_thresh",
241 .data = &sysctl_ipfrag_high_thresh,
242 .maxlen = sizeof(int),
244 .proc_handler = &proc_dointvec
247 .ctl_name = NET_IPV4_IPFRAG_LOW_THRESH,
248 .procname = "ipfrag_low_thresh",
249 .data = &sysctl_ipfrag_low_thresh,
250 .maxlen = sizeof(int),
252 .proc_handler = &proc_dointvec
255 .ctl_name = NET_IPV4_DYNADDR,
256 .procname = "ip_dynaddr",
257 .data = &sysctl_ip_dynaddr,
258 .maxlen = sizeof(int),
260 .proc_handler = &proc_dointvec
263 .ctl_name = NET_IPV4_IPFRAG_TIME,
264 .procname = "ipfrag_time",
265 .data = &sysctl_ipfrag_time,
266 .maxlen = sizeof(int),
268 .proc_handler = &proc_dointvec_jiffies,
269 .strategy = &sysctl_jiffies
272 .ctl_name = NET_IPV4_TCP_KEEPALIVE_TIME,
273 .procname = "tcp_keepalive_time",
274 .data = &sysctl_tcp_keepalive_time,
275 .maxlen = sizeof(int),
277 .proc_handler = &proc_dointvec_jiffies,
278 .strategy = &sysctl_jiffies
281 .ctl_name = NET_IPV4_TCP_KEEPALIVE_PROBES,
282 .procname = "tcp_keepalive_probes",
283 .data = &sysctl_tcp_keepalive_probes,
284 .maxlen = sizeof(int),
286 .proc_handler = &proc_dointvec
289 .ctl_name = NET_IPV4_TCP_KEEPALIVE_INTVL,
290 .procname = "tcp_keepalive_intvl",
291 .data = &sysctl_tcp_keepalive_intvl,
292 .maxlen = sizeof(int),
294 .proc_handler = &proc_dointvec_jiffies,
295 .strategy = &sysctl_jiffies
298 .ctl_name = NET_IPV4_TCP_RETRIES1,
299 .procname = "tcp_retries1",
300 .data = &sysctl_tcp_retries1,
301 .maxlen = sizeof(int),
303 .proc_handler = &proc_dointvec_minmax,
304 .strategy = &sysctl_intvec,
305 .extra2 = &tcp_retr1_max
308 .ctl_name = NET_IPV4_TCP_RETRIES2,
309 .procname = "tcp_retries2",
310 .data = &sysctl_tcp_retries2,
311 .maxlen = sizeof(int),
313 .proc_handler = &proc_dointvec
316 .ctl_name = NET_IPV4_TCP_FIN_TIMEOUT,
317 .procname = "tcp_fin_timeout",
318 .data = &sysctl_tcp_fin_timeout,
319 .maxlen = sizeof(int),
321 .proc_handler = &proc_dointvec_jiffies,
322 .strategy = &sysctl_jiffies
324 #ifdef CONFIG_SYN_COOKIES
326 .ctl_name = NET_TCP_SYNCOOKIES,
327 .procname = "tcp_syncookies",
328 .data = &sysctl_tcp_syncookies,
329 .maxlen = sizeof(int),
331 .proc_handler = &proc_dointvec
335 .ctl_name = NET_TCP_TW_RECYCLE,
336 .procname = "tcp_tw_recycle",
337 .data = &tcp_death_row.sysctl_tw_recycle,
338 .maxlen = sizeof(int),
340 .proc_handler = &proc_dointvec
343 .ctl_name = NET_TCP_ABORT_ON_OVERFLOW,
344 .procname = "tcp_abort_on_overflow",
345 .data = &sysctl_tcp_abort_on_overflow,
346 .maxlen = sizeof(int),
348 .proc_handler = &proc_dointvec
351 .ctl_name = NET_TCP_STDURG,
352 .procname = "tcp_stdurg",
353 .data = &sysctl_tcp_stdurg,
354 .maxlen = sizeof(int),
356 .proc_handler = &proc_dointvec
359 .ctl_name = NET_TCP_RFC1337,
360 .procname = "tcp_rfc1337",
361 .data = &sysctl_tcp_rfc1337,
362 .maxlen = sizeof(int),
364 .proc_handler = &proc_dointvec
367 .ctl_name = NET_TCP_MAX_SYN_BACKLOG,
368 .procname = "tcp_max_syn_backlog",
369 .data = &sysctl_max_syn_backlog,
370 .maxlen = sizeof(int),
372 .proc_handler = &proc_dointvec
375 .ctl_name = NET_IPV4_LOCAL_PORT_RANGE,
376 .procname = "ip_local_port_range",
377 .data = &sysctl_local_port_range,
378 .maxlen = sizeof(sysctl_local_port_range),
380 .proc_handler = &proc_dointvec_minmax,
381 .strategy = &sysctl_intvec,
382 .extra1 = ip_local_port_range_min,
383 .extra2 = ip_local_port_range_max
386 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
387 .procname = "icmp_echo_ignore_all",
388 .data = &sysctl_icmp_echo_ignore_all,
389 .maxlen = sizeof(int),
391 .proc_handler = &proc_dointvec
394 .ctl_name = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
395 .procname = "icmp_echo_ignore_broadcasts",
396 .data = &sysctl_icmp_echo_ignore_broadcasts,
397 .maxlen = sizeof(int),
399 .proc_handler = &proc_dointvec
402 .ctl_name = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
403 .procname = "icmp_ignore_bogus_error_responses",
404 .data = &sysctl_icmp_ignore_bogus_error_responses,
405 .maxlen = sizeof(int),
407 .proc_handler = &proc_dointvec
410 .ctl_name = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
411 .procname = "icmp_errors_use_inbound_ifaddr",
412 .data = &sysctl_icmp_errors_use_inbound_ifaddr,
413 .maxlen = sizeof(int),
415 .proc_handler = &proc_dointvec
418 .ctl_name = NET_IPV4_ROUTE,
422 .child = ipv4_route_table
424 #ifdef CONFIG_IP_MULTICAST
426 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
427 .procname = "igmp_max_memberships",
428 .data = &sysctl_igmp_max_memberships,
429 .maxlen = sizeof(int),
431 .proc_handler = &proc_dointvec
436 .ctl_name = NET_IPV4_IGMP_MAX_MSF,
437 .procname = "igmp_max_msf",
438 .data = &sysctl_igmp_max_msf,
439 .maxlen = sizeof(int),
441 .proc_handler = &proc_dointvec
444 .ctl_name = NET_IPV4_INET_PEER_THRESHOLD,
445 .procname = "inet_peer_threshold",
446 .data = &inet_peer_threshold,
447 .maxlen = sizeof(int),
449 .proc_handler = &proc_dointvec
452 .ctl_name = NET_IPV4_INET_PEER_MINTTL,
453 .procname = "inet_peer_minttl",
454 .data = &inet_peer_minttl,
455 .maxlen = sizeof(int),
457 .proc_handler = &proc_dointvec_jiffies,
458 .strategy = &sysctl_jiffies
461 .ctl_name = NET_IPV4_INET_PEER_MAXTTL,
462 .procname = "inet_peer_maxttl",
463 .data = &inet_peer_maxttl,
464 .maxlen = sizeof(int),
466 .proc_handler = &proc_dointvec_jiffies,
467 .strategy = &sysctl_jiffies
470 .ctl_name = NET_IPV4_INET_PEER_GC_MINTIME,
471 .procname = "inet_peer_gc_mintime",
472 .data = &inet_peer_gc_mintime,
473 .maxlen = sizeof(int),
475 .proc_handler = &proc_dointvec_jiffies,
476 .strategy = &sysctl_jiffies
479 .ctl_name = NET_IPV4_INET_PEER_GC_MAXTIME,
480 .procname = "inet_peer_gc_maxtime",
481 .data = &inet_peer_gc_maxtime,
482 .maxlen = sizeof(int),
484 .proc_handler = &proc_dointvec_jiffies,
485 .strategy = &sysctl_jiffies
488 .ctl_name = NET_TCP_ORPHAN_RETRIES,
489 .procname = "tcp_orphan_retries",
490 .data = &sysctl_tcp_orphan_retries,
491 .maxlen = sizeof(int),
493 .proc_handler = &proc_dointvec
496 .ctl_name = NET_TCP_FACK,
497 .procname = "tcp_fack",
498 .data = &sysctl_tcp_fack,
499 .maxlen = sizeof(int),
501 .proc_handler = &proc_dointvec
504 .ctl_name = NET_TCP_REORDERING,
505 .procname = "tcp_reordering",
506 .data = &sysctl_tcp_reordering,
507 .maxlen = sizeof(int),
509 .proc_handler = &proc_dointvec
512 .ctl_name = NET_TCP_ECN,
513 .procname = "tcp_ecn",
514 .data = &sysctl_tcp_ecn,
515 .maxlen = sizeof(int),
517 .proc_handler = &proc_dointvec
520 .ctl_name = NET_TCP_DSACK,
521 .procname = "tcp_dsack",
522 .data = &sysctl_tcp_dsack,
523 .maxlen = sizeof(int),
525 .proc_handler = &proc_dointvec
528 .ctl_name = NET_TCP_MEM,
529 .procname = "tcp_mem",
530 .data = &sysctl_tcp_mem,
531 .maxlen = sizeof(sysctl_tcp_mem),
533 .proc_handler = &proc_dointvec
536 .ctl_name = NET_TCP_WMEM,
537 .procname = "tcp_wmem",
538 .data = &sysctl_tcp_wmem,
539 .maxlen = sizeof(sysctl_tcp_wmem),
541 .proc_handler = &proc_dointvec
544 .ctl_name = NET_TCP_RMEM,
545 .procname = "tcp_rmem",
546 .data = &sysctl_tcp_rmem,
547 .maxlen = sizeof(sysctl_tcp_rmem),
549 .proc_handler = &proc_dointvec
552 .ctl_name = NET_TCP_APP_WIN,
553 .procname = "tcp_app_win",
554 .data = &sysctl_tcp_app_win,
555 .maxlen = sizeof(int),
557 .proc_handler = &proc_dointvec
560 .ctl_name = NET_TCP_ADV_WIN_SCALE,
561 .procname = "tcp_adv_win_scale",
562 .data = &sysctl_tcp_adv_win_scale,
563 .maxlen = sizeof(int),
565 .proc_handler = &proc_dointvec
568 .ctl_name = NET_IPV4_ICMP_RATELIMIT,
569 .procname = "icmp_ratelimit",
570 .data = &sysctl_icmp_ratelimit,
571 .maxlen = sizeof(int),
573 .proc_handler = &proc_dointvec
576 .ctl_name = NET_IPV4_ICMP_RATEMASK,
577 .procname = "icmp_ratemask",
578 .data = &sysctl_icmp_ratemask,
579 .maxlen = sizeof(int),
581 .proc_handler = &proc_dointvec
584 .ctl_name = NET_TCP_TW_REUSE,
585 .procname = "tcp_tw_reuse",
586 .data = &sysctl_tcp_tw_reuse,
587 .maxlen = sizeof(int),
589 .proc_handler = &proc_dointvec
592 .ctl_name = NET_TCP_FRTO,
593 .procname = "tcp_frto",
594 .data = &sysctl_tcp_frto,
595 .maxlen = sizeof(int),
597 .proc_handler = &proc_dointvec
600 .ctl_name = NET_TCP_LOW_LATENCY,
601 .procname = "tcp_low_latency",
602 .data = &sysctl_tcp_low_latency,
603 .maxlen = sizeof(int),
605 .proc_handler = &proc_dointvec
608 .ctl_name = NET_IPV4_IPFRAG_SECRET_INTERVAL,
609 .procname = "ipfrag_secret_interval",
610 .data = &sysctl_ipfrag_secret_interval,
611 .maxlen = sizeof(int),
613 .proc_handler = &proc_dointvec_jiffies,
614 .strategy = &sysctl_jiffies
617 .ctl_name = NET_TCP_NO_METRICS_SAVE,
618 .procname = "tcp_no_metrics_save",
619 .data = &sysctl_tcp_nometrics_save,
620 .maxlen = sizeof(int),
622 .proc_handler = &proc_dointvec,
625 .ctl_name = NET_TCP_MODERATE_RCVBUF,
626 .procname = "tcp_moderate_rcvbuf",
627 .data = &sysctl_tcp_moderate_rcvbuf,
628 .maxlen = sizeof(int),
630 .proc_handler = &proc_dointvec,
633 .ctl_name = NET_TCP_TSO_WIN_DIVISOR,
634 .procname = "tcp_tso_win_divisor",
635 .data = &sysctl_tcp_tso_win_divisor,
636 .maxlen = sizeof(int),
638 .proc_handler = &proc_dointvec,
641 .ctl_name = NET_TCP_CONG_CONTROL,
642 .procname = "tcp_congestion_control",
644 .maxlen = TCP_CA_NAME_MAX,
645 .proc_handler = &proc_tcp_congestion_control,
646 .strategy = &sysctl_tcp_congestion_control,
652 #endif /* CONFIG_SYSCTL */
654 EXPORT_SYMBOL(ipv4_config);