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