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