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

[VLAN]: Introduce the vlan_net structure and init/exit net ops.

Unlike TUN, it is empty from the very beginning, and will 
be eventually populated later.
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 a9fde260
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include "vlan.h" #include "vlan.h"
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
/* Global VLAN variables */ /* Global VLAN variables */
int vlan_net_id;
/* Our listing of VLAN group(s) */ /* Our listing of VLAN group(s) */
static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE]; static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
...@@ -625,6 +628,41 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -625,6 +628,41 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
return err; return err;
} }
static int vlan_init_net(struct net *net)
{
int err;
struct vlan_net *vn;
err = -ENOMEM;
vn = kzalloc(sizeof(struct vlan_net), GFP_KERNEL);
if (vn == NULL)
goto err_alloc;
err = net_assign_generic(net, vlan_net_id, vn);
if (err < 0)
goto err_assign;
return 0;
err_assign:
kfree(vn);
err_alloc:
return err;
}
static void vlan_exit_net(struct net *net)
{
struct vlan_net *vn;
vn = net_generic(net, vlan_net_id);
kfree(vn);
}
static struct pernet_operations vlan_net_ops = {
.init = vlan_init_net,
.exit = vlan_exit_net,
};
static int __init vlan_proto_init(void) static int __init vlan_proto_init(void)
{ {
int err; int err;
...@@ -632,6 +670,10 @@ static int __init vlan_proto_init(void) ...@@ -632,6 +670,10 @@ static int __init vlan_proto_init(void)
pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
pr_info("All bugs added by %s\n", vlan_buggyright); pr_info("All bugs added by %s\n", vlan_buggyright);
err = register_pernet_gen_device(&vlan_net_id, &vlan_net_ops);
if (err < 0)
goto err0;
err = vlan_proc_init(); err = vlan_proc_init();
if (err < 0) if (err < 0)
goto err1; goto err1;
...@@ -653,6 +695,8 @@ static int __init vlan_proto_init(void) ...@@ -653,6 +695,8 @@ static int __init vlan_proto_init(void)
err2: err2:
vlan_proc_cleanup(); vlan_proc_cleanup();
err1: err1:
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
err0:
return err; return err;
} }
...@@ -673,6 +717,8 @@ static void __exit vlan_cleanup_module(void) ...@@ -673,6 +717,8 @@ static void __exit vlan_cleanup_module(void)
vlan_proc_cleanup(); vlan_proc_cleanup();
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
synchronize_net(); synchronize_net();
} }
......
...@@ -50,4 +50,9 @@ static inline int is_vlan_dev(struct net_device *dev) ...@@ -50,4 +50,9 @@ static inline int is_vlan_dev(struct net_device *dev)
return dev->priv_flags & IFF_802_1Q_VLAN; return dev->priv_flags & IFF_802_1Q_VLAN;
} }
extern int vlan_net_id;
struct vlan_net {
};
#endif /* !(__BEN_VLAN_802_1Q_INC__) */ #endif /* !(__BEN_VLAN_802_1Q_INC__) */
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