diff options
-rw-r--r-- | net/ipv4/proc.c | 27 | ||||
-rw-r--r-- | net/ipv6/proc.c | 29 |
2 files changed, 46 insertions, 10 deletions
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 8156c26f9337..24ae23bb5124 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -426,25 +426,42 @@ static const struct file_operations netstat_seq_fops = { | |||
426 | .release = single_release, | 426 | .release = single_release, |
427 | }; | 427 | }; |
428 | 428 | ||
429 | static __net_init int ip_proc_init_net(struct net *net) | ||
430 | { | ||
431 | if (!proc_net_fops_create(net, "sockstat", S_IRUGO, &sockstat_seq_fops)) | ||
432 | return -ENOMEM; | ||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static __net_exit void ip_proc_exit_net(struct net *net) | ||
437 | { | ||
438 | proc_net_remove(net, "sockstat"); | ||
439 | } | ||
440 | |||
441 | static __net_initdata struct pernet_operations ip_proc_ops = { | ||
442 | .init = ip_proc_init_net, | ||
443 | .exit = ip_proc_exit_net, | ||
444 | }; | ||
445 | |||
429 | int __init ip_misc_proc_init(void) | 446 | int __init ip_misc_proc_init(void) |
430 | { | 447 | { |
431 | int rc = 0; | 448 | int rc = 0; |
432 | 449 | ||
450 | if (register_pernet_subsys(&ip_proc_ops)) | ||
451 | goto out_pernet; | ||
452 | |||
433 | if (!proc_net_fops_create(&init_net, "netstat", S_IRUGO, &netstat_seq_fops)) | 453 | if (!proc_net_fops_create(&init_net, "netstat", S_IRUGO, &netstat_seq_fops)) |
434 | goto out_netstat; | 454 | goto out_netstat; |
435 | 455 | ||
436 | if (!proc_net_fops_create(&init_net, "snmp", S_IRUGO, &snmp_seq_fops)) | 456 | if (!proc_net_fops_create(&init_net, "snmp", S_IRUGO, &snmp_seq_fops)) |
437 | goto out_snmp; | 457 | goto out_snmp; |
438 | |||
439 | if (!proc_net_fops_create(&init_net, "sockstat", S_IRUGO, &sockstat_seq_fops)) | ||
440 | goto out_sockstat; | ||
441 | out: | 458 | out: |
442 | return rc; | 459 | return rc; |
443 | out_sockstat: | ||
444 | proc_net_remove(&init_net, "snmp"); | ||
445 | out_snmp: | 460 | out_snmp: |
446 | proc_net_remove(&init_net, "netstat"); | 461 | proc_net_remove(&init_net, "netstat"); |
447 | out_netstat: | 462 | out_netstat: |
463 | unregister_pernet_subsys(&ip_proc_ops); | ||
464 | out_pernet: | ||
448 | rc = -ENOMEM; | 465 | rc = -ENOMEM; |
449 | goto out; | 466 | goto out; |
450 | } | 467 | } |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 4b9d5a905725..562366015e54 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -243,27 +243,45 @@ int snmp6_unregister_dev(struct inet6_dev *idev) | |||
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
245 | 245 | ||
246 | static int ipv6_proc_init_net(struct net *net) | ||
247 | { | ||
248 | if (!proc_net_fops_create(net, "sockstat6", S_IRUGO, | ||
249 | &sockstat6_seq_fops)) | ||
250 | return -ENOMEM; | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static void ipv6_proc_exit_net(struct net *net) | ||
255 | { | ||
256 | proc_net_remove(net, "sockstat6"); | ||
257 | } | ||
258 | |||
259 | static struct pernet_operations ipv6_proc_ops = { | ||
260 | .init = ipv6_proc_init_net, | ||
261 | .exit = ipv6_proc_exit_net, | ||
262 | }; | ||
263 | |||
246 | int __init ipv6_misc_proc_init(void) | 264 | int __init ipv6_misc_proc_init(void) |
247 | { | 265 | { |
248 | int rc = 0; | 266 | int rc = 0; |
249 | 267 | ||
268 | if (register_pernet_subsys(&ipv6_proc_ops)) | ||
269 | goto proc_net_fail; | ||
270 | |||
250 | if (!proc_net_fops_create(&init_net, "snmp6", S_IRUGO, &snmp6_seq_fops)) | 271 | if (!proc_net_fops_create(&init_net, "snmp6", S_IRUGO, &snmp6_seq_fops)) |
251 | goto proc_snmp6_fail; | 272 | goto proc_snmp6_fail; |
252 | 273 | ||
253 | proc_net_devsnmp6 = proc_mkdir("dev_snmp6", init_net.proc_net); | 274 | proc_net_devsnmp6 = proc_mkdir("dev_snmp6", init_net.proc_net); |
254 | if (!proc_net_devsnmp6) | 275 | if (!proc_net_devsnmp6) |
255 | goto proc_dev_snmp6_fail; | 276 | goto proc_dev_snmp6_fail; |
256 | |||
257 | if (!proc_net_fops_create(&init_net, "sockstat6", S_IRUGO, &sockstat6_seq_fops)) | ||
258 | goto proc_sockstat6_fail; | ||
259 | out: | 277 | out: |
260 | return rc; | 278 | return rc; |
261 | 279 | ||
262 | proc_sockstat6_fail: | ||
263 | proc_net_remove(&init_net, "dev_snmp6"); | ||
264 | proc_dev_snmp6_fail: | 280 | proc_dev_snmp6_fail: |
265 | proc_net_remove(&init_net, "snmp6"); | 281 | proc_net_remove(&init_net, "snmp6"); |
266 | proc_snmp6_fail: | 282 | proc_snmp6_fail: |
283 | unregister_pernet_subsys(&ipv6_proc_ops); | ||
284 | proc_net_fail: | ||
267 | rc = -ENOMEM; | 285 | rc = -ENOMEM; |
268 | goto out; | 286 | goto out; |
269 | } | 287 | } |
@@ -273,5 +291,6 @@ void ipv6_misc_proc_exit(void) | |||
273 | proc_net_remove(&init_net, "sockstat6"); | 291 | proc_net_remove(&init_net, "sockstat6"); |
274 | proc_net_remove(&init_net, "dev_snmp6"); | 292 | proc_net_remove(&init_net, "dev_snmp6"); |
275 | proc_net_remove(&init_net, "snmp6"); | 293 | proc_net_remove(&init_net, "snmp6"); |
294 | unregister_pernet_subsys(&ipv6_proc_ops); | ||
276 | } | 295 | } |
277 | 296 | ||