From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH net-2.6.26 1/8][SIT]: Introduce empty struct sit_net and init/exit net ops.
Date: Tue, 15 Apr 2008 17:27:49 +0400 [thread overview]
Message-ID: <4804AD55.4090605@openvz.org> (raw)
In-Reply-To: <4804ACFA.1040003@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv6/sit.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 91e46fb..aa6efc2 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -52,6 +52,8 @@
#include <net/inet_ecn.h>
#include <net/xfrm.h>
#include <net/dsfield.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
/*
This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c
@@ -66,6 +68,10 @@ static int ipip6_fb_tunnel_init(struct net_device *dev);
static int ipip6_tunnel_init(struct net_device *dev);
static void ipip6_tunnel_setup(struct net_device *dev);
+static int sit_net_id;
+struct sit_net {
+};
+
static struct net_device *ipip6_fb_tunnel_dev;
static struct ip_tunnel *tunnels_r_l[HASH_SIZE];
@@ -1068,6 +1074,41 @@ static void __exit sit_destroy_tunnels(void)
}
}
+static int sit_init_net(struct net *net)
+{
+ int err;
+ struct sit_net *sitn;
+
+ err = -ENOMEM;
+ sitn = kmalloc(sizeof(struct sit_net), GFP_KERNEL);
+ if (sitn == NULL)
+ goto err_alloc;
+
+ err = net_assign_generic(net, sit_net_id, sitn);
+ if (err < 0)
+ goto err_assign;
+
+ return 0;
+
+err_assign:
+ kfree(sitn);
+err_alloc:
+ return err;
+}
+
+static void sit_exit_net(struct net *net)
+{
+ struct sit_net *sitn;
+
+ sitn = net_generic(net, sit_net_id);
+ kfree(sitn);
+}
+
+static struct pernet_operations sit_net_ops = {
+ .init = sit_init_net,
+ .exit = sit_exit_net,
+};
+
static void __exit sit_cleanup(void)
{
xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
@@ -1076,6 +1117,8 @@ static void __exit sit_cleanup(void)
sit_destroy_tunnels();
unregister_netdevice(ipip6_fb_tunnel_dev);
rtnl_unlock();
+
+ unregister_pernet_gen_device(sit_net_id, &sit_net_ops);
}
static int __init sit_init(void)
@@ -1101,6 +1144,10 @@ static int __init sit_init(void)
if ((err = register_netdev(ipip6_fb_tunnel_dev)))
goto err2;
+ err = register_pernet_gen_device(&sit_net_id, &sit_net_ops);
+ if (err < 0)
+ goto err3;
+
out:
return err;
err2:
@@ -1108,6 +1155,9 @@ static int __init sit_init(void)
err1:
xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
goto out;
+err3:
+ unregister_netdevice(ipip6_fb_tunnel_dev);
+ goto err1;
}
module_init(sit_init);
--
1.5.3.4
next prev parent reply other threads:[~2008-04-15 12:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-15 13:26 [PATCH net-2.6.26 0/8][SIT]: Make SIT tunnel work in net namespaces Pavel Emelyanov
2008-04-15 13:27 ` Pavel Emelyanov [this message]
2008-04-15 13:29 ` [PATCH net-2.6.26 2/8][SIT]: Add net/sit_net argument to some functions Pavel Emelyanov
2008-04-15 13:31 ` [PATCH net-2.6.26 3/8][SIT]: Use proper net in hash-lookup functions Pavel Emelyanov
2008-04-15 13:33 ` [PATCH net-2.6.26 4/8][SIT]: Make the fallback tunnel device per-net Pavel Emelyanov
2008-04-15 13:34 ` [PATCH net-2.6.26 5/8][SIT]: Make tunnels hashes per-net Pavel Emelyanov
2008-04-15 13:36 ` [PATCH net-2.6.26 6/8][SIT]: Use proper net in routing calls Pavel Emelyanov
2008-04-15 13:37 ` [PATCH net-2.6.26 7/8][SIT]: Allow to create SIT tunnels in net namespaces Pavel Emelyanov
2008-04-15 13:39 ` [PATCH net-2.6.26 8/8][SIT]: Allow for IPPROTO_IPV6 protocol in namespaces Pavel Emelyanov
2008-04-16 8:19 ` [PATCH net-2.6.26 0/8][SIT]: Make SIT tunnel work in net namespaces David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4804AD55.4090605@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.