diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2012-06-14 05:16:42 -0400 |
|---|---|---|
| committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-19 01:46:19 -0500 |
| commit | d727abcb2355566a3372ee1810f156fba75112b7 (patch) | |
| tree | ed23c68e67d158d251a8e4677e40dcd9c8fdb541 /include/net | |
| parent | 499dcf2024092e5cce41d05599a5b51d1f92031a (diff) | |
netns: Deduplicate and fix copy_net_ns when !CONFIG_NET_NS
The copy of copy_net_ns used when the network stack is not
built is broken as it does not return -EINVAL when attempting
to create a new network namespace. We don't even have
a previous network namespace.
Since we need a copy of copy_net_ns in net/net_namespace.h that is
available when the networking stack is not built at all move the
correct version of copy_net_ns from net_namespace.c into net_namespace.h
Leaving us with just 2 versions of copy_net_ns. One version for when
we compile in network namespace suport and another stub for all other
occasions.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'include/net')
| -rw-r--r-- | include/net/net_namespace.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 95e64664118..32dcb6085eb 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
| @@ -126,16 +126,19 @@ struct net { | |||
| 126 | /* Init's network namespace */ | 126 | /* Init's network namespace */ |
| 127 | extern struct net init_net; | 127 | extern struct net init_net; |
| 128 | 128 | ||
| 129 | #ifdef CONFIG_NET | 129 | #ifdef CONFIG_NET_NS |
| 130 | extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns); | 130 | extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns); |
| 131 | 131 | ||
| 132 | #else /* CONFIG_NET */ | 132 | #else /* CONFIG_NET_NS */ |
| 133 | static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) | 133 | #include <linux/sched.h> |
| 134 | #include <linux/nsproxy.h> | ||
| 135 | static inline struct net *copy_net_ns(unsigned long flags, struct net *old_net) | ||
| 134 | { | 136 | { |
| 135 | /* There is nothing to copy so this is a noop */ | 137 | if (flags & CLONE_NEWNET) |
| 136 | return net_ns; | 138 | return ERR_PTR(-EINVAL); |
| 139 | return old_net; | ||
| 137 | } | 140 | } |
| 138 | #endif /* CONFIG_NET */ | 141 | #endif /* CONFIG_NET_NS */ |
| 139 | 142 | ||
| 140 | 143 | ||
| 141 | extern struct list_head net_namespace_list; | 144 | extern struct list_head net_namespace_list; |
