+static int ip6_tnl_init_net(struct net *net)
+{
+ int err;
+ struct ip6_tnl_net *ip6n;
+
+ err = -ENOMEM;
+ ip6n = kmalloc(sizeof(struct ip6_tnl_net), GFP_KERNEL);
+ if (ip6n == NULL)
+ goto err_alloc;
+
+ err = net_assign_generic(net, ip6_tnl_net_id, ip6n);
+ if (err < 0)
+ goto err_assign;
+
+ return 0;
+
+err_assign:
+ kfree(ip6n);
+err_alloc:
+ return err;
+}
+
+static void ip6_tnl_exit_net(struct net *net)
+{
+ struct ip6_tnl_net *ip6n;
+
+ ip6n = net_generic(net, ip6_tnl_net_id);
+ kfree(ip6n);
+}
+
+static struct pernet_operations ip6_tnl_net_ops = {
+ .init = ip6_tnl_init_net,
+ .exit = ip6_tnl_exit_net,
+};
+