Changes for kernel and Busybox
[tomato.git] / release / src / linux / linux / net / ipv4 / sysctl_net_ipv4.c
blob66f0e177f953bb564a4cca44857a1f6343a5530b
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/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>
18 /* From af_inet.c */
19 extern int sysctl_ip_nonlocal_bind;
21 /* From icmp.c */
22 extern int sysctl_icmp_echo_ignore_all;
23 extern int sysctl_icmp_echo_ignore_broadcasts;
24 extern int sysctl_icmp_ignore_bogus_error_responses;
26 /* From ip_fragment.c */
27 extern int sysctl_ipfrag_low_thresh;
28 extern int sysctl_ipfrag_high_thresh;
29 extern int sysctl_ipfrag_time;
30 extern int sysctl_ipfrag_secret_interval;
32 /* From ip_output.c */
33 extern int sysctl_ip_dynaddr;
35 /* From icmp.c */
36 extern int sysctl_icmp_ratelimit;
37 extern int sysctl_icmp_ratemask;
39 /* From igmp.c */
40 extern int sysctl_igmp_max_memberships;
41 extern int sysctl_igmp_max_msf;
43 /* From inetpeer.c */
44 extern int inet_peer_threshold;
45 extern int inet_peer_minttl;
46 extern int inet_peer_maxttl;
47 extern int inet_peer_gc_mintime;
48 extern int inet_peer_gc_maxtime;
50 #ifdef CONFIG_SYSCTL
51 static int tcp_retr1_max = 255;
52 static int ip_local_port_range_min[] = { 1, 1 };
53 static int ip_local_port_range_max[] = { 65535, 65535 };
54 #endif
56 /* From tcp_input.c */
57 extern int sysctl_tcp_westwood;
59 struct ipv4_config ipv4_config;
61 extern ctl_table ipv4_route_table[];
63 #ifdef CONFIG_SYSCTL
65 static
66 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
67 void *buffer, size_t *lenp)
69 int val = ipv4_devconf.forwarding;
70 int ret;
72 ret = proc_dointvec(ctl, write, filp, buffer, lenp);
74 if (write && ipv4_devconf.forwarding != val)
75 inet_forward_change(ipv4_devconf.forwarding);
77 return ret;
80 static int ipv4_sysctl_forward_strategy(ctl_table *table, int *name, int nlen,
81 void *oldval, size_t *oldlenp,
82 void *newval, size_t newlen,
83 void **context)
85 int new;
86 if (newlen != sizeof(int))
87 return -EINVAL;
88 if (get_user(new,(int *)newval))
89 return -EFAULT;
90 if (new != ipv4_devconf.forwarding)
91 inet_forward_change(new);
92 return 0; /* caller does change again and handles handles oldval */
95 ctl_table ipv4_table[] = {
96 {NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps",
97 &sysctl_tcp_timestamps, sizeof(int), 0644, NULL,
98 &proc_dointvec},
99 {NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling",
100 &sysctl_tcp_window_scaling, sizeof(int), 0644, NULL,
101 &proc_dointvec},
102 {NET_IPV4_TCP_SACK, "tcp_sack",
103 &sysctl_tcp_sack, sizeof(int), 0644, NULL,
104 &proc_dointvec},
105 {NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse",
106 &sysctl_tcp_retrans_collapse, sizeof(int), 0644, NULL,
107 &proc_dointvec},
108 {NET_IPV4_FORWARD, "ip_forward",
109 &ipv4_devconf.forwarding, sizeof(int), 0644, NULL,
110 &ipv4_sysctl_forward,&ipv4_sysctl_forward_strategy},
111 {NET_IPV4_DEFAULT_TTL, "ip_default_ttl",
112 &sysctl_ip_default_ttl, sizeof(int), 0644, NULL,
113 &proc_dointvec},
114 {NET_IPV4_AUTOCONFIG, "ip_autoconfig",
115 &ipv4_config.autoconfig, sizeof(int), 0644, NULL,
116 &proc_dointvec},
117 {NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc",
118 &ipv4_config.no_pmtu_disc, sizeof(int), 0644, NULL,
119 &proc_dointvec},
120 {NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind",
121 &sysctl_ip_nonlocal_bind, sizeof(int), 0644, NULL,
122 &proc_dointvec},
123 {NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries",
124 &sysctl_tcp_syn_retries, sizeof(int), 0644, NULL, &proc_dointvec},
125 {NET_TCP_SYNACK_RETRIES, "tcp_synack_retries",
126 &sysctl_tcp_synack_retries, sizeof(int), 0644, NULL, &proc_dointvec},
127 {NET_TCP_MAX_ORPHANS, "tcp_max_orphans",
128 &sysctl_tcp_max_orphans, sizeof(int), 0644, NULL, &proc_dointvec},
129 {NET_TCP_MAX_TW_BUCKETS, "tcp_max_tw_buckets",
130 &sysctl_tcp_max_tw_buckets, sizeof(int), 0644, NULL, &proc_dointvec},
131 {NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh",
132 &sysctl_ipfrag_high_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
133 {NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh",
134 &sysctl_ipfrag_low_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
135 {NET_IPV4_DYNADDR, "ip_dynaddr",
136 &sysctl_ip_dynaddr, sizeof(int), 0644, NULL, &proc_dointvec},
137 {NET_IPV4_IPFRAG_TIME, "ipfrag_time",
138 &sysctl_ipfrag_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies,
139 &sysctl_jiffies},
140 {NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time",
141 &sysctl_tcp_keepalive_time, sizeof(int), 0644, NULL,
142 &proc_dointvec_jiffies, &sysctl_jiffies},
143 {NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes",
144 &sysctl_tcp_keepalive_probes, sizeof(int), 0644, NULL,
145 &proc_dointvec},
146 {NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl",
147 &sysctl_tcp_keepalive_intvl, sizeof(int), 0644, NULL,
148 &proc_dointvec_jiffies, &sysctl_jiffies},
149 {NET_IPV4_TCP_RETRIES1, "tcp_retries1",
150 &sysctl_tcp_retries1, sizeof(int), 0644, NULL, &proc_dointvec_minmax,
151 &sysctl_intvec, NULL, NULL, &tcp_retr1_max},
152 {NET_IPV4_TCP_RETRIES2, "tcp_retries2",
153 &sysctl_tcp_retries2, sizeof(int), 0644, NULL, &proc_dointvec},
154 {NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout",
155 &sysctl_tcp_fin_timeout, sizeof(int), 0644, NULL,
156 &proc_dointvec_jiffies, &sysctl_jiffies},
157 #ifdef CONFIG_SYN_COOKIES
158 {NET_TCP_SYNCOOKIES, "tcp_syncookies",
159 &sysctl_tcp_syncookies, sizeof(int), 0644, NULL, &proc_dointvec},
160 #endif
161 {NET_TCP_TW_RECYCLE, "tcp_tw_recycle",
162 &sysctl_tcp_tw_recycle, sizeof(int), 0644, NULL, &proc_dointvec},
163 {NET_TCP_ABORT_ON_OVERFLOW, "tcp_abort_on_overflow",
164 &sysctl_tcp_abort_on_overflow, sizeof(int), 0644, NULL, &proc_dointvec},
165 {NET_TCP_STDURG, "tcp_stdurg", &sysctl_tcp_stdurg,
166 sizeof(int), 0644, NULL, &proc_dointvec},
167 {NET_TCP_RFC1337, "tcp_rfc1337", &sysctl_tcp_rfc1337,
168 sizeof(int), 0644, NULL, &proc_dointvec},
169 {NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog", &sysctl_max_syn_backlog,
170 sizeof(int), 0644, NULL, &proc_dointvec},
171 {NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range",
172 &sysctl_local_port_range, sizeof(sysctl_local_port_range), 0644,
173 NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL,
174 ip_local_port_range_min, ip_local_port_range_max },
175 {NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all",
176 &sysctl_icmp_echo_ignore_all, sizeof(int), 0644, NULL,
177 &proc_dointvec},
178 {NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts",
179 &sysctl_icmp_echo_ignore_broadcasts, sizeof(int), 0644, NULL,
180 &proc_dointvec},
181 {NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses",
182 &sysctl_icmp_ignore_bogus_error_responses, sizeof(int), 0644, NULL,
183 &proc_dointvec},
184 {NET_IPV4_ROUTE, "route", NULL, 0, 0555, ipv4_route_table},
185 #ifdef CONFIG_IP_MULTICAST
186 {NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships",
187 &sysctl_igmp_max_memberships, sizeof(int), 0644, NULL, &proc_dointvec},
188 #endif
189 {NET_IPV4_IGMP_MAX_MSF, "igmp_max_msf",
190 &sysctl_igmp_max_msf, sizeof(int), 0644, NULL, &proc_dointvec},
191 {NET_IPV4_INET_PEER_THRESHOLD, "inet_peer_threshold",
192 &inet_peer_threshold, sizeof(int), 0644, NULL, &proc_dointvec},
193 {NET_IPV4_INET_PEER_MINTTL, "inet_peer_minttl",
194 &inet_peer_minttl, sizeof(int), 0644, NULL,
195 &proc_dointvec_jiffies, &sysctl_jiffies},
196 {NET_IPV4_INET_PEER_MAXTTL, "inet_peer_maxttl",
197 &inet_peer_maxttl, sizeof(int), 0644, NULL,
198 &proc_dointvec_jiffies, &sysctl_jiffies},
199 {NET_IPV4_INET_PEER_GC_MINTIME, "inet_peer_gc_mintime",
200 &inet_peer_gc_mintime, sizeof(int), 0644, NULL,
201 &proc_dointvec_jiffies, &sysctl_jiffies},
202 {NET_IPV4_INET_PEER_GC_MAXTIME, "inet_peer_gc_maxtime",
203 &inet_peer_gc_maxtime, sizeof(int), 0644, NULL,
204 &proc_dointvec_jiffies, &sysctl_jiffies},
205 {NET_TCP_ORPHAN_RETRIES, "tcp_orphan_retries",
206 &sysctl_tcp_orphan_retries, sizeof(int), 0644, NULL, &proc_dointvec},
207 {NET_TCP_FACK, "tcp_fack",
208 &sysctl_tcp_fack, sizeof(int), 0644, NULL, &proc_dointvec},
209 {NET_TCP_REORDERING, "tcp_reordering",
210 &sysctl_tcp_reordering, sizeof(int), 0644, NULL, &proc_dointvec},
211 {NET_TCP_ECN, "tcp_ecn",
212 &sysctl_tcp_ecn, sizeof(int), 0644, NULL, &proc_dointvec},
213 {NET_TCP_DSACK, "tcp_dsack",
214 &sysctl_tcp_dsack, sizeof(int), 0644, NULL, &proc_dointvec},
215 {NET_TCP_MEM, "tcp_mem",
216 &sysctl_tcp_mem, sizeof(sysctl_tcp_mem), 0644, NULL, &proc_dointvec},
217 {NET_TCP_WMEM, "tcp_wmem",
218 &sysctl_tcp_wmem, sizeof(sysctl_tcp_wmem), 0644, NULL, &proc_dointvec},
219 {NET_TCP_RMEM, "tcp_rmem",
220 &sysctl_tcp_rmem, sizeof(sysctl_tcp_rmem), 0644, NULL, &proc_dointvec},
221 {NET_TCP_APP_WIN, "tcp_app_win",
222 &sysctl_tcp_app_win, sizeof(int), 0644, NULL, &proc_dointvec},
223 {NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale",
224 &sysctl_tcp_adv_win_scale, sizeof(int), 0644, NULL, &proc_dointvec},
225 {NET_IPV4_ICMP_RATELIMIT, "icmp_ratelimit",
226 &sysctl_icmp_ratelimit, sizeof(int), 0644, NULL, &proc_dointvec},
227 {NET_IPV4_ICMP_RATEMASK, "icmp_ratemask",
228 &sysctl_icmp_ratemask, sizeof(int), 0644, NULL, &proc_dointvec},
229 {NET_IPV4_IPFRAG_SECRET_INTERVAL, "ipfrag_secret_interval",
230 &sysctl_ipfrag_secret_interval, sizeof(int), 0644, NULL, &proc_dointvec_jiffies,
231 &sysctl_jiffies},
232 {NET_TCP_TW_REUSE, "tcp_tw_reuse",
233 &sysctl_tcp_tw_reuse, sizeof(int), 0644, NULL, &proc_dointvec},
234 {NET_TCP_FRTO, "tcp_frto",
235 &sysctl_tcp_frto, sizeof(int), 0644, NULL, &proc_dointvec},
236 {NET_TCP_LOW_LATENCY, "tcp_low_latency",
237 &sysctl_tcp_low_latency, sizeof(int), 0644, NULL, &proc_dointvec},
238 {NET_IPV4_IPFRAG_SECRET_INTERVAL, "ipfrag_secret_interval",
239 &sysctl_ipfrag_secret_interval, sizeof(int), 0644, NULL, &proc_dointvec_jiffies,
240 &sysctl_jiffies},
241 {NET_TCP_WESTWOOD, "tcp_westwood",
242 &sysctl_tcp_westwood, sizeof(int), 0644, NULL,
243 &proc_dointvec},
244 {NET_TCP_NO_METRICS_SAVE, "tcp_no_metrics_save",
245 &sysctl_tcp_nometrics_save, sizeof(int), 0644, NULL,
246 &proc_dointvec},
247 {NET_TCP_VEGAS, "tcp_vegas_cong_avoid",
248 &sysctl_tcp_vegas_cong_avoid, sizeof(int), 0644, NULL,
249 &proc_dointvec},
250 {NET_TCP_VEGAS_ALPHA, "tcp_vegas_alpha",
251 &sysctl_tcp_vegas_alpha, sizeof(int), 0644, NULL,
252 &proc_dointvec},
253 {NET_TCP_VEGAS_BETA, "tcp_vegas_beta",
254 &sysctl_tcp_vegas_beta, sizeof(int), 0644, NULL,
255 &proc_dointvec},
256 {NET_TCP_VEGAS_GAMMA, "tcp_vegas_gamma",
257 &sysctl_tcp_vegas_gamma, sizeof(int), 0644, NULL,
258 &proc_dointvec},
259 {NET_TCP_BIC, "tcp_bic",
260 &sysctl_tcp_bic, sizeof(int), 0644, NULL,
261 &proc_dointvec},
262 {NET_TCP_BIC_FAST_CONVERGENCE, "tcp_bic_fast_convergence",
263 &sysctl_tcp_bic_fast_convergence, sizeof(int), 0644, NULL,
264 &proc_dointvec},
265 {NET_TCP_BIC_LOW_WINDOW, "tcp_bic_low_window",
266 &sysctl_tcp_bic_low_window, sizeof(int), 0644, NULL,
267 &proc_dointvec},
268 {NET_TCP_DEFAULT_WIN_SCALE, "tcp_default_win_scale",
269 &sysctl_tcp_default_win_scale, sizeof(int), 0644, NULL,
270 &proc_dointvec},
271 {NET_TCP_MODERATE_RCVBUF, "tcp_moderate_rcvbuf",
272 &sysctl_tcp_moderate_rcvbuf, sizeof(int), 0644, NULL,
273 &proc_dointvec},
274 {NET_TCP_BIC_BETA, "tcp_bic_beta",
275 &sysctl_tcp_bic_beta, sizeof(int), 0644, NULL,
276 &proc_dointvec},
280 #endif /* CONFIG_SYSCTL */