Commit cd1c7014 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[VLAN]: Add a net argument to proc init and cleanup calls.

All proc files will be created in each net, so prepare them for 
this change now, not to mess it with real creation patch.

The net != &init_net checks in them are for git-bisect sanity, 
but I will drop them soon.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Acked-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9ed0f0e
...@@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net) ...@@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net)
if (err < 0) if (err < 0)
goto err_assign; goto err_assign;
err = vlan_proc_init(net);
if (err < 0)
goto err_proc;
return 0; return 0;
err_proc:
/* nothing */
err_assign: err_assign:
kfree(vn); kfree(vn);
err_alloc: err_alloc:
...@@ -655,6 +661,7 @@ static void vlan_exit_net(struct net *net) ...@@ -655,6 +661,7 @@ static void vlan_exit_net(struct net *net)
struct vlan_net *vn; struct vlan_net *vn;
vn = net_generic(net, vlan_net_id); vn = net_generic(net, vlan_net_id);
vlan_proc_cleanup(net);
kfree(vn); kfree(vn);
} }
...@@ -674,10 +681,6 @@ static int __init vlan_proto_init(void) ...@@ -674,10 +681,6 @@ static int __init vlan_proto_init(void)
if (err < 0) if (err < 0)
goto err0; goto err0;
err = vlan_proc_init();
if (err < 0)
goto err1;
err = register_netdevice_notifier(&vlan_notifier_block); err = register_netdevice_notifier(&vlan_notifier_block);
if (err < 0) if (err < 0)
goto err2; goto err2;
...@@ -693,8 +696,6 @@ static int __init vlan_proto_init(void) ...@@ -693,8 +696,6 @@ static int __init vlan_proto_init(void)
err3: err3:
unregister_netdevice_notifier(&vlan_notifier_block); unregister_netdevice_notifier(&vlan_notifier_block);
err2: err2:
vlan_proc_cleanup();
err1:
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
err0: err0:
return err; return err;
...@@ -715,8 +716,6 @@ static void __exit vlan_cleanup_module(void) ...@@ -715,8 +716,6 @@ static void __exit vlan_cleanup_module(void)
for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
BUG_ON(!hlist_empty(&vlan_group_hash[i])); BUG_ON(!hlist_empty(&vlan_group_hash[i]));
vlan_proc_cleanup();
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
synchronize_net(); synchronize_net();
......
...@@ -138,8 +138,11 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = { ...@@ -138,8 +138,11 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
* Clean up /proc/net/vlan entries * Clean up /proc/net/vlan entries
*/ */
void vlan_proc_cleanup(void) void vlan_proc_cleanup(struct net *net)
{ {
if (net != &init_net)
return;
if (proc_vlan_conf) if (proc_vlan_conf)
remove_proc_entry(name_conf, proc_vlan_dir); remove_proc_entry(name_conf, proc_vlan_dir);
...@@ -155,8 +158,11 @@ void vlan_proc_cleanup(void) ...@@ -155,8 +158,11 @@ void vlan_proc_cleanup(void)
* Create /proc/net/vlan entries * Create /proc/net/vlan entries
*/ */
int __init vlan_proc_init(void) int vlan_proc_init(struct net *net)
{ {
if (net != &init_net)
return 0;
proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net);
if (!proc_vlan_dir) if (!proc_vlan_dir)
goto err; goto err;
...@@ -169,7 +175,7 @@ int __init vlan_proc_init(void) ...@@ -169,7 +175,7 @@ int __init vlan_proc_init(void)
err: err:
pr_err("%s: can't create entry in proc filesystem!\n", __func__); pr_err("%s: can't create entry in proc filesystem!\n", __func__);
vlan_proc_cleanup(); vlan_proc_cleanup(net);
return -ENOBUFS; return -ENOBUFS;
} }
......
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
#define __BEN_VLAN_PROC_INC__ #define __BEN_VLAN_PROC_INC__
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int vlan_proc_init(void); struct net;
int vlan_proc_init(struct net *net);
int vlan_proc_rem_dev(struct net_device *vlandev); int vlan_proc_rem_dev(struct net_device *vlandev);
int vlan_proc_add_dev(struct net_device *vlandev); int vlan_proc_add_dev(struct net_device *vlandev);
void vlan_proc_cleanup(void); void vlan_proc_cleanup(struct net *net);
#else /* No CONFIG_PROC_FS */ #else /* No CONFIG_PROC_FS */
#define vlan_proc_init() (0) #define vlan_proc_init(net) (0)
#define vlan_proc_cleanup() do {} while (0) #define vlan_proc_cleanup(net) do {} while (0)
#define vlan_proc_add_dev(dev) ({(void)(dev), 0; }) #define vlan_proc_add_dev(dev) ({(void)(dev), 0; })
#define vlan_proc_rem_dev(dev) ({(void)(dev), 0; }) #define vlan_proc_rem_dev(dev) ({(void)(dev), 0; })
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment