Import 2.3.18pre1
[davej-history.git] / net / ipv4 / sysctl_net_ipv4.c
blob1ff1566af21e6a987b5ae95e380b60dd0a589e09
1 /*
2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4 * $Id: sysctl_net_ipv4.c,v 1.40 1999/09/07 02:31:17 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/sysctl.h>
12 #include <linux/config.h>
13 #include <net/snmp.h>
14 #include <net/ip.h>
15 #include <net/route.h>
16 #include <net/tcp.h>
19 * TCP configuration parameters
22 #define TCP_PMTU_DISC 0x00000001 /* perform PMTU discovery */
23 #define TCP_CONG_AVOID 0x00000002 /* congestion avoidance algorithm */
24 #define TCP_DELAY_ACKS 0x00000003 /* delayed ack stategy */
26 #if 0
27 static int boolean_min = 0;
28 static int boolean_max = 1;
29 #endif
31 /* From icmp.c */
32 extern int sysctl_icmp_echo_ignore_all;
33 extern int sysctl_icmp_echo_ignore_broadcasts;
34 extern int sysctl_icmp_ignore_bogus_error_responses;
36 /* From ip_fragment.c */
37 extern int sysctl_ipfrag_low_thresh;
38 extern int sysctl_ipfrag_high_thresh;
39 extern int sysctl_ipfrag_time;
41 /* From ip_output.c */
42 extern int sysctl_ip_dynaddr;
44 /* From ip_masq.c */
45 extern int sysctl_ip_masq_debug;
47 extern int sysctl_tcp_timestamps;
48 extern int sysctl_tcp_window_scaling;
49 extern int sysctl_tcp_sack;
50 extern int sysctl_tcp_retrans_collapse;
51 extern int sysctl_tcp_keepalive_time;
52 extern int sysctl_tcp_keepalive_probes;
53 extern int sysctl_tcp_retries1;
54 extern int sysctl_tcp_retries2;
55 extern int sysctl_tcp_fin_timeout;
56 extern int sysctl_tcp_syncookies;
57 extern int sysctl_tcp_syn_retries;
58 extern int sysctl_tcp_stdurg;
59 extern int sysctl_tcp_rfc1337;
60 extern int sysctl_tcp_syn_taildrop;
61 extern int sysctl_max_syn_backlog;
62 extern int sysctl_tcp_tw_recycle;
64 /* From icmp.c */
65 extern int sysctl_icmp_destunreach_time;
66 extern int sysctl_icmp_timeexceed_time;
67 extern int sysctl_icmp_paramprob_time;
68 extern int sysctl_icmp_echoreply_time;
70 /* From igmp.c */
71 extern int sysctl_igmp_max_memberships;
73 int tcp_retr1_max = 255;
75 struct ipv4_config ipv4_config;
77 extern ctl_table ipv4_route_table[];
79 #ifdef CONFIG_SYSCTL
81 static
82 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
83 void *buffer, size_t *lenp)
85 int val = ipv4_devconf.forwarding;
86 int ret;
88 ret = proc_dointvec(ctl, write, filp, buffer, lenp);
90 if (write && ipv4_devconf.forwarding != val)
91 inet_forward_change();
93 return ret;
96 static int ipv4_sysctl_forward_strategy(ctl_table *table, int *name, int nlen,
97 void *oldval, size_t *oldlenp,
98 void *newval, size_t newlen,
99 void **context)
101 int new;
102 if (newlen != sizeof(int))
103 return -EINVAL;
104 if (get_user(new,(int *)newval))
105 return -EFAULT;
106 if (new != ipv4_devconf.forwarding)
107 inet_forward_change();
108 return 0; /* caller does change again and handles handles oldval */
111 ctl_table ipv4_table[] = {
112 {NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps",
113 &sysctl_tcp_timestamps, sizeof(int), 0644, NULL,
114 &proc_dointvec},
115 {NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling",
116 &sysctl_tcp_window_scaling, sizeof(int), 0644, NULL,
117 &proc_dointvec},
118 {NET_IPV4_TCP_SACK, "tcp_sack",
119 &sysctl_tcp_sack, sizeof(int), 0644, NULL,
120 &proc_dointvec},
121 {NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse",
122 &sysctl_tcp_retrans_collapse, sizeof(int), 0644, NULL,
123 &proc_dointvec},
124 {NET_IPV4_FORWARD, "ip_forward",
125 &ipv4_devconf.forwarding, sizeof(int), 0644, NULL,
126 &ipv4_sysctl_forward,&ipv4_sysctl_forward_strategy},
127 {NET_IPV4_DEFAULT_TTL, "ip_default_ttl",
128 &ip_statistics.IpDefaultTTL, sizeof(int), 0644, NULL,
129 &proc_dointvec},
130 {NET_IPV4_AUTOCONFIG, "ip_autoconfig",
131 &ipv4_config.autoconfig, sizeof(int), 0644, NULL,
132 &proc_dointvec},
133 {NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc",
134 &ipv4_config.no_pmtu_disc, sizeof(int), 0644, NULL,
135 &proc_dointvec},
136 {NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries",
137 &sysctl_tcp_syn_retries, sizeof(int), 0644, NULL, &proc_dointvec},
138 {NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh",
139 &sysctl_ipfrag_high_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
140 {NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh",
141 &sysctl_ipfrag_low_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
142 {NET_IPV4_DYNADDR, "ip_dynaddr",
143 &sysctl_ip_dynaddr, sizeof(int), 0644, NULL, &proc_dointvec},
144 {NET_IPV4_IPFRAG_TIME, "ipfrag_time",
145 &sysctl_ipfrag_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies,
146 &sysctl_jiffies},
147 {NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time",
148 &sysctl_tcp_keepalive_time, sizeof(int), 0644, NULL,
149 &proc_dointvec_jiffies, &sysctl_jiffies},
150 {NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes",
151 &sysctl_tcp_keepalive_probes, sizeof(int), 0644, NULL,
152 &proc_dointvec},
153 {NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl",
154 &sysctl_tcp_keepalive_intvl, sizeof(int), 0644, NULL,
155 &proc_dointvec_jiffies, &sysctl_jiffies},
156 {NET_IPV4_TCP_RETRIES1, "tcp_retries1",
157 &sysctl_tcp_retries1, sizeof(int), 0644, NULL, &proc_dointvec_minmax,
158 &sysctl_intvec, NULL, NULL, &tcp_retr1_max},
159 {NET_IPV4_TCP_RETRIES2, "tcp_retries2",
160 &sysctl_tcp_retries2, sizeof(int), 0644, NULL, &proc_dointvec},
161 {NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout",
162 &sysctl_tcp_fin_timeout, sizeof(int), 0644, NULL,
163 &proc_dointvec_jiffies, &sysctl_jiffies},
164 #ifdef CONFIG_SYN_COOKIES
165 {NET_TCP_SYNCOOKIES, "tcp_syncookies",
166 &sysctl_tcp_syncookies, sizeof(int), 0644, NULL, &proc_dointvec},
167 #endif
168 #ifdef CONFIG_TCP_TW_RECYCLE
169 {NET_TCP_TW_RECYCLE, "tcp_tw_recycle",
170 &sysctl_tcp_tw_recycle, sizeof(int), 0644, NULL, &proc_dointvec},
171 #endif
172 {NET_TCP_STDURG, "tcp_stdurg", &sysctl_tcp_stdurg,
173 sizeof(int), 0644, NULL, &proc_dointvec},
174 {NET_TCP_RFC1337, "tcp_rfc1337", &sysctl_tcp_rfc1337,
175 sizeof(int), 0644, NULL, &proc_dointvec},
176 {NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog", &sysctl_max_syn_backlog,
177 sizeof(int), 0644, NULL, &proc_dointvec},
178 {NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range",
179 &sysctl_local_port_range, sizeof(sysctl_local_port_range), 0644,
180 NULL, &proc_dointvec},
181 {NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all",
182 &sysctl_icmp_echo_ignore_all, sizeof(int), 0644, NULL,
183 &proc_dointvec},
184 {NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts",
185 &sysctl_icmp_echo_ignore_broadcasts, sizeof(int), 0644, NULL,
186 &proc_dointvec},
187 {NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses",
188 &sysctl_icmp_ignore_bogus_error_responses, sizeof(int), 0644, NULL,
189 &proc_dointvec},
190 {NET_IPV4_ICMP_DESTUNREACH_RATE, "icmp_destunreach_rate",
191 &sysctl_icmp_destunreach_time, sizeof(int), 0644, NULL, &proc_dointvec},
192 {NET_IPV4_ICMP_TIMEEXCEED_RATE, "icmp_timeexceed_rate",
193 &sysctl_icmp_timeexceed_time, sizeof(int), 0644, NULL, &proc_dointvec},
194 {NET_IPV4_ICMP_PARAMPROB_RATE, "icmp_paramprob_rate",
195 &sysctl_icmp_paramprob_time, sizeof(int), 0644, NULL, &proc_dointvec},
196 {NET_IPV4_ICMP_ECHOREPLY_RATE, "icmp_echoreply_rate",
197 &sysctl_icmp_echoreply_time, sizeof(int), 0644, NULL, &proc_dointvec},
198 {NET_IPV4_ROUTE, "route", NULL, 0, 0555, ipv4_route_table},
199 #ifdef CONFIG_IP_MULTICAST
200 {NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships",
201 &sysctl_igmp_max_memberships, sizeof(int), 0644, NULL, &proc_dointvec},
202 #endif
206 #endif /* CONFIG_SYSCTL */