]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem. | |
3 | * | |
1da177e4 LT |
4 | * Begun April 1, 1996, Mike Shaver. |
5 | * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS] | |
6 | */ | |
7 | ||
8 | #include <linux/mm.h> | |
9 | #include <linux/module.h> | |
10 | #include <linux/sysctl.h> | |
20380731 | 11 | #include <linux/igmp.h> |
14c85021 | 12 | #include <linux/inetdevice.h> |
227b60f5 | 13 | #include <linux/seqlock.h> |
3e37c3f9 | 14 | #include <linux/init.h> |
5a0e3ad6 | 15 | #include <linux/slab.h> |
c319b4d7 | 16 | #include <linux/nsproxy.h> |
3dc43e3e | 17 | #include <linux/swap.h> |
1da177e4 | 18 | #include <net/snmp.h> |
20380731 | 19 | #include <net/icmp.h> |
1da177e4 LT |
20 | #include <net/ip.h> |
21 | #include <net/route.h> | |
22 | #include <net/tcp.h> | |
95766fff | 23 | #include <net/udp.h> |
446fda4f | 24 | #include <net/cipso_ipv4.h> |
04128f23 | 25 | #include <net/inet_frag.h> |
c319b4d7 | 26 | #include <net/ping.h> |
dddb64bc | 27 | #include <net/protocol.h> |
1da177e4 | 28 | |
89cee8b1 | 29 | static int zero; |
cdda8891 | 30 | static int one = 1; |
6ba8a3b1 | 31 | static int four = 4; |
43e122b0 | 32 | static int thousand = 1000; |
95bd09eb | 33 | static int gso_max_segs = GSO_MAX_SEGS; |
e905a9ed | 34 | static int tcp_retr1_max = 255; |
1da177e4 LT |
35 | static int ip_local_port_range_min[] = { 1, 1 }; |
36 | static int ip_local_port_range_max[] = { 65535, 65535 }; | |
0147fc05 AD |
37 | static int tcp_adv_win_scale_min = -31; |
38 | static int tcp_adv_win_scale_max = 31; | |
4548b683 KJ |
39 | static int ip_privileged_port_min; |
40 | static int ip_privileged_port_max = 65535; | |
249fab77 ED |
41 | static int ip_ttl_min = 1; |
42 | static int ip_ttl_max = 255; | |
651e9271 MT |
43 | static int tcp_syn_retries_min = 1; |
44 | static int tcp_syn_retries_max = MAX_TCP_SYNCNT; | |
c319b4d7 VK |
45 | static int ip_ping_group_range_min[] = { 0, 0 }; |
46 | static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; | |
1da177e4 | 47 | |
b6690b14 FW |
48 | /* obsolete */ |
49 | static int sysctl_tcp_low_latency __read_mostly; | |
50 | ||
227b60f5 | 51 | /* Update system visible IP port range */ |
0bbf87d8 | 52 | static void set_local_port_range(struct net *net, int range[2]) |
227b60f5 | 53 | { |
ed2dfd90 ED |
54 | bool same_parity = !((range[0] ^ range[1]) & 1); |
55 | ||
4ee3bd4a | 56 | write_seqlock_bh(&net->ipv4.ip_local_ports.lock); |
ed2dfd90 ED |
57 | if (same_parity && !net->ipv4.ip_local_ports.warned) { |
58 | net->ipv4.ip_local_ports.warned = true; | |
59 | pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n"); | |
60 | } | |
c9d8f1a6 CW |
61 | net->ipv4.ip_local_ports.range[0] = range[0]; |
62 | net->ipv4.ip_local_ports.range[1] = range[1]; | |
4ee3bd4a | 63 | write_sequnlock_bh(&net->ipv4.ip_local_ports.lock); |
227b60f5 SH |
64 | } |
65 | ||
66 | /* Validate changes from /proc interface. */ | |
fe2c6338 | 67 | static int ipv4_local_port_range(struct ctl_table *table, int write, |
227b60f5 SH |
68 | void __user *buffer, |
69 | size_t *lenp, loff_t *ppos) | |
70 | { | |
0bbf87d8 | 71 | struct net *net = |
c9d8f1a6 | 72 | container_of(table->data, struct net, ipv4.ip_local_ports.range); |
227b60f5 | 73 | int ret; |
3c689b73 | 74 | int range[2]; |
fe2c6338 | 75 | struct ctl_table tmp = { |
227b60f5 SH |
76 | .data = &range, |
77 | .maxlen = sizeof(range), | |
78 | .mode = table->mode, | |
79 | .extra1 = &ip_local_port_range_min, | |
80 | .extra2 = &ip_local_port_range_max, | |
81 | }; | |
82 | ||
0bbf87d8 EB |
83 | inet_get_local_port_range(net, &range[0], &range[1]); |
84 | ||
8d65af78 | 85 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
227b60f5 SH |
86 | |
87 | if (write && ret == 0) { | |
4548b683 KJ |
88 | /* Ensure that the upper limit is not smaller than the lower, |
89 | * and that the lower does not encroach upon the privileged | |
90 | * port limit. | |
91 | */ | |
92 | if ((range[1] < range[0]) || | |
93 | (range[0] < net->ipv4.sysctl_ip_prot_sock)) | |
227b60f5 SH |
94 | ret = -EINVAL; |
95 | else | |
0bbf87d8 | 96 | set_local_port_range(net, range); |
227b60f5 SH |
97 | } |
98 | ||
99 | return ret; | |
100 | } | |
101 | ||
4548b683 KJ |
102 | /* Validate changes from /proc interface. */ |
103 | static int ipv4_privileged_ports(struct ctl_table *table, int write, | |
104 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
105 | { | |
106 | struct net *net = container_of(table->data, struct net, | |
107 | ipv4.sysctl_ip_prot_sock); | |
108 | int ret; | |
109 | int pports; | |
110 | int range[2]; | |
111 | struct ctl_table tmp = { | |
112 | .data = &pports, | |
113 | .maxlen = sizeof(pports), | |
114 | .mode = table->mode, | |
115 | .extra1 = &ip_privileged_port_min, | |
116 | .extra2 = &ip_privileged_port_max, | |
117 | }; | |
118 | ||
119 | pports = net->ipv4.sysctl_ip_prot_sock; | |
120 | ||
121 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); | |
122 | ||
123 | if (write && ret == 0) { | |
124 | inet_get_local_port_range(net, &range[0], &range[1]); | |
125 | /* Ensure that the local port range doesn't overlap with the | |
126 | * privileged port range. | |
127 | */ | |
128 | if (range[0] < pports) | |
129 | ret = -EINVAL; | |
130 | else | |
131 | net->ipv4.sysctl_ip_prot_sock = pports; | |
132 | } | |
133 | ||
134 | return ret; | |
135 | } | |
c319b4d7 | 136 | |
7064d16e | 137 | static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high) |
c319b4d7 | 138 | { |
7064d16e | 139 | kgid_t *data = table->data; |
0bbf87d8 | 140 | struct net *net = |
ba6b918a | 141 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
95c96174 | 142 | unsigned int seq; |
c319b4d7 | 143 | do { |
396a30cc | 144 | seq = read_seqbegin(&net->ipv4.ping_group_range.lock); |
c319b4d7 VK |
145 | |
146 | *low = data[0]; | |
147 | *high = data[1]; | |
396a30cc | 148 | } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); |
c319b4d7 VK |
149 | } |
150 | ||
151 | /* Update system visible IP port range */ | |
7064d16e | 152 | static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high) |
c319b4d7 | 153 | { |
7064d16e | 154 | kgid_t *data = table->data; |
0bbf87d8 | 155 | struct net *net = |
ba6b918a | 156 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
396a30cc | 157 | write_seqlock(&net->ipv4.ping_group_range.lock); |
7064d16e EB |
158 | data[0] = low; |
159 | data[1] = high; | |
396a30cc | 160 | write_sequnlock(&net->ipv4.ping_group_range.lock); |
c319b4d7 VK |
161 | } |
162 | ||
163 | /* Validate changes from /proc interface. */ | |
fe2c6338 | 164 | static int ipv4_ping_group_range(struct ctl_table *table, int write, |
c319b4d7 VK |
165 | void __user *buffer, |
166 | size_t *lenp, loff_t *ppos) | |
167 | { | |
7064d16e | 168 | struct user_namespace *user_ns = current_user_ns(); |
c319b4d7 | 169 | int ret; |
7064d16e EB |
170 | gid_t urange[2]; |
171 | kgid_t low, high; | |
fe2c6338 | 172 | struct ctl_table tmp = { |
7064d16e EB |
173 | .data = &urange, |
174 | .maxlen = sizeof(urange), | |
c319b4d7 VK |
175 | .mode = table->mode, |
176 | .extra1 = &ip_ping_group_range_min, | |
177 | .extra2 = &ip_ping_group_range_max, | |
178 | }; | |
179 | ||
7064d16e EB |
180 | inet_get_ping_group_range_table(table, &low, &high); |
181 | urange[0] = from_kgid_munged(user_ns, low); | |
182 | urange[1] = from_kgid_munged(user_ns, high); | |
c319b4d7 VK |
183 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
184 | ||
7064d16e EB |
185 | if (write && ret == 0) { |
186 | low = make_kgid(user_ns, urange[0]); | |
187 | high = make_kgid(user_ns, urange[1]); | |
188 | if (!gid_valid(low) || !gid_valid(high) || | |
189 | (urange[1] < urange[0]) || gid_lt(high, low)) { | |
190 | low = make_kgid(&init_user_ns, 1); | |
191 | high = make_kgid(&init_user_ns, 0); | |
192 | } | |
193 | set_ping_group_range(table, low, high); | |
194 | } | |
c319b4d7 VK |
195 | |
196 | return ret; | |
197 | } | |
198 | ||
fe2c6338 | 199 | static int proc_tcp_congestion_control(struct ctl_table *ctl, int write, |
317a76f9 SH |
200 | void __user *buffer, size_t *lenp, loff_t *ppos) |
201 | { | |
202 | char val[TCP_CA_NAME_MAX]; | |
fe2c6338 | 203 | struct ctl_table tbl = { |
317a76f9 SH |
204 | .data = val, |
205 | .maxlen = TCP_CA_NAME_MAX, | |
206 | }; | |
207 | int ret; | |
208 | ||
209 | tcp_get_default_congestion_control(val); | |
210 | ||
8d65af78 | 211 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
317a76f9 SH |
212 | if (write && ret == 0) |
213 | ret = tcp_set_default_congestion_control(val); | |
214 | return ret; | |
215 | } | |
216 | ||
fe2c6338 | 217 | static int proc_tcp_available_congestion_control(struct ctl_table *ctl, |
8d65af78 | 218 | int write, |
3ff825b2 SH |
219 | void __user *buffer, size_t *lenp, |
220 | loff_t *ppos) | |
221 | { | |
fe2c6338 | 222 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, }; |
3ff825b2 SH |
223 | int ret; |
224 | ||
225 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
226 | if (!tbl.data) | |
227 | return -ENOMEM; | |
228 | tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX); | |
8d65af78 | 229 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
3ff825b2 SH |
230 | kfree(tbl.data); |
231 | return ret; | |
232 | } | |
233 | ||
fe2c6338 | 234 | static int proc_allowed_congestion_control(struct ctl_table *ctl, |
8d65af78 | 235 | int write, |
ce7bc3bf SH |
236 | void __user *buffer, size_t *lenp, |
237 | loff_t *ppos) | |
238 | { | |
fe2c6338 | 239 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX }; |
ce7bc3bf SH |
240 | int ret; |
241 | ||
242 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
243 | if (!tbl.data) | |
244 | return -ENOMEM; | |
245 | ||
246 | tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen); | |
8d65af78 | 247 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
ce7bc3bf SH |
248 | if (write && ret == 0) |
249 | ret = tcp_set_allowed_congestion_control(tbl.data); | |
250 | kfree(tbl.data); | |
251 | return ret; | |
252 | } | |
253 | ||
43713848 | 254 | static int proc_tcp_fastopen_key(struct ctl_table *table, int write, |
fe2c6338 JP |
255 | void __user *buffer, size_t *lenp, |
256 | loff_t *ppos) | |
10467163 | 257 | { |
43713848 HY |
258 | struct net *net = container_of(table->data, struct net, |
259 | ipv4.sysctl_tcp_fastopen); | |
fe2c6338 | 260 | struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) }; |
10467163 JC |
261 | struct tcp_fastopen_context *ctxt; |
262 | int ret; | |
263 | u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */ | |
264 | ||
265 | tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL); | |
266 | if (!tbl.data) | |
267 | return -ENOMEM; | |
268 | ||
269 | rcu_read_lock(); | |
43713848 | 270 | ctxt = rcu_dereference(net->ipv4.tcp_fastopen_ctx); |
10467163 JC |
271 | if (ctxt) |
272 | memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH); | |
0e24c4fc AC |
273 | else |
274 | memset(user_key, 0, sizeof(user_key)); | |
10467163 JC |
275 | rcu_read_unlock(); |
276 | ||
277 | snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x", | |
278 | user_key[0], user_key[1], user_key[2], user_key[3]); | |
279 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); | |
280 | ||
281 | if (write && ret == 0) { | |
282 | if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1, | |
283 | user_key + 2, user_key + 3) != 4) { | |
284 | ret = -EINVAL; | |
285 | goto bad_key; | |
286 | } | |
1fba70e5 YC |
287 | tcp_fastopen_reset_cipher(net, NULL, user_key, |
288 | TCP_FASTOPEN_KEY_LENGTH); | |
10467163 JC |
289 | } |
290 | ||
291 | bad_key: | |
292 | pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n", | |
293 | user_key[0], user_key[1], user_key[2], user_key[3], | |
294 | (char *)tbl.data, ret); | |
295 | kfree(tbl.data); | |
296 | return ret; | |
297 | } | |
298 | ||
dddb64bc SAK |
299 | static void proc_configure_early_demux(int enabled, int protocol) |
300 | { | |
301 | struct net_protocol *ipprot; | |
302 | #if IS_ENABLED(CONFIG_IPV6) | |
303 | struct inet6_protocol *ip6prot; | |
304 | #endif | |
305 | ||
58c4c6a3 DA |
306 | rcu_read_lock(); |
307 | ||
dddb64bc SAK |
308 | ipprot = rcu_dereference(inet_protos[protocol]); |
309 | if (ipprot) | |
310 | ipprot->early_demux = enabled ? ipprot->early_demux_handler : | |
311 | NULL; | |
312 | ||
313 | #if IS_ENABLED(CONFIG_IPV6) | |
314 | ip6prot = rcu_dereference(inet6_protos[protocol]); | |
315 | if (ip6prot) | |
316 | ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : | |
317 | NULL; | |
318 | #endif | |
58c4c6a3 | 319 | rcu_read_unlock(); |
dddb64bc SAK |
320 | } |
321 | ||
322 | static int proc_tcp_early_demux(struct ctl_table *table, int write, | |
323 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
324 | { | |
325 | int ret = 0; | |
326 | ||
327 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | |
328 | ||
329 | if (write && !ret) { | |
330 | int enabled = init_net.ipv4.sysctl_tcp_early_demux; | |
331 | ||
332 | proc_configure_early_demux(enabled, IPPROTO_TCP); | |
333 | } | |
334 | ||
335 | return ret; | |
336 | } | |
337 | ||
338 | static int proc_udp_early_demux(struct ctl_table *table, int write, | |
339 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
340 | { | |
341 | int ret = 0; | |
342 | ||
343 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | |
344 | ||
345 | if (write && !ret) { | |
346 | int enabled = init_net.ipv4.sysctl_udp_early_demux; | |
347 | ||
348 | proc_configure_early_demux(enabled, IPPROTO_UDP); | |
349 | } | |
350 | ||
351 | return ret; | |
352 | } | |
353 | ||
cf1ef3f0 WW |
354 | static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, |
355 | int write, | |
356 | void __user *buffer, | |
357 | size_t *lenp, loff_t *ppos) | |
358 | { | |
3733be14 HY |
359 | struct net *net = container_of(table->data, struct net, |
360 | ipv4.sysctl_tcp_fastopen_blackhole_timeout); | |
cf1ef3f0 WW |
361 | int ret; |
362 | ||
363 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | |
364 | if (write && ret == 0) | |
3733be14 | 365 | atomic_set(&net->ipv4.tfo_active_disable_times, 0); |
734942cc DW |
366 | |
367 | return ret; | |
368 | } | |
369 | ||
370 | static int proc_tcp_available_ulp(struct ctl_table *ctl, | |
371 | int write, | |
372 | void __user *buffer, size_t *lenp, | |
373 | loff_t *ppos) | |
374 | { | |
375 | struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, }; | |
376 | int ret; | |
377 | ||
378 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
379 | if (!tbl.data) | |
380 | return -ENOMEM; | |
381 | tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX); | |
382 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); | |
383 | kfree(tbl.data); | |
384 | ||
cf1ef3f0 WW |
385 | return ret; |
386 | } | |
387 | ||
3e37c3f9 | 388 | static struct ctl_table ipv4_table[] = { |
e905a9ed | 389 | { |
1da177e4 LT |
390 | .procname = "tcp_retrans_collapse", |
391 | .data = &sysctl_tcp_retrans_collapse, | |
392 | .maxlen = sizeof(int), | |
393 | .mode = 0644, | |
6d9f239a | 394 | .proc_handler = proc_dointvec |
1da177e4 | 395 | }, |
1da177e4 | 396 | { |
1da177e4 LT |
397 | .procname = "tcp_max_orphans", |
398 | .data = &sysctl_tcp_max_orphans, | |
399 | .maxlen = sizeof(int), | |
400 | .mode = 0644, | |
6d9f239a | 401 | .proc_handler = proc_dointvec |
1da177e4 | 402 | }, |
1da177e4 | 403 | { |
1da177e4 LT |
404 | .procname = "tcp_abort_on_overflow", |
405 | .data = &sysctl_tcp_abort_on_overflow, | |
406 | .maxlen = sizeof(int), | |
407 | .mode = 0644, | |
6d9f239a | 408 | .proc_handler = proc_dointvec |
1da177e4 LT |
409 | }, |
410 | { | |
1da177e4 LT |
411 | .procname = "tcp_stdurg", |
412 | .data = &sysctl_tcp_stdurg, | |
413 | .maxlen = sizeof(int), | |
414 | .mode = 0644, | |
6d9f239a | 415 | .proc_handler = proc_dointvec |
1da177e4 LT |
416 | }, |
417 | { | |
1da177e4 LT |
418 | .procname = "tcp_rfc1337", |
419 | .data = &sysctl_tcp_rfc1337, | |
420 | .maxlen = sizeof(int), | |
421 | .mode = 0644, | |
6d9f239a | 422 | .proc_handler = proc_dointvec |
1da177e4 | 423 | }, |
1da177e4 | 424 | { |
1da177e4 LT |
425 | .procname = "inet_peer_threshold", |
426 | .data = &inet_peer_threshold, | |
427 | .maxlen = sizeof(int), | |
428 | .mode = 0644, | |
6d9f239a | 429 | .proc_handler = proc_dointvec |
1da177e4 LT |
430 | }, |
431 | { | |
1da177e4 LT |
432 | .procname = "inet_peer_minttl", |
433 | .data = &inet_peer_minttl, | |
434 | .maxlen = sizeof(int), | |
435 | .mode = 0644, | |
6d9f239a | 436 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 LT |
437 | }, |
438 | { | |
1da177e4 LT |
439 | .procname = "inet_peer_maxttl", |
440 | .data = &inet_peer_maxttl, | |
441 | .maxlen = sizeof(int), | |
442 | .mode = 0644, | |
6d9f239a | 443 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 | 444 | }, |
1da177e4 | 445 | { |
1da177e4 LT |
446 | .procname = "tcp_fack", |
447 | .data = &sysctl_tcp_fack, | |
448 | .maxlen = sizeof(int), | |
449 | .mode = 0644, | |
6d9f239a | 450 | .proc_handler = proc_dointvec |
1da177e4 | 451 | }, |
4f41b1c5 YC |
452 | { |
453 | .procname = "tcp_recovery", | |
454 | .data = &sysctl_tcp_recovery, | |
455 | .maxlen = sizeof(int), | |
456 | .mode = 0644, | |
457 | .proc_handler = proc_dointvec, | |
458 | }, | |
dca145ff ED |
459 | { |
460 | .procname = "tcp_max_reordering", | |
461 | .data = &sysctl_tcp_max_reordering, | |
462 | .maxlen = sizeof(int), | |
463 | .mode = 0644, | |
464 | .proc_handler = proc_dointvec | |
465 | }, | |
1da177e4 | 466 | { |
1da177e4 LT |
467 | .procname = "tcp_dsack", |
468 | .data = &sysctl_tcp_dsack, | |
469 | .maxlen = sizeof(int), | |
470 | .mode = 0644, | |
6d9f239a | 471 | .proc_handler = proc_dointvec |
1da177e4 | 472 | }, |
a4fe34bf EB |
473 | { |
474 | .procname = "tcp_mem", | |
475 | .maxlen = sizeof(sysctl_tcp_mem), | |
476 | .data = &sysctl_tcp_mem, | |
477 | .mode = 0644, | |
478 | .proc_handler = proc_doulongvec_minmax, | |
479 | }, | |
1da177e4 | 480 | { |
1da177e4 LT |
481 | .procname = "tcp_wmem", |
482 | .data = &sysctl_tcp_wmem, | |
483 | .maxlen = sizeof(sysctl_tcp_wmem), | |
484 | .mode = 0644, | |
cdda8891 | 485 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 486 | .extra1 = &one, |
1da177e4 LT |
487 | }, |
488 | { | |
1da177e4 LT |
489 | .procname = "tcp_rmem", |
490 | .data = &sysctl_tcp_rmem, | |
491 | .maxlen = sizeof(sysctl_tcp_rmem), | |
492 | .mode = 0644, | |
cdda8891 | 493 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 494 | .extra1 = &one, |
1da177e4 LT |
495 | }, |
496 | { | |
1da177e4 LT |
497 | .procname = "tcp_app_win", |
498 | .data = &sysctl_tcp_app_win, | |
499 | .maxlen = sizeof(int), | |
500 | .mode = 0644, | |
6d9f239a | 501 | .proc_handler = proc_dointvec |
1da177e4 LT |
502 | }, |
503 | { | |
1da177e4 LT |
504 | .procname = "tcp_adv_win_scale", |
505 | .data = &sysctl_tcp_adv_win_scale, | |
506 | .maxlen = sizeof(int), | |
507 | .mode = 0644, | |
0147fc05 AD |
508 | .proc_handler = proc_dointvec_minmax, |
509 | .extra1 = &tcp_adv_win_scale_min, | |
510 | .extra2 = &tcp_adv_win_scale_max, | |
1da177e4 | 511 | }, |
1da177e4 | 512 | { |
1da177e4 LT |
513 | .procname = "tcp_frto", |
514 | .data = &sysctl_tcp_frto, | |
515 | .maxlen = sizeof(int), | |
f6722583 YC |
516 | .mode = 0644, |
517 | .proc_handler = proc_dointvec | |
518 | }, | |
519 | { | |
520 | .procname = "tcp_min_rtt_wlen", | |
521 | .data = &sysctl_tcp_min_rtt_wlen, | |
522 | .maxlen = sizeof(int), | |
1da177e4 | 523 | .mode = 0644, |
6d9f239a | 524 | .proc_handler = proc_dointvec |
1da177e4 LT |
525 | }, |
526 | { | |
1da177e4 LT |
527 | .procname = "tcp_low_latency", |
528 | .data = &sysctl_tcp_low_latency, | |
529 | .maxlen = sizeof(int), | |
530 | .mode = 0644, | |
6d9f239a | 531 | .proc_handler = proc_dointvec |
1da177e4 | 532 | }, |
1da177e4 | 533 | { |
1da177e4 LT |
534 | .procname = "tcp_no_metrics_save", |
535 | .data = &sysctl_tcp_nometrics_save, | |
536 | .maxlen = sizeof(int), | |
537 | .mode = 0644, | |
6d9f239a | 538 | .proc_handler = proc_dointvec, |
1da177e4 | 539 | }, |
1da177e4 | 540 | { |
1da177e4 LT |
541 | .procname = "tcp_moderate_rcvbuf", |
542 | .data = &sysctl_tcp_moderate_rcvbuf, | |
543 | .maxlen = sizeof(int), | |
544 | .mode = 0644, | |
6d9f239a | 545 | .proc_handler = proc_dointvec, |
1da177e4 LT |
546 | }, |
547 | { | |
1da177e4 LT |
548 | .procname = "tcp_tso_win_divisor", |
549 | .data = &sysctl_tcp_tso_win_divisor, | |
550 | .maxlen = sizeof(int), | |
551 | .mode = 0644, | |
6d9f239a | 552 | .proc_handler = proc_dointvec, |
1da177e4 LT |
553 | }, |
554 | { | |
317a76f9 | 555 | .procname = "tcp_congestion_control", |
1da177e4 | 556 | .mode = 0644, |
317a76f9 | 557 | .maxlen = TCP_CA_NAME_MAX, |
6d9f239a | 558 | .proc_handler = proc_tcp_congestion_control, |
1da177e4 | 559 | }, |
e905a9ed | 560 | { |
15d99e02 RJ |
561 | .procname = "tcp_workaround_signed_windows", |
562 | .data = &sysctl_tcp_workaround_signed_windows, | |
563 | .maxlen = sizeof(int), | |
564 | .mode = 0644, | |
6d9f239a | 565 | .proc_handler = proc_dointvec |
15d99e02 | 566 | }, |
46d3ceab ED |
567 | { |
568 | .procname = "tcp_limit_output_bytes", | |
569 | .data = &sysctl_tcp_limit_output_bytes, | |
570 | .maxlen = sizeof(int), | |
571 | .mode = 0644, | |
572 | .proc_handler = proc_dointvec | |
573 | }, | |
282f23c6 ED |
574 | { |
575 | .procname = "tcp_challenge_ack_limit", | |
576 | .data = &sysctl_tcp_challenge_ack_limit, | |
577 | .maxlen = sizeof(int), | |
578 | .mode = 0644, | |
579 | .proc_handler = proc_dointvec | |
580 | }, | |
35089bb2 | 581 | { |
35089bb2 DM |
582 | .procname = "tcp_slow_start_after_idle", |
583 | .data = &sysctl_tcp_slow_start_after_idle, | |
584 | .maxlen = sizeof(int), | |
585 | .mode = 0644, | |
6d9f239a | 586 | .proc_handler = proc_dointvec |
35089bb2 | 587 | }, |
446fda4f PM |
588 | #ifdef CONFIG_NETLABEL |
589 | { | |
446fda4f PM |
590 | .procname = "cipso_cache_enable", |
591 | .data = &cipso_v4_cache_enabled, | |
592 | .maxlen = sizeof(int), | |
593 | .mode = 0644, | |
6d9f239a | 594 | .proc_handler = proc_dointvec, |
446fda4f PM |
595 | }, |
596 | { | |
446fda4f PM |
597 | .procname = "cipso_cache_bucket_size", |
598 | .data = &cipso_v4_cache_bucketsize, | |
599 | .maxlen = sizeof(int), | |
600 | .mode = 0644, | |
6d9f239a | 601 | .proc_handler = proc_dointvec, |
446fda4f PM |
602 | }, |
603 | { | |
446fda4f PM |
604 | .procname = "cipso_rbm_optfmt", |
605 | .data = &cipso_v4_rbm_optfmt, | |
606 | .maxlen = sizeof(int), | |
607 | .mode = 0644, | |
6d9f239a | 608 | .proc_handler = proc_dointvec, |
446fda4f PM |
609 | }, |
610 | { | |
446fda4f PM |
611 | .procname = "cipso_rbm_strictvalid", |
612 | .data = &cipso_v4_rbm_strictvalid, | |
613 | .maxlen = sizeof(int), | |
614 | .mode = 0644, | |
6d9f239a | 615 | .proc_handler = proc_dointvec, |
446fda4f PM |
616 | }, |
617 | #endif /* CONFIG_NETLABEL */ | |
3ff825b2 | 618 | { |
3ff825b2 SH |
619 | .procname = "tcp_available_congestion_control", |
620 | .maxlen = TCP_CA_BUF_MAX, | |
621 | .mode = 0444, | |
6d9f239a | 622 | .proc_handler = proc_tcp_available_congestion_control, |
3ff825b2 | 623 | }, |
ce7bc3bf | 624 | { |
ce7bc3bf SH |
625 | .procname = "tcp_allowed_congestion_control", |
626 | .maxlen = TCP_CA_BUF_MAX, | |
627 | .mode = 0644, | |
6d9f239a | 628 | .proc_handler = proc_allowed_congestion_control, |
ce7bc3bf | 629 | }, |
36e31b0a AP |
630 | { |
631 | .procname = "tcp_thin_linear_timeouts", | |
632 | .data = &sysctl_tcp_thin_linear_timeouts, | |
633 | .maxlen = sizeof(int), | |
634 | .mode = 0644, | |
635 | .proc_handler = proc_dointvec | |
636 | }, | |
eed530b6 YC |
637 | { |
638 | .procname = "tcp_early_retrans", | |
639 | .data = &sysctl_tcp_early_retrans, | |
640 | .maxlen = sizeof(int), | |
641 | .mode = 0644, | |
642 | .proc_handler = proc_dointvec_minmax, | |
643 | .extra1 = &zero, | |
6ba8a3b1 | 644 | .extra2 = &four, |
eed530b6 | 645 | }, |
95bd09eb ED |
646 | { |
647 | .procname = "tcp_min_tso_segs", | |
648 | .data = &sysctl_tcp_min_tso_segs, | |
649 | .maxlen = sizeof(int), | |
650 | .mode = 0644, | |
651 | .proc_handler = proc_dointvec_minmax, | |
d6a4e26a | 652 | .extra1 = &one, |
95bd09eb ED |
653 | .extra2 = &gso_max_segs, |
654 | }, | |
43e122b0 ED |
655 | { |
656 | .procname = "tcp_pacing_ss_ratio", | |
657 | .data = &sysctl_tcp_pacing_ss_ratio, | |
658 | .maxlen = sizeof(int), | |
659 | .mode = 0644, | |
660 | .proc_handler = proc_dointvec_minmax, | |
661 | .extra1 = &zero, | |
662 | .extra2 = &thousand, | |
663 | }, | |
664 | { | |
665 | .procname = "tcp_pacing_ca_ratio", | |
666 | .data = &sysctl_tcp_pacing_ca_ratio, | |
667 | .maxlen = sizeof(int), | |
668 | .mode = 0644, | |
669 | .proc_handler = proc_dointvec_minmax, | |
670 | .extra1 = &zero, | |
671 | .extra2 = &thousand, | |
672 | }, | |
f54b3111 ED |
673 | { |
674 | .procname = "tcp_autocorking", | |
675 | .data = &sysctl_tcp_autocorking, | |
676 | .maxlen = sizeof(int), | |
677 | .mode = 0644, | |
678 | .proc_handler = proc_dointvec_minmax, | |
679 | .extra1 = &zero, | |
680 | .extra2 = &one, | |
681 | }, | |
032ee423 NC |
682 | { |
683 | .procname = "tcp_invalid_ratelimit", | |
684 | .data = &sysctl_tcp_invalid_ratelimit, | |
685 | .maxlen = sizeof(int), | |
686 | .mode = 0644, | |
687 | .proc_handler = proc_dointvec_ms_jiffies, | |
688 | }, | |
734942cc DW |
689 | { |
690 | .procname = "tcp_available_ulp", | |
691 | .maxlen = TCP_ULP_BUF_MAX, | |
692 | .mode = 0444, | |
693 | .proc_handler = proc_tcp_available_ulp, | |
694 | }, | |
4cdf507d ED |
695 | { |
696 | .procname = "icmp_msgs_per_sec", | |
697 | .data = &sysctl_icmp_msgs_per_sec, | |
698 | .maxlen = sizeof(int), | |
699 | .mode = 0644, | |
700 | .proc_handler = proc_dointvec_minmax, | |
701 | .extra1 = &zero, | |
702 | }, | |
703 | { | |
704 | .procname = "icmp_msgs_burst", | |
705 | .data = &sysctl_icmp_msgs_burst, | |
706 | .maxlen = sizeof(int), | |
707 | .mode = 0644, | |
708 | .proc_handler = proc_dointvec_minmax, | |
709 | .extra1 = &zero, | |
710 | }, | |
95766fff | 711 | { |
95766fff HA |
712 | .procname = "udp_mem", |
713 | .data = &sysctl_udp_mem, | |
714 | .maxlen = sizeof(sysctl_udp_mem), | |
715 | .mode = 0644, | |
8d987e5c | 716 | .proc_handler = proc_doulongvec_minmax, |
95766fff HA |
717 | }, |
718 | { | |
95766fff HA |
719 | .procname = "udp_rmem_min", |
720 | .data = &sysctl_udp_rmem_min, | |
721 | .maxlen = sizeof(sysctl_udp_rmem_min), | |
722 | .mode = 0644, | |
6d9f239a | 723 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 724 | .extra1 = &one |
95766fff HA |
725 | }, |
726 | { | |
95766fff HA |
727 | .procname = "udp_wmem_min", |
728 | .data = &sysctl_udp_wmem_min, | |
729 | .maxlen = sizeof(sysctl_udp_wmem_min), | |
730 | .mode = 0644, | |
6d9f239a | 731 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 732 | .extra1 = &one |
95766fff | 733 | }, |
f8572d8f | 734 | { } |
1da177e4 | 735 | }; |
3e37c3f9 | 736 | |
68528f09 PE |
737 | static struct ctl_table ipv4_net_table[] = { |
738 | { | |
68528f09 PE |
739 | .procname = "icmp_echo_ignore_all", |
740 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, | |
741 | .maxlen = sizeof(int), | |
742 | .mode = 0644, | |
6d9f239a | 743 | .proc_handler = proc_dointvec |
68528f09 PE |
744 | }, |
745 | { | |
68528f09 PE |
746 | .procname = "icmp_echo_ignore_broadcasts", |
747 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, | |
748 | .maxlen = sizeof(int), | |
749 | .mode = 0644, | |
6d9f239a | 750 | .proc_handler = proc_dointvec |
68528f09 PE |
751 | }, |
752 | { | |
68528f09 PE |
753 | .procname = "icmp_ignore_bogus_error_responses", |
754 | .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, | |
755 | .maxlen = sizeof(int), | |
756 | .mode = 0644, | |
6d9f239a | 757 | .proc_handler = proc_dointvec |
68528f09 PE |
758 | }, |
759 | { | |
68528f09 PE |
760 | .procname = "icmp_errors_use_inbound_ifaddr", |
761 | .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, | |
762 | .maxlen = sizeof(int), | |
763 | .mode = 0644, | |
6d9f239a | 764 | .proc_handler = proc_dointvec |
68528f09 PE |
765 | }, |
766 | { | |
68528f09 PE |
767 | .procname = "icmp_ratelimit", |
768 | .data = &init_net.ipv4.sysctl_icmp_ratelimit, | |
769 | .maxlen = sizeof(int), | |
770 | .mode = 0644, | |
6d9f239a | 771 | .proc_handler = proc_dointvec_ms_jiffies, |
68528f09 PE |
772 | }, |
773 | { | |
68528f09 PE |
774 | .procname = "icmp_ratemask", |
775 | .data = &init_net.ipv4.sysctl_icmp_ratemask, | |
776 | .maxlen = sizeof(int), | |
777 | .mode = 0644, | |
6d9f239a | 778 | .proc_handler = proc_dointvec |
68528f09 | 779 | }, |
c319b4d7 VK |
780 | { |
781 | .procname = "ping_group_range", | |
ba6b918a | 782 | .data = &init_net.ipv4.ping_group_range.range, |
7064d16e | 783 | .maxlen = sizeof(gid_t)*2, |
c319b4d7 VK |
784 | .mode = 0644, |
785 | .proc_handler = ipv4_ping_group_range, | |
786 | }, | |
5d134f1c HFS |
787 | { |
788 | .procname = "tcp_ecn", | |
789 | .data = &init_net.ipv4.sysctl_tcp_ecn, | |
790 | .maxlen = sizeof(int), | |
791 | .mode = 0644, | |
792 | .proc_handler = proc_dointvec | |
793 | }, | |
49213555 DB |
794 | { |
795 | .procname = "tcp_ecn_fallback", | |
796 | .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, | |
797 | .maxlen = sizeof(int), | |
798 | .mode = 0644, | |
799 | .proc_handler = proc_dointvec | |
800 | }, | |
287b7f38 NB |
801 | { |
802 | .procname = "ip_dynaddr", | |
803 | .data = &init_net.ipv4.sysctl_ip_dynaddr, | |
804 | .maxlen = sizeof(int), | |
805 | .mode = 0644, | |
806 | .proc_handler = proc_dointvec | |
807 | }, | |
e21145a9 NB |
808 | { |
809 | .procname = "ip_early_demux", | |
810 | .data = &init_net.ipv4.sysctl_ip_early_demux, | |
811 | .maxlen = sizeof(int), | |
812 | .mode = 0644, | |
813 | .proc_handler = proc_dointvec | |
814 | }, | |
dddb64bc SAK |
815 | { |
816 | .procname = "udp_early_demux", | |
817 | .data = &init_net.ipv4.sysctl_udp_early_demux, | |
818 | .maxlen = sizeof(int), | |
819 | .mode = 0644, | |
820 | .proc_handler = proc_udp_early_demux | |
821 | }, | |
822 | { | |
823 | .procname = "tcp_early_demux", | |
824 | .data = &init_net.ipv4.sysctl_tcp_early_demux, | |
825 | .maxlen = sizeof(int), | |
826 | .mode = 0644, | |
827 | .proc_handler = proc_tcp_early_demux | |
828 | }, | |
fa50d974 NB |
829 | { |
830 | .procname = "ip_default_ttl", | |
831 | .data = &init_net.ipv4.sysctl_ip_default_ttl, | |
832 | .maxlen = sizeof(int), | |
833 | .mode = 0644, | |
834 | .proc_handler = proc_dointvec_minmax, | |
835 | .extra1 = &ip_ttl_min, | |
836 | .extra2 = &ip_ttl_max, | |
837 | }, | |
0bbf87d8 EB |
838 | { |
839 | .procname = "ip_local_port_range", | |
c9d8f1a6 CW |
840 | .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), |
841 | .data = &init_net.ipv4.ip_local_ports.range, | |
0bbf87d8 EB |
842 | .mode = 0644, |
843 | .proc_handler = ipv4_local_port_range, | |
844 | }, | |
122ff243 WC |
845 | { |
846 | .procname = "ip_local_reserved_ports", | |
847 | .data = &init_net.ipv4.sysctl_local_reserved_ports, | |
848 | .maxlen = 65536, | |
849 | .mode = 0644, | |
850 | .proc_handler = proc_do_large_bitmap, | |
851 | }, | |
974eda11 HFS |
852 | { |
853 | .procname = "ip_no_pmtu_disc", | |
854 | .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, | |
855 | .maxlen = sizeof(int), | |
856 | .mode = 0644, | |
857 | .proc_handler = proc_dointvec | |
858 | }, | |
f87c10a8 HFS |
859 | { |
860 | .procname = "ip_forward_use_pmtu", | |
861 | .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, | |
862 | .maxlen = sizeof(int), | |
863 | .mode = 0644, | |
864 | .proc_handler = proc_dointvec, | |
865 | }, | |
49a60158 VB |
866 | { |
867 | .procname = "ip_nonlocal_bind", | |
868 | .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, | |
869 | .maxlen = sizeof(int), | |
870 | .mode = 0644, | |
871 | .proc_handler = proc_dointvec | |
872 | }, | |
e110861f LC |
873 | { |
874 | .procname = "fwmark_reflect", | |
875 | .data = &init_net.ipv4.sysctl_fwmark_reflect, | |
876 | .maxlen = sizeof(int), | |
877 | .mode = 0644, | |
878 | .proc_handler = proc_dointvec, | |
879 | }, | |
84f39b08 LC |
880 | { |
881 | .procname = "tcp_fwmark_accept", | |
882 | .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, | |
883 | .maxlen = sizeof(int), | |
884 | .mode = 0644, | |
885 | .proc_handler = proc_dointvec, | |
886 | }, | |
6dd9a14e DA |
887 | #ifdef CONFIG_NET_L3_MASTER_DEV |
888 | { | |
889 | .procname = "tcp_l3mdev_accept", | |
890 | .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, | |
891 | .maxlen = sizeof(int), | |
892 | .mode = 0644, | |
893 | .proc_handler = proc_dointvec_minmax, | |
894 | .extra1 = &zero, | |
895 | .extra2 = &one, | |
896 | }, | |
897 | #endif | |
b0f9ca53 FD |
898 | { |
899 | .procname = "tcp_mtu_probing", | |
900 | .data = &init_net.ipv4.sysctl_tcp_mtu_probing, | |
901 | .maxlen = sizeof(int), | |
902 | .mode = 0644, | |
903 | .proc_handler = proc_dointvec, | |
904 | }, | |
905 | { | |
906 | .procname = "tcp_base_mss", | |
907 | .data = &init_net.ipv4.sysctl_tcp_base_mss, | |
908 | .maxlen = sizeof(int), | |
909 | .mode = 0644, | |
910 | .proc_handler = proc_dointvec, | |
911 | }, | |
6b58e0a5 FD |
912 | { |
913 | .procname = "tcp_probe_threshold", | |
914 | .data = &init_net.ipv4.sysctl_tcp_probe_threshold, | |
915 | .maxlen = sizeof(int), | |
916 | .mode = 0644, | |
917 | .proc_handler = proc_dointvec, | |
918 | }, | |
05cbc0db FD |
919 | { |
920 | .procname = "tcp_probe_interval", | |
921 | .data = &init_net.ipv4.sysctl_tcp_probe_interval, | |
922 | .maxlen = sizeof(int), | |
923 | .mode = 0644, | |
924 | .proc_handler = proc_dointvec, | |
925 | }, | |
df2cf4a7 PD |
926 | { |
927 | .procname = "igmp_link_local_mcast_reports", | |
87a8a2ae | 928 | .data = &init_net.ipv4.sysctl_igmp_llm_reports, |
df2cf4a7 PD |
929 | .maxlen = sizeof(int), |
930 | .mode = 0644, | |
931 | .proc_handler = proc_dointvec | |
932 | }, | |
815c5270 NB |
933 | { |
934 | .procname = "igmp_max_memberships", | |
935 | .data = &init_net.ipv4.sysctl_igmp_max_memberships, | |
936 | .maxlen = sizeof(int), | |
937 | .mode = 0644, | |
938 | .proc_handler = proc_dointvec | |
939 | }, | |
166b6b2d NB |
940 | { |
941 | .procname = "igmp_max_msf", | |
942 | .data = &init_net.ipv4.sysctl_igmp_max_msf, | |
943 | .maxlen = sizeof(int), | |
944 | .mode = 0644, | |
945 | .proc_handler = proc_dointvec | |
946 | }, | |
165094af NB |
947 | #ifdef CONFIG_IP_MULTICAST |
948 | { | |
949 | .procname = "igmp_qrv", | |
950 | .data = &init_net.ipv4.sysctl_igmp_qrv, | |
951 | .maxlen = sizeof(int), | |
952 | .mode = 0644, | |
953 | .proc_handler = proc_dointvec_minmax, | |
954 | .extra1 = &one | |
955 | }, | |
956 | #endif | |
13b287e8 NB |
957 | { |
958 | .procname = "tcp_keepalive_time", | |
959 | .data = &init_net.ipv4.sysctl_tcp_keepalive_time, | |
960 | .maxlen = sizeof(int), | |
961 | .mode = 0644, | |
962 | .proc_handler = proc_dointvec_jiffies, | |
963 | }, | |
9bd6861b NB |
964 | { |
965 | .procname = "tcp_keepalive_probes", | |
966 | .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, | |
967 | .maxlen = sizeof(int), | |
968 | .mode = 0644, | |
969 | .proc_handler = proc_dointvec | |
970 | }, | |
b840d15d NB |
971 | { |
972 | .procname = "tcp_keepalive_intvl", | |
973 | .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, | |
974 | .maxlen = sizeof(int), | |
975 | .mode = 0644, | |
976 | .proc_handler = proc_dointvec_jiffies, | |
977 | }, | |
6fa25166 NB |
978 | { |
979 | .procname = "tcp_syn_retries", | |
980 | .data = &init_net.ipv4.sysctl_tcp_syn_retries, | |
981 | .maxlen = sizeof(int), | |
982 | .mode = 0644, | |
983 | .proc_handler = proc_dointvec_minmax, | |
984 | .extra1 = &tcp_syn_retries_min, | |
985 | .extra2 = &tcp_syn_retries_max | |
986 | }, | |
7c083ecb NB |
987 | { |
988 | .procname = "tcp_synack_retries", | |
989 | .data = &init_net.ipv4.sysctl_tcp_synack_retries, | |
990 | .maxlen = sizeof(int), | |
991 | .mode = 0644, | |
992 | .proc_handler = proc_dointvec | |
993 | }, | |
12ed8244 NB |
994 | #ifdef CONFIG_SYN_COOKIES |
995 | { | |
996 | .procname = "tcp_syncookies", | |
997 | .data = &init_net.ipv4.sysctl_tcp_syncookies, | |
998 | .maxlen = sizeof(int), | |
999 | .mode = 0644, | |
1000 | .proc_handler = proc_dointvec | |
1001 | }, | |
1002 | #endif | |
1043e25f NB |
1003 | { |
1004 | .procname = "tcp_reordering", | |
1005 | .data = &init_net.ipv4.sysctl_tcp_reordering, | |
1006 | .maxlen = sizeof(int), | |
1007 | .mode = 0644, | |
1008 | .proc_handler = proc_dointvec | |
1009 | }, | |
ae5c3f40 NB |
1010 | { |
1011 | .procname = "tcp_retries1", | |
1012 | .data = &init_net.ipv4.sysctl_tcp_retries1, | |
1013 | .maxlen = sizeof(int), | |
1014 | .mode = 0644, | |
1015 | .proc_handler = proc_dointvec_minmax, | |
1016 | .extra2 = &tcp_retr1_max | |
1017 | }, | |
c6214a97 NB |
1018 | { |
1019 | .procname = "tcp_retries2", | |
1020 | .data = &init_net.ipv4.sysctl_tcp_retries2, | |
1021 | .maxlen = sizeof(int), | |
1022 | .mode = 0644, | |
1023 | .proc_handler = proc_dointvec | |
1024 | }, | |
c402d9be NB |
1025 | { |
1026 | .procname = "tcp_orphan_retries", | |
1027 | .data = &init_net.ipv4.sysctl_tcp_orphan_retries, | |
1028 | .maxlen = sizeof(int), | |
1029 | .mode = 0644, | |
1030 | .proc_handler = proc_dointvec | |
1031 | }, | |
1e579caa NB |
1032 | { |
1033 | .procname = "tcp_fin_timeout", | |
1034 | .data = &init_net.ipv4.sysctl_tcp_fin_timeout, | |
1035 | .maxlen = sizeof(int), | |
1036 | .mode = 0644, | |
1037 | .proc_handler = proc_dointvec_jiffies, | |
1038 | }, | |
4979f2d9 NB |
1039 | { |
1040 | .procname = "tcp_notsent_lowat", | |
1041 | .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, | |
1042 | .maxlen = sizeof(unsigned int), | |
1043 | .mode = 0644, | |
b007f090 | 1044 | .proc_handler = proc_douintvec, |
4979f2d9 | 1045 | }, |
56ab6b93 HY |
1046 | { |
1047 | .procname = "tcp_tw_reuse", | |
1048 | .data = &init_net.ipv4.sysctl_tcp_tw_reuse, | |
1049 | .maxlen = sizeof(int), | |
1050 | .mode = 0644, | |
1051 | .proc_handler = proc_dointvec | |
1052 | }, | |
1946e672 HY |
1053 | { |
1054 | .procname = "tcp_max_tw_buckets", | |
1055 | .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, | |
1056 | .maxlen = sizeof(int), | |
1057 | .mode = 0644, | |
1058 | .proc_handler = proc_dointvec | |
1059 | }, | |
fee83d09 HY |
1060 | { |
1061 | .procname = "tcp_max_syn_backlog", | |
1062 | .data = &init_net.ipv4.sysctl_max_syn_backlog, | |
1063 | .maxlen = sizeof(int), | |
1064 | .mode = 0644, | |
1065 | .proc_handler = proc_dointvec | |
1066 | }, | |
e1cfcbe8 HY |
1067 | { |
1068 | .procname = "tcp_fastopen", | |
1069 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
1070 | .maxlen = sizeof(int), | |
1071 | .mode = 0644, | |
1072 | .proc_handler = proc_dointvec, | |
1073 | }, | |
43713848 HY |
1074 | { |
1075 | .procname = "tcp_fastopen_key", | |
1076 | .mode = 0600, | |
1077 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
1078 | .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), | |
1079 | .proc_handler = proc_tcp_fastopen_key, | |
1080 | }, | |
3733be14 HY |
1081 | { |
1082 | .procname = "tcp_fastopen_blackhole_timeout_sec", | |
1083 | .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, | |
1084 | .maxlen = sizeof(int), | |
1085 | .mode = 0644, | |
1086 | .proc_handler = proc_tfo_blackhole_detect_timeout, | |
1087 | .extra1 = &zero, | |
1088 | }, | |
a6db4494 DA |
1089 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
1090 | { | |
1091 | .procname = "fib_multipath_use_neigh", | |
1092 | .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, | |
1093 | .maxlen = sizeof(int), | |
1094 | .mode = 0644, | |
1095 | .proc_handler = proc_dointvec_minmax, | |
bf4e0a3d NA |
1096 | .extra1 = &zero, |
1097 | .extra2 = &one, | |
1098 | }, | |
1099 | { | |
1100 | .procname = "fib_multipath_hash_policy", | |
1101 | .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, | |
1102 | .maxlen = sizeof(int), | |
1103 | .mode = 0644, | |
1104 | .proc_handler = proc_dointvec_minmax, | |
a6db4494 DA |
1105 | .extra1 = &zero, |
1106 | .extra2 = &one, | |
1107 | }, | |
1108 | #endif | |
4548b683 KJ |
1109 | { |
1110 | .procname = "ip_unprivileged_port_start", | |
1111 | .maxlen = sizeof(int), | |
1112 | .data = &init_net.ipv4.sysctl_ip_prot_sock, | |
1113 | .mode = 0644, | |
1114 | .proc_handler = ipv4_privileged_ports, | |
1115 | }, | |
63a6fff3 RS |
1116 | #ifdef CONFIG_NET_L3_MASTER_DEV |
1117 | { | |
1118 | .procname = "udp_l3mdev_accept", | |
1119 | .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, | |
1120 | .maxlen = sizeof(int), | |
1121 | .mode = 0644, | |
1122 | .proc_handler = proc_dointvec_minmax, | |
1123 | .extra1 = &zero, | |
1124 | .extra2 = &one, | |
1125 | }, | |
1126 | #endif | |
f9301034 ED |
1127 | { |
1128 | .procname = "tcp_sack", | |
1129 | .data = &init_net.ipv4.sysctl_tcp_sack, | |
1130 | .maxlen = sizeof(int), | |
1131 | .mode = 0644, | |
1132 | .proc_handler = proc_dointvec | |
1133 | }, | |
9bb37ef0 ED |
1134 | { |
1135 | .procname = "tcp_window_scaling", | |
1136 | .data = &init_net.ipv4.sysctl_tcp_window_scaling, | |
1137 | .maxlen = sizeof(int), | |
1138 | .mode = 0644, | |
1139 | .proc_handler = proc_dointvec | |
1140 | }, | |
5d2ed052 ED |
1141 | { |
1142 | .procname = "tcp_timestamps", | |
1143 | .data = &init_net.ipv4.sysctl_tcp_timestamps, | |
1144 | .maxlen = sizeof(int), | |
1145 | .mode = 0644, | |
1146 | .proc_handler = proc_dointvec | |
1147 | }, | |
68528f09 PE |
1148 | { } |
1149 | }; | |
1150 | ||
1577519d PE |
1151 | static __net_init int ipv4_sysctl_init_net(struct net *net) |
1152 | { | |
68528f09 PE |
1153 | struct ctl_table *table; |
1154 | ||
1155 | table = ipv4_net_table; | |
09ad9bc7 | 1156 | if (!net_eq(net, &init_net)) { |
0a6fa23d EB |
1157 | int i; |
1158 | ||
68528f09 | 1159 | table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); |
51456b29 | 1160 | if (!table) |
68528f09 PE |
1161 | goto err_alloc; |
1162 | ||
0a6fa23d EB |
1163 | /* Update the variables to point into the current struct net */ |
1164 | for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) | |
1165 | table[i].data += (void *)net - (void *)&init_net; | |
68528f09 PE |
1166 | } |
1167 | ||
ec8f23ce | 1168 | net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); |
51456b29 | 1169 | if (!net->ipv4.ipv4_hdr) |
68528f09 PE |
1170 | goto err_reg; |
1171 | ||
122ff243 WC |
1172 | net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); |
1173 | if (!net->ipv4.sysctl_local_reserved_ports) | |
1174 | goto err_ports; | |
1175 | ||
1577519d | 1176 | return 0; |
68528f09 | 1177 | |
122ff243 WC |
1178 | err_ports: |
1179 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); | |
68528f09 | 1180 | err_reg: |
09ad9bc7 | 1181 | if (!net_eq(net, &init_net)) |
68528f09 PE |
1182 | kfree(table); |
1183 | err_alloc: | |
1184 | return -ENOMEM; | |
1577519d PE |
1185 | } |
1186 | ||
1187 | static __net_exit void ipv4_sysctl_exit_net(struct net *net) | |
1188 | { | |
68528f09 PE |
1189 | struct ctl_table *table; |
1190 | ||
122ff243 | 1191 | kfree(net->ipv4.sysctl_local_reserved_ports); |
68528f09 PE |
1192 | table = net->ipv4.ipv4_hdr->ctl_table_arg; |
1193 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); | |
1194 | kfree(table); | |
1577519d PE |
1195 | } |
1196 | ||
1197 | static __net_initdata struct pernet_operations ipv4_sysctl_ops = { | |
1198 | .init = ipv4_sysctl_init_net, | |
1199 | .exit = ipv4_sysctl_exit_net, | |
1200 | }; | |
1201 | ||
3e37c3f9 PE |
1202 | static __init int sysctl_ipv4_init(void) |
1203 | { | |
1204 | struct ctl_table_header *hdr; | |
1205 | ||
ec8f23ce | 1206 | hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); |
51456b29 | 1207 | if (!hdr) |
1577519d PE |
1208 | return -ENOMEM; |
1209 | ||
1210 | if (register_pernet_subsys(&ipv4_sysctl_ops)) { | |
5dd3df10 | 1211 | unregister_net_sysctl_table(hdr); |
1577519d PE |
1212 | return -ENOMEM; |
1213 | } | |
1214 | ||
1215 | return 0; | |
3e37c3f9 PE |
1216 | } |
1217 | ||
1218 | __initcall(sysctl_ipv4_init); |