]>
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[] = { |
1da177e4 | 389 | { |
1da177e4 LT |
390 | .procname = "tcp_max_orphans", |
391 | .data = &sysctl_tcp_max_orphans, | |
392 | .maxlen = sizeof(int), | |
393 | .mode = 0644, | |
6d9f239a | 394 | .proc_handler = proc_dointvec |
1da177e4 | 395 | }, |
1da177e4 | 396 | { |
1da177e4 LT |
397 | .procname = "inet_peer_threshold", |
398 | .data = &inet_peer_threshold, | |
399 | .maxlen = sizeof(int), | |
400 | .mode = 0644, | |
6d9f239a | 401 | .proc_handler = proc_dointvec |
1da177e4 LT |
402 | }, |
403 | { | |
1da177e4 LT |
404 | .procname = "inet_peer_minttl", |
405 | .data = &inet_peer_minttl, | |
406 | .maxlen = sizeof(int), | |
407 | .mode = 0644, | |
6d9f239a | 408 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 LT |
409 | }, |
410 | { | |
1da177e4 LT |
411 | .procname = "inet_peer_maxttl", |
412 | .data = &inet_peer_maxttl, | |
413 | .maxlen = sizeof(int), | |
414 | .mode = 0644, | |
6d9f239a | 415 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 | 416 | }, |
a4fe34bf EB |
417 | { |
418 | .procname = "tcp_mem", | |
419 | .maxlen = sizeof(sysctl_tcp_mem), | |
420 | .data = &sysctl_tcp_mem, | |
421 | .mode = 0644, | |
422 | .proc_handler = proc_doulongvec_minmax, | |
423 | }, | |
1da177e4 | 424 | { |
1da177e4 LT |
425 | .procname = "tcp_wmem", |
426 | .data = &sysctl_tcp_wmem, | |
427 | .maxlen = sizeof(sysctl_tcp_wmem), | |
428 | .mode = 0644, | |
cdda8891 | 429 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 430 | .extra1 = &one, |
1da177e4 LT |
431 | }, |
432 | { | |
1da177e4 LT |
433 | .procname = "tcp_rmem", |
434 | .data = &sysctl_tcp_rmem, | |
435 | .maxlen = sizeof(sysctl_tcp_rmem), | |
436 | .mode = 0644, | |
cdda8891 | 437 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 438 | .extra1 = &one, |
1da177e4 | 439 | }, |
1da177e4 | 440 | { |
1da177e4 LT |
441 | .procname = "tcp_low_latency", |
442 | .data = &sysctl_tcp_low_latency, | |
443 | .maxlen = sizeof(int), | |
444 | .mode = 0644, | |
6d9f239a | 445 | .proc_handler = proc_dointvec |
1da177e4 | 446 | }, |
1da177e4 | 447 | { |
317a76f9 | 448 | .procname = "tcp_congestion_control", |
1da177e4 | 449 | .mode = 0644, |
317a76f9 | 450 | .maxlen = TCP_CA_NAME_MAX, |
6d9f239a | 451 | .proc_handler = proc_tcp_congestion_control, |
1da177e4 | 452 | }, |
446fda4f PM |
453 | #ifdef CONFIG_NETLABEL |
454 | { | |
446fda4f PM |
455 | .procname = "cipso_cache_enable", |
456 | .data = &cipso_v4_cache_enabled, | |
457 | .maxlen = sizeof(int), | |
458 | .mode = 0644, | |
6d9f239a | 459 | .proc_handler = proc_dointvec, |
446fda4f PM |
460 | }, |
461 | { | |
446fda4f PM |
462 | .procname = "cipso_cache_bucket_size", |
463 | .data = &cipso_v4_cache_bucketsize, | |
464 | .maxlen = sizeof(int), | |
465 | .mode = 0644, | |
6d9f239a | 466 | .proc_handler = proc_dointvec, |
446fda4f PM |
467 | }, |
468 | { | |
446fda4f PM |
469 | .procname = "cipso_rbm_optfmt", |
470 | .data = &cipso_v4_rbm_optfmt, | |
471 | .maxlen = sizeof(int), | |
472 | .mode = 0644, | |
6d9f239a | 473 | .proc_handler = proc_dointvec, |
446fda4f PM |
474 | }, |
475 | { | |
446fda4f PM |
476 | .procname = "cipso_rbm_strictvalid", |
477 | .data = &cipso_v4_rbm_strictvalid, | |
478 | .maxlen = sizeof(int), | |
479 | .mode = 0644, | |
6d9f239a | 480 | .proc_handler = proc_dointvec, |
446fda4f PM |
481 | }, |
482 | #endif /* CONFIG_NETLABEL */ | |
3ff825b2 | 483 | { |
3ff825b2 SH |
484 | .procname = "tcp_available_congestion_control", |
485 | .maxlen = TCP_CA_BUF_MAX, | |
486 | .mode = 0444, | |
6d9f239a | 487 | .proc_handler = proc_tcp_available_congestion_control, |
3ff825b2 | 488 | }, |
ce7bc3bf | 489 | { |
ce7bc3bf SH |
490 | .procname = "tcp_allowed_congestion_control", |
491 | .maxlen = TCP_CA_BUF_MAX, | |
492 | .mode = 0644, | |
6d9f239a | 493 | .proc_handler = proc_allowed_congestion_control, |
ce7bc3bf | 494 | }, |
43e122b0 ED |
495 | { |
496 | .procname = "tcp_pacing_ss_ratio", | |
497 | .data = &sysctl_tcp_pacing_ss_ratio, | |
498 | .maxlen = sizeof(int), | |
499 | .mode = 0644, | |
500 | .proc_handler = proc_dointvec_minmax, | |
501 | .extra1 = &zero, | |
502 | .extra2 = &thousand, | |
503 | }, | |
504 | { | |
505 | .procname = "tcp_pacing_ca_ratio", | |
506 | .data = &sysctl_tcp_pacing_ca_ratio, | |
507 | .maxlen = sizeof(int), | |
508 | .mode = 0644, | |
509 | .proc_handler = proc_dointvec_minmax, | |
510 | .extra1 = &zero, | |
511 | .extra2 = &thousand, | |
512 | }, | |
032ee423 NC |
513 | { |
514 | .procname = "tcp_invalid_ratelimit", | |
515 | .data = &sysctl_tcp_invalid_ratelimit, | |
516 | .maxlen = sizeof(int), | |
517 | .mode = 0644, | |
518 | .proc_handler = proc_dointvec_ms_jiffies, | |
519 | }, | |
734942cc DW |
520 | { |
521 | .procname = "tcp_available_ulp", | |
522 | .maxlen = TCP_ULP_BUF_MAX, | |
523 | .mode = 0444, | |
524 | .proc_handler = proc_tcp_available_ulp, | |
525 | }, | |
4cdf507d ED |
526 | { |
527 | .procname = "icmp_msgs_per_sec", | |
528 | .data = &sysctl_icmp_msgs_per_sec, | |
529 | .maxlen = sizeof(int), | |
530 | .mode = 0644, | |
531 | .proc_handler = proc_dointvec_minmax, | |
532 | .extra1 = &zero, | |
533 | }, | |
534 | { | |
535 | .procname = "icmp_msgs_burst", | |
536 | .data = &sysctl_icmp_msgs_burst, | |
537 | .maxlen = sizeof(int), | |
538 | .mode = 0644, | |
539 | .proc_handler = proc_dointvec_minmax, | |
540 | .extra1 = &zero, | |
541 | }, | |
95766fff | 542 | { |
95766fff HA |
543 | .procname = "udp_mem", |
544 | .data = &sysctl_udp_mem, | |
545 | .maxlen = sizeof(sysctl_udp_mem), | |
546 | .mode = 0644, | |
8d987e5c | 547 | .proc_handler = proc_doulongvec_minmax, |
95766fff HA |
548 | }, |
549 | { | |
95766fff HA |
550 | .procname = "udp_rmem_min", |
551 | .data = &sysctl_udp_rmem_min, | |
552 | .maxlen = sizeof(sysctl_udp_rmem_min), | |
553 | .mode = 0644, | |
6d9f239a | 554 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 555 | .extra1 = &one |
95766fff HA |
556 | }, |
557 | { | |
95766fff HA |
558 | .procname = "udp_wmem_min", |
559 | .data = &sysctl_udp_wmem_min, | |
560 | .maxlen = sizeof(sysctl_udp_wmem_min), | |
561 | .mode = 0644, | |
6d9f239a | 562 | .proc_handler = proc_dointvec_minmax, |
5d37852b | 563 | .extra1 = &one |
95766fff | 564 | }, |
f8572d8f | 565 | { } |
1da177e4 | 566 | }; |
3e37c3f9 | 567 | |
68528f09 PE |
568 | static struct ctl_table ipv4_net_table[] = { |
569 | { | |
68528f09 PE |
570 | .procname = "icmp_echo_ignore_all", |
571 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, | |
572 | .maxlen = sizeof(int), | |
573 | .mode = 0644, | |
6d9f239a | 574 | .proc_handler = proc_dointvec |
68528f09 PE |
575 | }, |
576 | { | |
68528f09 PE |
577 | .procname = "icmp_echo_ignore_broadcasts", |
578 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, | |
579 | .maxlen = sizeof(int), | |
580 | .mode = 0644, | |
6d9f239a | 581 | .proc_handler = proc_dointvec |
68528f09 PE |
582 | }, |
583 | { | |
68528f09 PE |
584 | .procname = "icmp_ignore_bogus_error_responses", |
585 | .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, | |
586 | .maxlen = sizeof(int), | |
587 | .mode = 0644, | |
6d9f239a | 588 | .proc_handler = proc_dointvec |
68528f09 PE |
589 | }, |
590 | { | |
68528f09 PE |
591 | .procname = "icmp_errors_use_inbound_ifaddr", |
592 | .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, | |
593 | .maxlen = sizeof(int), | |
594 | .mode = 0644, | |
6d9f239a | 595 | .proc_handler = proc_dointvec |
68528f09 PE |
596 | }, |
597 | { | |
68528f09 PE |
598 | .procname = "icmp_ratelimit", |
599 | .data = &init_net.ipv4.sysctl_icmp_ratelimit, | |
600 | .maxlen = sizeof(int), | |
601 | .mode = 0644, | |
6d9f239a | 602 | .proc_handler = proc_dointvec_ms_jiffies, |
68528f09 PE |
603 | }, |
604 | { | |
68528f09 PE |
605 | .procname = "icmp_ratemask", |
606 | .data = &init_net.ipv4.sysctl_icmp_ratemask, | |
607 | .maxlen = sizeof(int), | |
608 | .mode = 0644, | |
6d9f239a | 609 | .proc_handler = proc_dointvec |
68528f09 | 610 | }, |
c319b4d7 VK |
611 | { |
612 | .procname = "ping_group_range", | |
ba6b918a | 613 | .data = &init_net.ipv4.ping_group_range.range, |
7064d16e | 614 | .maxlen = sizeof(gid_t)*2, |
c319b4d7 VK |
615 | .mode = 0644, |
616 | .proc_handler = ipv4_ping_group_range, | |
617 | }, | |
5d134f1c HFS |
618 | { |
619 | .procname = "tcp_ecn", | |
620 | .data = &init_net.ipv4.sysctl_tcp_ecn, | |
621 | .maxlen = sizeof(int), | |
622 | .mode = 0644, | |
623 | .proc_handler = proc_dointvec | |
624 | }, | |
49213555 DB |
625 | { |
626 | .procname = "tcp_ecn_fallback", | |
627 | .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, | |
628 | .maxlen = sizeof(int), | |
629 | .mode = 0644, | |
630 | .proc_handler = proc_dointvec | |
631 | }, | |
287b7f38 NB |
632 | { |
633 | .procname = "ip_dynaddr", | |
634 | .data = &init_net.ipv4.sysctl_ip_dynaddr, | |
635 | .maxlen = sizeof(int), | |
636 | .mode = 0644, | |
637 | .proc_handler = proc_dointvec | |
638 | }, | |
e21145a9 NB |
639 | { |
640 | .procname = "ip_early_demux", | |
641 | .data = &init_net.ipv4.sysctl_ip_early_demux, | |
642 | .maxlen = sizeof(int), | |
643 | .mode = 0644, | |
644 | .proc_handler = proc_dointvec | |
645 | }, | |
dddb64bc SAK |
646 | { |
647 | .procname = "udp_early_demux", | |
648 | .data = &init_net.ipv4.sysctl_udp_early_demux, | |
649 | .maxlen = sizeof(int), | |
650 | .mode = 0644, | |
651 | .proc_handler = proc_udp_early_demux | |
652 | }, | |
653 | { | |
654 | .procname = "tcp_early_demux", | |
655 | .data = &init_net.ipv4.sysctl_tcp_early_demux, | |
656 | .maxlen = sizeof(int), | |
657 | .mode = 0644, | |
658 | .proc_handler = proc_tcp_early_demux | |
659 | }, | |
fa50d974 NB |
660 | { |
661 | .procname = "ip_default_ttl", | |
662 | .data = &init_net.ipv4.sysctl_ip_default_ttl, | |
663 | .maxlen = sizeof(int), | |
664 | .mode = 0644, | |
665 | .proc_handler = proc_dointvec_minmax, | |
666 | .extra1 = &ip_ttl_min, | |
667 | .extra2 = &ip_ttl_max, | |
668 | }, | |
0bbf87d8 EB |
669 | { |
670 | .procname = "ip_local_port_range", | |
c9d8f1a6 CW |
671 | .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), |
672 | .data = &init_net.ipv4.ip_local_ports.range, | |
0bbf87d8 EB |
673 | .mode = 0644, |
674 | .proc_handler = ipv4_local_port_range, | |
675 | }, | |
122ff243 WC |
676 | { |
677 | .procname = "ip_local_reserved_ports", | |
678 | .data = &init_net.ipv4.sysctl_local_reserved_ports, | |
679 | .maxlen = 65536, | |
680 | .mode = 0644, | |
681 | .proc_handler = proc_do_large_bitmap, | |
682 | }, | |
974eda11 HFS |
683 | { |
684 | .procname = "ip_no_pmtu_disc", | |
685 | .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, | |
686 | .maxlen = sizeof(int), | |
687 | .mode = 0644, | |
688 | .proc_handler = proc_dointvec | |
689 | }, | |
f87c10a8 HFS |
690 | { |
691 | .procname = "ip_forward_use_pmtu", | |
692 | .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, | |
693 | .maxlen = sizeof(int), | |
694 | .mode = 0644, | |
695 | .proc_handler = proc_dointvec, | |
696 | }, | |
49a60158 VB |
697 | { |
698 | .procname = "ip_nonlocal_bind", | |
699 | .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, | |
700 | .maxlen = sizeof(int), | |
701 | .mode = 0644, | |
702 | .proc_handler = proc_dointvec | |
703 | }, | |
e110861f LC |
704 | { |
705 | .procname = "fwmark_reflect", | |
706 | .data = &init_net.ipv4.sysctl_fwmark_reflect, | |
707 | .maxlen = sizeof(int), | |
708 | .mode = 0644, | |
709 | .proc_handler = proc_dointvec, | |
710 | }, | |
84f39b08 LC |
711 | { |
712 | .procname = "tcp_fwmark_accept", | |
713 | .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, | |
714 | .maxlen = sizeof(int), | |
715 | .mode = 0644, | |
716 | .proc_handler = proc_dointvec, | |
717 | }, | |
6dd9a14e DA |
718 | #ifdef CONFIG_NET_L3_MASTER_DEV |
719 | { | |
720 | .procname = "tcp_l3mdev_accept", | |
721 | .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, | |
722 | .maxlen = sizeof(int), | |
723 | .mode = 0644, | |
724 | .proc_handler = proc_dointvec_minmax, | |
725 | .extra1 = &zero, | |
726 | .extra2 = &one, | |
727 | }, | |
728 | #endif | |
b0f9ca53 FD |
729 | { |
730 | .procname = "tcp_mtu_probing", | |
731 | .data = &init_net.ipv4.sysctl_tcp_mtu_probing, | |
732 | .maxlen = sizeof(int), | |
733 | .mode = 0644, | |
734 | .proc_handler = proc_dointvec, | |
735 | }, | |
736 | { | |
737 | .procname = "tcp_base_mss", | |
738 | .data = &init_net.ipv4.sysctl_tcp_base_mss, | |
739 | .maxlen = sizeof(int), | |
740 | .mode = 0644, | |
741 | .proc_handler = proc_dointvec, | |
742 | }, | |
6b58e0a5 FD |
743 | { |
744 | .procname = "tcp_probe_threshold", | |
745 | .data = &init_net.ipv4.sysctl_tcp_probe_threshold, | |
746 | .maxlen = sizeof(int), | |
747 | .mode = 0644, | |
748 | .proc_handler = proc_dointvec, | |
749 | }, | |
05cbc0db FD |
750 | { |
751 | .procname = "tcp_probe_interval", | |
752 | .data = &init_net.ipv4.sysctl_tcp_probe_interval, | |
753 | .maxlen = sizeof(int), | |
754 | .mode = 0644, | |
755 | .proc_handler = proc_dointvec, | |
756 | }, | |
df2cf4a7 PD |
757 | { |
758 | .procname = "igmp_link_local_mcast_reports", | |
87a8a2ae | 759 | .data = &init_net.ipv4.sysctl_igmp_llm_reports, |
df2cf4a7 PD |
760 | .maxlen = sizeof(int), |
761 | .mode = 0644, | |
762 | .proc_handler = proc_dointvec | |
763 | }, | |
815c5270 NB |
764 | { |
765 | .procname = "igmp_max_memberships", | |
766 | .data = &init_net.ipv4.sysctl_igmp_max_memberships, | |
767 | .maxlen = sizeof(int), | |
768 | .mode = 0644, | |
769 | .proc_handler = proc_dointvec | |
770 | }, | |
166b6b2d NB |
771 | { |
772 | .procname = "igmp_max_msf", | |
773 | .data = &init_net.ipv4.sysctl_igmp_max_msf, | |
774 | .maxlen = sizeof(int), | |
775 | .mode = 0644, | |
776 | .proc_handler = proc_dointvec | |
777 | }, | |
165094af NB |
778 | #ifdef CONFIG_IP_MULTICAST |
779 | { | |
780 | .procname = "igmp_qrv", | |
781 | .data = &init_net.ipv4.sysctl_igmp_qrv, | |
782 | .maxlen = sizeof(int), | |
783 | .mode = 0644, | |
784 | .proc_handler = proc_dointvec_minmax, | |
785 | .extra1 = &one | |
786 | }, | |
787 | #endif | |
13b287e8 NB |
788 | { |
789 | .procname = "tcp_keepalive_time", | |
790 | .data = &init_net.ipv4.sysctl_tcp_keepalive_time, | |
791 | .maxlen = sizeof(int), | |
792 | .mode = 0644, | |
793 | .proc_handler = proc_dointvec_jiffies, | |
794 | }, | |
9bd6861b NB |
795 | { |
796 | .procname = "tcp_keepalive_probes", | |
797 | .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, | |
798 | .maxlen = sizeof(int), | |
799 | .mode = 0644, | |
800 | .proc_handler = proc_dointvec | |
801 | }, | |
b840d15d NB |
802 | { |
803 | .procname = "tcp_keepalive_intvl", | |
804 | .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, | |
805 | .maxlen = sizeof(int), | |
806 | .mode = 0644, | |
807 | .proc_handler = proc_dointvec_jiffies, | |
808 | }, | |
6fa25166 NB |
809 | { |
810 | .procname = "tcp_syn_retries", | |
811 | .data = &init_net.ipv4.sysctl_tcp_syn_retries, | |
812 | .maxlen = sizeof(int), | |
813 | .mode = 0644, | |
814 | .proc_handler = proc_dointvec_minmax, | |
815 | .extra1 = &tcp_syn_retries_min, | |
816 | .extra2 = &tcp_syn_retries_max | |
817 | }, | |
7c083ecb NB |
818 | { |
819 | .procname = "tcp_synack_retries", | |
820 | .data = &init_net.ipv4.sysctl_tcp_synack_retries, | |
821 | .maxlen = sizeof(int), | |
822 | .mode = 0644, | |
823 | .proc_handler = proc_dointvec | |
824 | }, | |
12ed8244 NB |
825 | #ifdef CONFIG_SYN_COOKIES |
826 | { | |
827 | .procname = "tcp_syncookies", | |
828 | .data = &init_net.ipv4.sysctl_tcp_syncookies, | |
829 | .maxlen = sizeof(int), | |
830 | .mode = 0644, | |
831 | .proc_handler = proc_dointvec | |
832 | }, | |
833 | #endif | |
1043e25f NB |
834 | { |
835 | .procname = "tcp_reordering", | |
836 | .data = &init_net.ipv4.sysctl_tcp_reordering, | |
837 | .maxlen = sizeof(int), | |
838 | .mode = 0644, | |
839 | .proc_handler = proc_dointvec | |
840 | }, | |
ae5c3f40 NB |
841 | { |
842 | .procname = "tcp_retries1", | |
843 | .data = &init_net.ipv4.sysctl_tcp_retries1, | |
844 | .maxlen = sizeof(int), | |
845 | .mode = 0644, | |
846 | .proc_handler = proc_dointvec_minmax, | |
847 | .extra2 = &tcp_retr1_max | |
848 | }, | |
c6214a97 NB |
849 | { |
850 | .procname = "tcp_retries2", | |
851 | .data = &init_net.ipv4.sysctl_tcp_retries2, | |
852 | .maxlen = sizeof(int), | |
853 | .mode = 0644, | |
854 | .proc_handler = proc_dointvec | |
855 | }, | |
c402d9be NB |
856 | { |
857 | .procname = "tcp_orphan_retries", | |
858 | .data = &init_net.ipv4.sysctl_tcp_orphan_retries, | |
859 | .maxlen = sizeof(int), | |
860 | .mode = 0644, | |
861 | .proc_handler = proc_dointvec | |
862 | }, | |
1e579caa NB |
863 | { |
864 | .procname = "tcp_fin_timeout", | |
865 | .data = &init_net.ipv4.sysctl_tcp_fin_timeout, | |
866 | .maxlen = sizeof(int), | |
867 | .mode = 0644, | |
868 | .proc_handler = proc_dointvec_jiffies, | |
869 | }, | |
4979f2d9 NB |
870 | { |
871 | .procname = "tcp_notsent_lowat", | |
872 | .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, | |
873 | .maxlen = sizeof(unsigned int), | |
874 | .mode = 0644, | |
b007f090 | 875 | .proc_handler = proc_douintvec, |
4979f2d9 | 876 | }, |
56ab6b93 HY |
877 | { |
878 | .procname = "tcp_tw_reuse", | |
879 | .data = &init_net.ipv4.sysctl_tcp_tw_reuse, | |
880 | .maxlen = sizeof(int), | |
881 | .mode = 0644, | |
882 | .proc_handler = proc_dointvec | |
883 | }, | |
1946e672 HY |
884 | { |
885 | .procname = "tcp_max_tw_buckets", | |
886 | .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, | |
887 | .maxlen = sizeof(int), | |
888 | .mode = 0644, | |
889 | .proc_handler = proc_dointvec | |
890 | }, | |
fee83d09 HY |
891 | { |
892 | .procname = "tcp_max_syn_backlog", | |
893 | .data = &init_net.ipv4.sysctl_max_syn_backlog, | |
894 | .maxlen = sizeof(int), | |
895 | .mode = 0644, | |
896 | .proc_handler = proc_dointvec | |
897 | }, | |
e1cfcbe8 HY |
898 | { |
899 | .procname = "tcp_fastopen", | |
900 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
901 | .maxlen = sizeof(int), | |
902 | .mode = 0644, | |
903 | .proc_handler = proc_dointvec, | |
904 | }, | |
43713848 HY |
905 | { |
906 | .procname = "tcp_fastopen_key", | |
907 | .mode = 0600, | |
908 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
909 | .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), | |
910 | .proc_handler = proc_tcp_fastopen_key, | |
911 | }, | |
3733be14 HY |
912 | { |
913 | .procname = "tcp_fastopen_blackhole_timeout_sec", | |
914 | .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, | |
915 | .maxlen = sizeof(int), | |
916 | .mode = 0644, | |
917 | .proc_handler = proc_tfo_blackhole_detect_timeout, | |
918 | .extra1 = &zero, | |
919 | }, | |
a6db4494 DA |
920 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
921 | { | |
922 | .procname = "fib_multipath_use_neigh", | |
923 | .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, | |
924 | .maxlen = sizeof(int), | |
925 | .mode = 0644, | |
926 | .proc_handler = proc_dointvec_minmax, | |
bf4e0a3d NA |
927 | .extra1 = &zero, |
928 | .extra2 = &one, | |
929 | }, | |
930 | { | |
931 | .procname = "fib_multipath_hash_policy", | |
932 | .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, | |
933 | .maxlen = sizeof(int), | |
934 | .mode = 0644, | |
935 | .proc_handler = proc_dointvec_minmax, | |
a6db4494 DA |
936 | .extra1 = &zero, |
937 | .extra2 = &one, | |
938 | }, | |
939 | #endif | |
4548b683 KJ |
940 | { |
941 | .procname = "ip_unprivileged_port_start", | |
942 | .maxlen = sizeof(int), | |
943 | .data = &init_net.ipv4.sysctl_ip_prot_sock, | |
944 | .mode = 0644, | |
945 | .proc_handler = ipv4_privileged_ports, | |
946 | }, | |
63a6fff3 RS |
947 | #ifdef CONFIG_NET_L3_MASTER_DEV |
948 | { | |
949 | .procname = "udp_l3mdev_accept", | |
950 | .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, | |
951 | .maxlen = sizeof(int), | |
952 | .mode = 0644, | |
953 | .proc_handler = proc_dointvec_minmax, | |
954 | .extra1 = &zero, | |
955 | .extra2 = &one, | |
956 | }, | |
957 | #endif | |
f9301034 ED |
958 | { |
959 | .procname = "tcp_sack", | |
960 | .data = &init_net.ipv4.sysctl_tcp_sack, | |
961 | .maxlen = sizeof(int), | |
962 | .mode = 0644, | |
963 | .proc_handler = proc_dointvec | |
964 | }, | |
9bb37ef0 ED |
965 | { |
966 | .procname = "tcp_window_scaling", | |
967 | .data = &init_net.ipv4.sysctl_tcp_window_scaling, | |
968 | .maxlen = sizeof(int), | |
969 | .mode = 0644, | |
970 | .proc_handler = proc_dointvec | |
971 | }, | |
5d2ed052 ED |
972 | { |
973 | .procname = "tcp_timestamps", | |
974 | .data = &init_net.ipv4.sysctl_tcp_timestamps, | |
975 | .maxlen = sizeof(int), | |
976 | .mode = 0644, | |
977 | .proc_handler = proc_dointvec | |
978 | }, | |
2ae21cf5 ED |
979 | { |
980 | .procname = "tcp_early_retrans", | |
981 | .data = &init_net.ipv4.sysctl_tcp_early_retrans, | |
982 | .maxlen = sizeof(int), | |
983 | .mode = 0644, | |
984 | .proc_handler = proc_dointvec_minmax, | |
985 | .extra1 = &zero, | |
986 | .extra2 = &four, | |
987 | }, | |
e20223f1 ED |
988 | { |
989 | .procname = "tcp_recovery", | |
990 | .data = &init_net.ipv4.sysctl_tcp_recovery, | |
991 | .maxlen = sizeof(int), | |
992 | .mode = 0644, | |
993 | .proc_handler = proc_dointvec, | |
994 | }, | |
2c04ac8a ED |
995 | { |
996 | .procname = "tcp_thin_linear_timeouts", | |
997 | .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts, | |
998 | .maxlen = sizeof(int), | |
999 | .mode = 0644, | |
1000 | .proc_handler = proc_dointvec | |
1001 | }, | |
b510f0d2 ED |
1002 | { |
1003 | .procname = "tcp_slow_start_after_idle", | |
1004 | .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle, | |
1005 | .maxlen = sizeof(int), | |
1006 | .mode = 0644, | |
1007 | .proc_handler = proc_dointvec | |
1008 | }, | |
e0a1e5b5 ED |
1009 | { |
1010 | .procname = "tcp_retrans_collapse", | |
1011 | .data = &init_net.ipv4.sysctl_tcp_retrans_collapse, | |
1012 | .maxlen = sizeof(int), | |
1013 | .mode = 0644, | |
1014 | .proc_handler = proc_dointvec | |
1015 | }, | |
3f4c7c6f ED |
1016 | { |
1017 | .procname = "tcp_stdurg", | |
1018 | .data = &init_net.ipv4.sysctl_tcp_stdurg, | |
1019 | .maxlen = sizeof(int), | |
1020 | .mode = 0644, | |
1021 | .proc_handler = proc_dointvec | |
1022 | }, | |
625357aa ED |
1023 | { |
1024 | .procname = "tcp_rfc1337", | |
1025 | .data = &init_net.ipv4.sysctl_tcp_rfc1337, | |
1026 | .maxlen = sizeof(int), | |
1027 | .mode = 0644, | |
1028 | .proc_handler = proc_dointvec | |
1029 | }, | |
65c9410c ED |
1030 | { |
1031 | .procname = "tcp_abort_on_overflow", | |
1032 | .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow, | |
1033 | .maxlen = sizeof(int), | |
1034 | .mode = 0644, | |
1035 | .proc_handler = proc_dointvec | |
1036 | }, | |
0bc65a28 ED |
1037 | { |
1038 | .procname = "tcp_fack", | |
1039 | .data = &init_net.ipv4.sysctl_tcp_fack, | |
1040 | .maxlen = sizeof(int), | |
1041 | .mode = 0644, | |
1042 | .proc_handler = proc_dointvec | |
1043 | }, | |
c6e21803 ED |
1044 | { |
1045 | .procname = "tcp_max_reordering", | |
1046 | .data = &init_net.ipv4.sysctl_tcp_max_reordering, | |
1047 | .maxlen = sizeof(int), | |
1048 | .mode = 0644, | |
1049 | .proc_handler = proc_dointvec | |
1050 | }, | |
6496f6bd ED |
1051 | { |
1052 | .procname = "tcp_dsack", | |
1053 | .data = &init_net.ipv4.sysctl_tcp_dsack, | |
1054 | .maxlen = sizeof(int), | |
1055 | .mode = 0644, | |
1056 | .proc_handler = proc_dointvec | |
1057 | }, | |
0c12654a ED |
1058 | { |
1059 | .procname = "tcp_app_win", | |
1060 | .data = &init_net.ipv4.sysctl_tcp_app_win, | |
1061 | .maxlen = sizeof(int), | |
1062 | .mode = 0644, | |
1063 | .proc_handler = proc_dointvec | |
1064 | }, | |
94f0893e ED |
1065 | { |
1066 | .procname = "tcp_adv_win_scale", | |
1067 | .data = &init_net.ipv4.sysctl_tcp_adv_win_scale, | |
1068 | .maxlen = sizeof(int), | |
1069 | .mode = 0644, | |
1070 | .proc_handler = proc_dointvec_minmax, | |
1071 | .extra1 = &tcp_adv_win_scale_min, | |
1072 | .extra2 = &tcp_adv_win_scale_max, | |
1073 | }, | |
af9b69a7 ED |
1074 | { |
1075 | .procname = "tcp_frto", | |
1076 | .data = &init_net.ipv4.sysctl_tcp_frto, | |
1077 | .maxlen = sizeof(int), | |
1078 | .mode = 0644, | |
1079 | .proc_handler = proc_dointvec | |
1080 | }, | |
ec36e416 ED |
1081 | { |
1082 | .procname = "tcp_no_metrics_save", | |
1083 | .data = &init_net.ipv4.sysctl_tcp_nometrics_save, | |
1084 | .maxlen = sizeof(int), | |
1085 | .mode = 0644, | |
1086 | .proc_handler = proc_dointvec, | |
1087 | }, | |
4540c0cf ED |
1088 | { |
1089 | .procname = "tcp_moderate_rcvbuf", | |
1090 | .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf, | |
1091 | .maxlen = sizeof(int), | |
1092 | .mode = 0644, | |
1093 | .proc_handler = proc_dointvec, | |
1094 | }, | |
d06a9904 ED |
1095 | { |
1096 | .procname = "tcp_tso_win_divisor", | |
1097 | .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor, | |
1098 | .maxlen = sizeof(int), | |
1099 | .mode = 0644, | |
1100 | .proc_handler = proc_dointvec, | |
1101 | }, | |
ceef9ab6 ED |
1102 | { |
1103 | .procname = "tcp_workaround_signed_windows", | |
1104 | .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows, | |
1105 | .maxlen = sizeof(int), | |
1106 | .mode = 0644, | |
1107 | .proc_handler = proc_dointvec | |
1108 | }, | |
9184d8bb ED |
1109 | { |
1110 | .procname = "tcp_limit_output_bytes", | |
1111 | .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes, | |
1112 | .maxlen = sizeof(int), | |
1113 | .mode = 0644, | |
1114 | .proc_handler = proc_dointvec | |
1115 | }, | |
b530b681 ED |
1116 | { |
1117 | .procname = "tcp_challenge_ack_limit", | |
1118 | .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit, | |
1119 | .maxlen = sizeof(int), | |
1120 | .mode = 0644, | |
1121 | .proc_handler = proc_dointvec | |
1122 | }, | |
26e9596e ED |
1123 | { |
1124 | .procname = "tcp_min_tso_segs", | |
1125 | .data = &init_net.ipv4.sysctl_tcp_min_tso_segs, | |
1126 | .maxlen = sizeof(int), | |
1127 | .mode = 0644, | |
1128 | .proc_handler = proc_dointvec_minmax, | |
1129 | .extra1 = &one, | |
1130 | .extra2 = &gso_max_segs, | |
1131 | }, | |
bd239704 ED |
1132 | { |
1133 | .procname = "tcp_min_rtt_wlen", | |
1134 | .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen, | |
1135 | .maxlen = sizeof(int), | |
1136 | .mode = 0644, | |
1137 | .proc_handler = proc_dointvec | |
1138 | }, | |
790f00e1 ED |
1139 | { |
1140 | .procname = "tcp_autocorking", | |
1141 | .data = &init_net.ipv4.sysctl_tcp_autocorking, | |
1142 | .maxlen = sizeof(int), | |
1143 | .mode = 0644, | |
1144 | .proc_handler = proc_dointvec_minmax, | |
1145 | .extra1 = &zero, | |
1146 | .extra2 = &one, | |
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); |