-static int vxlan_init_net(struct net *net)
-{
- struct vxlan_net *vn = net_generic(net, vxlan_net_id);
- unsigned int h;
-
- spin_lock_init(&vn->sock_lock);
-
- for (h = 0; h < PORT_HASH_SIZE; ++h)
- INIT_HLIST_HEAD(&vn->sock_list[h]);
-
- return 0;
-}
-
-static struct pernet_operations vxlan_net_ops = {
- .init = vxlan_init_net,
- .id = &vxlan_net_id,
- .size = sizeof(struct vxlan_net),
-};
-
-static int refcnt;
-static DEFINE_MUTEX(init_lock);
-DEFINE_COMPAT_PNET_REG_FUNC(device);
-
-static int vxlan_init_module(void)
-{
- int err = 0;
-
- mutex_lock(&init_lock);
- if (refcnt)
- goto out;
- err = register_pernet_device(&vxlan_net_ops);
-out:
- if (!err)
- refcnt++;
- mutex_unlock(&init_lock);
- return err;
-}
-
-static void vxlan_cleanup_module(void)
-{
- mutex_lock(&init_lock);
- refcnt--;
- if (refcnt)
- goto out;
- unregister_pernet_device(&vxlan_net_ops);
-out:
- mutex_unlock(&init_lock);
-}