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