aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-27 01:04:26 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:46 -0400
commit9dd776b6d7b0b85966b6ddd03e2b2aae59012ab1 (patch)
treeed92aee1f242bb31a0965a4156063eac916ae15e /include
parent8b41d1887db718be9a2cd9e18c58ce25a4c7fd93 (diff)
[NET]: Add network namespace clone & unshare support.
This patch allows you to create a new network namespace using sys_clone, or sys_unshare. As the network namespace is still experimental and under development clone and unshare support is only made available when CONFIG_NET_NS is selected at compile time. As this patch introduces network namespace support into code paths that exist when the CONFIG_NET is not selected there are a few additions made to net_namespace.h to allow a few more functions to be used when the networking stack is not compiled in. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/net/net_namespace.h18
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 313c6b6e774f..a4a141055c44 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -27,6 +27,7 @@
27#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ 27#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
28#define CLONE_NEWIPC 0x08000000 /* New ipcs */ 28#define CLONE_NEWIPC 0x08000000 /* New ipcs */
29#define CLONE_NEWUSER 0x10000000 /* New user namespace */ 29#define CLONE_NEWUSER 0x10000000 /* New user namespace */
30#define CLONE_NEWNET 0x20000000 /* New network namespace */
30 31
31/* 32/*
32 * Scheduling policies 33 * Scheduling policies
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index ac8f8304094e..3ea4194613ed 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -38,11 +38,23 @@ extern struct net init_net;
38 38
39extern struct list_head net_namespace_list; 39extern struct list_head net_namespace_list;
40 40
41#ifdef CONFIG_NET
42extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns);
43#else
44static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
45{
46 /* There is nothing to copy so this is a noop */
47 return net_ns;
48}
49#endif
50
41extern void __put_net(struct net *net); 51extern void __put_net(struct net *net);
42 52
43static inline struct net *get_net(struct net *net) 53static inline struct net *get_net(struct net *net)
44{ 54{
55#ifdef CONFIG_NET
45 atomic_inc(&net->count); 56 atomic_inc(&net->count);
57#endif
46 return net; 58 return net;
47} 59}
48 60
@@ -60,19 +72,25 @@ static inline struct net *maybe_get_net(struct net *net)
60 72
61static inline void put_net(struct net *net) 73static inline void put_net(struct net *net)
62{ 74{
75#ifdef CONFIG_NET
63 if (atomic_dec_and_test(&net->count)) 76 if (atomic_dec_and_test(&net->count))
64 __put_net(net); 77 __put_net(net);
78#endif
65} 79}
66 80
67static inline struct net *hold_net(struct net *net) 81static inline struct net *hold_net(struct net *net)
68{ 82{
83#ifdef CONFIG_NET
69 atomic_inc(&net->use_count); 84 atomic_inc(&net->use_count);
85#endif
70 return net; 86 return net;
71} 87}
72 88
73static inline void release_net(struct net *net) 89static inline void release_net(struct net *net)
74{ 90{
91#ifdef CONFIG_NET
75 atomic_dec(&net->use_count); 92 atomic_dec(&net->use_count);
93#endif
76} 94}
77 95
78extern void net_lock(void); 96extern void net_lock(void);