From a312e00197ea4876bba541121f32b676bc92b829 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 16:17:04 -0800 Subject: [PATCH] Add initial backport support for network namespaces We simply declare the overly used init_net sprinkled all over the kernel, and declare its. All other code should that uses network namespaces should be ifdef'd for now as well as inclusion of net/net_namespace.h as we do not backport the network namespace implemetnation at all, we simply try to nullify its effect. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.24.c | 7 +++++++ include/linux/compat-2.6.24.h | 31 +++++++++++++++++++++++++++++++ include/linux/compat-2.6.26.h | 2 ++ 3 files changed, 40 insertions(+) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index 347f6f7d65fe..31a9212f84e1 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -15,6 +15,13 @@ #include +/* + * We simply won't use it though, just declare it for our wrappers and + * for usage with tons of code that makes mention to it. + */ +struct net init_net; +EXPORT_SYMBOL(init_net); + /* Part of net/ethernet/eth.c as of 2.6.24 */ char *print_mac(char *buf, const u8 *addr) { diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index ac9489f7fe12..246156c26921 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -20,6 +20,37 @@ #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) +struct proc_dir_entry; +struct net_device; +struct net { + atomic_t count; /* To decided when the network + * namespace should be freed. + */ + atomic_t use_count; /* To track references we + * destroy on demand + */ + struct list_head list; /* list of network namespaces */ + struct work_struct work; /* work struct for freeing */ + + struct proc_dir_entry *proc_net; + struct proc_dir_entry *proc_net_stat; + struct proc_dir_entry *proc_net_root; + + struct net_device *loopback_dev; /* The loopback */ + + struct list_head dev_base_head; + struct hlist_head *dev_name_head; + struct hlist_head *dev_index_head; +}; + +#ifdef CONFIG_NET +/* Init's network namespace */ +extern struct net init_net; +#define INIT_NET_NS(net_ns) .net_ns = &init_net, +#else +#define INIT_NET_NS(net_ns) +#endif + /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index b7c3b05793cf..0ea99b1503a7 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,7 +11,9 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include +#endif /* These jiffie helpers added as of 2.6.26 */ -- 2.30.2