diff options
Diffstat (limited to 'net/ipv6/proc.c')
-rw-r--r-- | net/ipv6/proc.c | 29 |
1 files changed, 24 insertions, 5 deletions
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 | ||