1 /*
2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
3 *
4 * $Id: sysctl_net_ipv4.c,v 1.47 2000/10/19 15:51:02 davem Exp $
5 *
6 * Begun April 1, 1996, Mike Shaver.
7 * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
8 */
9
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>
17
18 /* From af_inet.c */
19 extern int sysctl_ip_nonlocal_bind;
20
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;
25
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
31 /* From ip_output.c */
32 extern int sysctl_ip_dynaddr;
33
34 /* From icmp.c */
35 extern int sysctl_icmp_destunreach_time;
36 extern int sysctl_icmp_timeexceed_time;
37 extern int sysctl_icmp_paramprob_time;
38 extern int sysctl_icmp_echoreply_time;
39
40 /* From igmp.c */
41 extern int sysctl_igmp_max_memberships;
42
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;
49
50 static int tcp_retr1_max = 255;
51
52 static int ip_local_port_range_min[] = { 1, 1 };
53 static int ip_local_port_range_max[] = { 65535, 65535 };
54
55 struct ipv4_config ipv4_config;
56
57 extern ctl_table ipv4_route_table[];
58
59 #ifdef CONFIG_SYSCTL
60
61 static
62 int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
63 void *buffer, size_t *lenp)
64 {
65 int val = ipv4_devconf.forwarding;
66 int ret;
67
68 ret = proc_dointvec(ctl, write, filp, buffer, lenp);
69
70 if (write && ipv4_devconf.forwarding != val)
71 inet_forward_change();
72
73 return ret;
74 }
75
76 static int ipv4_sysctl_forward_strategy(ctl_table *table, int *name, int nlen,
77 void *oldval, size_t *oldlenp,
78 void *newval, size_t newlen,
79 void **context)
80 {
81 int new;
82 if (newlen != sizeof(int))
83 return -EINVAL;
84 if (get_user(new,(int *)newval))
85 return -EFAULT;
86 if (new != ipv4_devconf.forwarding)
87 inet_forward_change();
88 return 0; /* caller does change again and handles handles oldval */
89 }
90
91 ctl_table ipv4_table[] = {
92 {NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps",
93 &sysctl_tcp_timestamps, sizeof(int), 0644, NULL,
94 &proc_dointvec},
95 {NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling",
96 &sysctl_tcp_window_scaling, sizeof(int), 0644, NULL,
97 &proc_dointvec},
98 {NET_IPV4_TCP_SACK, "tcp_sack",
99 &sysctl_tcp_sack, sizeof(int), 0644, NULL,
100 &proc_dointvec},
101 {NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse",
102 &sysctl_tcp_retrans_collapse, sizeof(int), 0644, NULL,
103 &proc_dointvec},
104 {NET_IPV4_FORWARD, "ip_forward",
105 &ipv4_devconf.forwarding, sizeof(int), 0644, NULL,
106 &ipv4_sysctl_forward,&ipv4_sysctl_forward_strategy},
107 {NET_IPV4_DEFAULT_TTL, "ip_default_ttl",
108 &sysctl_ip_default_ttl, sizeof(int), 0644, NULL,
109 &proc_dointvec},
110 {NET_IPV4_AUTOCONFIG, "ip_autoconfig",
111 &ipv4_config.autoconfig, sizeof(int), 0644, NULL,
112 &proc_dointvec},
113 {NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc",
114 &ipv4_config.no_pmtu_disc, sizeof(int), 0644, NULL,
115 &proc_dointvec},
116 {NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind",
117 &sysctl_ip_nonlocal_bind, sizeof(int), 0644, NULL,
118 &proc_dointvec},
119 {NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries",
120 &sysctl_tcp_syn_retries, sizeof(int), 0644, NULL, &proc_dointvec},
121 {NET_TCP_SYNACK_RETRIES, "tcp_synack_retries",
122 &sysctl_tcp_synack_retries, sizeof(int), 0644, NULL, &proc_dointvec},
123 {NET_TCP_MAX_ORPHANS, "tcp_max_orphans",
124 &sysctl_tcp_max_orphans, sizeof(int), 0644, NULL, &proc_dointvec},
125 {NET_TCP_MAX_TW_BUCKETS, "tcp_max_tw_buckets",
126 &sysctl_tcp_max_tw_buckets, sizeof(int), 0644, NULL, &proc_dointvec},
127 {NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh",
128 &sysctl_ipfrag_high_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
129 {NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh",
130 &sysctl_ipfrag_low_thresh, sizeof(int), 0644, NULL, &proc_dointvec},
131 {NET_IPV4_DYNADDR, "ip_dynaddr",
132 &sysctl_ip_dynaddr, sizeof(int), 0644, NULL, &proc_dointvec},
133 {NET_IPV4_IPFRAG_TIME, "ipfrag_time",
134 &sysctl_ipfrag_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies,
135 &sysctl_jiffies},
136 {NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time",
137 &sysctl_tcp_keepalive_time, sizeof(int), 0644, NULL,
138 &proc_dointvec_jiffies, &sysctl_jiffies},
139 {NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes",
140 &sysctl_tcp_keepalive_probes, sizeof(int), 0644, NULL,
141 &proc_dointvec},
142 {NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl",
143 &sysctl_tcp_keepalive_intvl, sizeof(int), 0644, NULL,
144 &proc_dointvec_jiffies, &sysctl_jiffies},
145 {NET_IPV4_TCP_RETRIES1, "tcp_retries1",
146 &sysctl_tcp_retries1, sizeof(int), 0644, NULL, &proc_dointvec_minmax,
147 &sysctl_intvec, NULL, NULL, &tcp_retr1_max},
148 {NET_IPV4_TCP_RETRIES2, "tcp_retries2",
149 &sysctl_tcp_retries2, sizeof(int), 0644, NULL, &proc_dointvec},
150 {NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout",
151 &sysctl_tcp_fin_timeout, sizeof(int), 0644, NULL,
152 &proc_dointvec_jiffies, &sysctl_jiffies},
153 #ifdef CONFIG_SYN_COOKIES
154 {NET_TCP_SYNCOOKIES, "tcp_syncookies",
155 &sysctl_tcp_syncookies, sizeof(int), 0644, NULL, &proc_dointvec},
156 #endif
157 {NET_TCP_TW_RECYCLE, "tcp_tw_recycle",
158 &sysctl_tcp_tw_recycle, sizeof(int), 0644, NULL, &proc_dointvec},
159 {NET_TCP_ABORT_ON_OVERFLOW, "tcp_abort_on_overflow",
160 &sysctl_tcp_abort_on_overflow, sizeof(int), 0644, NULL, &proc_dointvec},
161 {NET_TCP_STDURG, "tcp_stdurg", &sysctl_tcp_stdurg,
162 sizeof(int), 0644, NULL, &proc_dointvec},
163 {NET_TCP_RFC1337, "tcp_rfc1337", &sysctl_tcp_rfc1337,
164 sizeof(int), 0644, NULL, &proc_dointvec},
165 {NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog", &sysctl_max_syn_backlog,
166 sizeof(int), 0644, NULL, &proc_dointvec},
167 {NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range",
168 &sysctl_local_port_range, sizeof(sysctl_local_port_range), 0644,
169 NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL,
170 ip_local_port_range_min, ip_local_port_range_max },
171 {NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all",
172 &sysctl_icmp_echo_ignore_all, sizeof(int), 0644, NULL,
173 &proc_dointvec},
174 {NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts",
175 &sysctl_icmp_echo_ignore_broadcasts, sizeof(int), 0644, NULL,
176 &proc_dointvec},
177 {NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses",
178 &sysctl_icmp_ignore_bogus_error_responses, sizeof(int), 0644, NULL,
179 &proc_dointvec},
180 {NET_IPV4_ICMP_DESTUNREACH_RATE, "icmp_destunreach_rate",
181 &sysctl_icmp_destunreach_time, sizeof(int), 0644, NULL, &proc_dointvec},
182 {NET_IPV4_ICMP_TIMEEXCEED_RATE, "icmp_timeexceed_rate",
183 &sysctl_icmp_timeexceed_time, sizeof(int), 0644, NULL, &proc_dointvec},
184 {NET_IPV4_ICMP_PARAMPROB_RATE, "icmp_paramprob_rate",
185 &sysctl_icmp_paramprob_time, sizeof(int), 0644, NULL, &proc_dointvec},
186 {NET_IPV4_ICMP_ECHOREPLY_RATE, "icmp_echoreply_rate",
187 &sysctl_icmp_echoreply_time, sizeof(int), 0644, NULL, &proc_dointvec},
188 {NET_IPV4_ROUTE, "route", NULL, 0, 0555, ipv4_route_table},
189 #ifdef CONFIG_IP_MULTICAST
190 {NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships",
191 &sysctl_igmp_max_memberships, sizeof(int), 0644, NULL, &proc_dointvec},
192 #endif
193 {NET_IPV4_INET_PEER_THRESHOLD, "inet_peer_threshold",
194 &inet_peer_threshold, sizeof(int), 0644, NULL, &proc_dointvec},
195 {NET_IPV4_INET_PEER_MINTTL, "inet_peer_minttl",
196 &inet_peer_minttl, sizeof(int), 0644, NULL,
197 &proc_dointvec_jiffies, &sysctl_jiffies},
198 {NET_IPV4_INET_PEER_MAXTTL, "inet_peer_maxttl",
199 &inet_peer_maxttl, sizeof(int), 0644, NULL,
200 &proc_dointvec_jiffies, &sysctl_jiffies},
201 {NET_IPV4_INET_PEER_GC_MINTIME, "inet_peer_gc_mintime",
202 &inet_peer_gc_mintime, sizeof(int), 0644, NULL,
203 &proc_dointvec_jiffies, &sysctl_jiffies},
204 {NET_IPV4_INET_PEER_GC_MAXTIME, "inet_peer_gc_maxtime",
205 &inet_peer_gc_maxtime, sizeof(int), 0644, NULL,
206 &proc_dointvec_jiffies, &sysctl_jiffies},
207 {NET_TCP_ORPHAN_RETRIES, "tcp_orphan_retries",
208 &sysctl_tcp_orphan_retries, sizeof(int), 0644, NULL, &proc_dointvec},
209 {NET_TCP_FACK, "tcp_fack",
210 &sysctl_tcp_fack, sizeof(int), 0644, NULL, &proc_dointvec},
211 {NET_TCP_REORDERING, "tcp_reordering",
212 &sysctl_tcp_reordering, sizeof(int), 0644, NULL, &proc_dointvec},
213 #ifdef CONFIG_INET_ECN
214 {NET_TCP_ECN, "tcp_ecn",
215 &sysctl_tcp_ecn, sizeof(int), 0644, NULL, &proc_dointvec},
216 #endif
217 {NET_TCP_DSACK, "tcp_dsack",
218 &sysctl_tcp_dsack, sizeof(int), 0644, NULL, &proc_dointvec},
219 {NET_TCP_MEM, "tcp_mem",
220 &sysctl_tcp_mem, sizeof(sysctl_tcp_mem), 0644, NULL, &proc_dointvec},
221 {NET_TCP_WMEM, "tcp_wmem",
222 &sysctl_tcp_wmem, sizeof(sysctl_tcp_wmem), 0644, NULL, &proc_dointvec},
223 {NET_TCP_RMEM, "tcp_rmem",
224 &sysctl_tcp_rmem, sizeof(sysctl_tcp_rmem), 0644, NULL, &proc_dointvec},
225 {NET_TCP_APP_WIN, "tcp_app_win",
226 &sysctl_tcp_app_win, sizeof(int), 0644, NULL, &proc_dointvec},
227 {NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale",
228 &sysctl_tcp_adv_win_scale, sizeof(int), 0644, NULL, &proc_dointvec},
229 {0}
230 };
231
232 #endif /* CONFIG_SYSCTL */
233
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.