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][IPIP]: Introduce empty ipip_net structure and net init/exit ops.
Date: Tue, 15 Apr 2008 16:26:16 +0400 [thread overview]
Message-ID: <48049EE8.8090606@openvz.org> (raw)
In-Reply-To: <48049E9C.1020207@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv4/ipip.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 894bce9..e39a4c2 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -115,10 +115,16 @@
#include <net/ipip.h>
#include <net/inet_ecn.h>
#include <net/xfrm.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
#define HASH_SIZE 16
#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
+static int ipip_net_id;
+struct ipip_net {
+};
+
static int ipip_fb_tunnel_init(struct net_device *dev);
static int ipip_tunnel_init(struct net_device *dev);
static void ipip_tunnel_setup(struct net_device *dev);
@@ -867,6 +873,41 @@ static struct xfrm_tunnel ipip_handler = {
static char banner[] __initdata =
KERN_INFO "IPv4 over IPv4 tunneling driver\n";
+static int ipip_init_net(struct net *net)
+{
+ int err;
+ struct ipip_net *ipn;
+
+ err = -ENOMEM;
+ ipn = kmalloc(sizeof(struct ipip_net), GFP_KERNEL);
+ if (ipn == NULL)
+ goto err_alloc;
+
+ err = net_assign_generic(net, ipip_net_id, ipn);
+ if (err < 0)
+ goto err_assign;
+
+ return 0;
+
+err_assign:
+ kfree(ipn);
+err_alloc:
+ return err;
+}
+
+static void ipip_exit_net(struct net *net)
+{
+ struct ipip_net *ipn;
+
+ ipn = net_generic(net, ipip_net_id);
+ kfree(ipn);
+}
+
+static struct pernet_operations ipip_net_ops = {
+ .init = ipip_init_net,
+ .exit = ipip_exit_net,
+};
+
static int __init ipip_init(void)
{
int err;
@@ -890,6 +931,10 @@ static int __init ipip_init(void)
if ((err = register_netdev(ipip_fb_tunnel_dev)))
goto err2;
+
+ err = register_pernet_gen_device(&ipip_net_id, &ipip_net_ops);
+ if (err)
+ goto err3;
out:
return err;
err2:
@@ -897,6 +942,9 @@ static int __init ipip_init(void)
err1:
xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
goto out;
+err3:
+ unregister_netdevice(ipip_fb_tunnel_dev);
+ goto err1;
}
static void __exit ipip_destroy_tunnels(void)
@@ -922,6 +970,8 @@ static void __exit ipip_fini(void)
ipip_destroy_tunnels();
unregister_netdevice(ipip_fb_tunnel_dev);
rtnl_unlock();
+
+ unregister_pernet_gen_device(ipip_net_id, &ipip_net_ops);
}
module_init(ipip_init);
--
1.5.3.4
next prev parent reply other threads:[~2008-04-15 11:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-15 12:25 [PATCH net-2.6.26 0/8][IPIP]: Make IPIP tunnel work in net namespaces Pavel Emelyanov
2008-04-15 12:26 ` Pavel Emelyanov [this message]
2008-04-15 12:29 ` [PATCH net-2.6.26 2/8][IPIP]: Make the fallback tunnel device per-net Pavel Emelyanov
2008-04-15 12:31 ` [PATCH net-2.6.26 3/8][IPIP]: Add net/ipip_net argument to some functions Pavel Emelyanov
2008-04-15 12:33 ` [PATCH net-2.6.26 4/8][IPIP]: Use proper net in hash-lookup functions Pavel Emelyanov
2008-04-15 12:36 ` [PATCH net-2.6.26 5/8][IPIP]: Make tunnels hashes per net Pavel Emelyanov
2008-04-15 12:38 ` [PATCH net-2.6.26 6/8][IPIP]: Use proper net in (mostly) routing calls Pavel Emelyanov
2008-04-15 12:39 ` [PATCH net-2.6.26 7/8][IPIP]: Allow to create IPIP tunnels in net namespaces Pavel Emelyanov
2008-04-15 12:41 ` [PATCH net-2.6.26 8/8][IPIP]: Allow for IPPROTO_IPIP protocol in namespaces Pavel Emelyanov
2008-04-16 8:08 ` [PATCH net-2.6.26 0/8][IPIP]: Make IPIP 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=48049EE8.8090606@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).