@@ -556,44 +556,35 @@
.release = single_release,
};
-void cleanup_procfs(void)
+static void __net_exit batmanadv_net_exit(struct net *net)
{
- if (proc_transt_global_file)
remove_proc_entry(PROC_FILE_TRANST_GLOBAL, proc_batman_dir);
- if (proc_transt_local_file)
remove_proc_entry(PROC_FILE_TRANST_LOCAL, proc_batman_dir);
- if (proc_originators_file)
remove_proc_entry(PROC_FILE_ORIGINATORS, proc_batman_dir);
- if (proc_orig_interval_file)
remove_proc_entry(PROC_FILE_ORIG_INTERVAL, proc_batman_dir);
- if (proc_interface_file)
remove_proc_entry(PROC_FILE_INTERFACES, proc_batman_dir);
- if (proc_vis_data_file)
remove_proc_entry(PROC_FILE_VIS_DATA, proc_batman_dir);
- if (proc_vis_srv_file)
remove_proc_entry(PROC_FILE_VIS_SRV, proc_batman_dir);
- if (proc_aggr_file)
remove_proc_entry(PROC_FILE_AGGR, proc_batman_dir);
- if (proc_batman_dir)
#ifdef __NET_NET_NAMESPACE_H
- remove_proc_entry(PROC_ROOT_DIR, init_net.proc_net);
+ remove_proc_entry(PROC_ROOT_DIR, net->proc_net);
#else
remove_proc_entry(PROC_ROOT_DIR, proc_net);
#endif
}
-int setup_procfs(void)
+static int __net_init batmanadv_net_init(struct net *net)
{
#ifdef __NET_NET_NAMESPACE_H
- proc_batman_dir = proc_mkdir(PROC_ROOT_DIR, init_net.proc_net);
+ proc_batman_dir = proc_mkdir(PROC_ROOT_DIR, net->proc_net);
#else
proc_batman_dir = proc_mkdir(PROC_ROOT_DIR, proc_net);
#endif
@@ -610,7 +601,7 @@
proc_interface_file->proc_fops = &proc_interfaces_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_INTERFACES);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -621,7 +612,7 @@
proc_orig_interval_file->proc_fops = &proc_orig_interval_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_ORIG_INTERVAL);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -631,7 +622,7 @@
proc_originators_file->proc_fops = &proc_originators_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_ORIGINATORS);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -641,7 +632,7 @@
proc_transt_local_file->proc_fops = &proc_transt_local_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_LOCAL);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -651,7 +642,7 @@
proc_transt_global_file->proc_fops = &proc_transt_global_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_TRANST_GLOBAL);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -662,7 +653,7 @@
proc_vis_srv_file->proc_fops = &proc_vis_srv_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_SRV);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -672,7 +663,7 @@
proc_vis_data_file->proc_fops = &proc_vis_data_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_VIS_DATA);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
@@ -682,9 +673,25 @@
proc_aggr_file->proc_fops = &proc_aggr_fops;
} else {
printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_AGGR);
- cleanup_procfs();
+ batmanadv_net_exit(net);
return -EFAULT;
}
return 0;
}
+
+static struct pernet_operations batmanadv_net_ops = {
+ .init = batmanadv_net_init,
+ .exit = batmanadv_net_exit,
+};
+
+
+int setup_procfs(void)
+{
+ return register_pernet_subsys(&batmanadv_net_ops);
+}
+
+void cleanup_procfs(void)
+{
+ return unregister_pernet_subsys(&batmanadv_net_ops);
+}