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