Following patch improves compat net-namespace code which is mostly targeted for 2.6.32 kernel. Now it allows multiple users register_pernet_gen_device(). Upcoming vxlan restructuring patch needs this patch.
Signed-off-by: Pravin Shelar <pshe...@nicira.com> --- datapath/linux/compat/include/net/net_namespace.h | 5 +++-- datapath/linux/compat/net_namespace.c | 17 ++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/datapath/linux/compat/include/net/net_namespace.h b/datapath/linux/compat/include/net/net_namespace.h index 77f0a16..134c646 100644 --- a/datapath/linux/compat/include/net/net_namespace.h +++ b/datapath/linux/compat/include/net/net_namespace.h @@ -64,14 +64,15 @@ static inline struct net *read_pnet(struct net * const *pnet) #endif /* 2.6.29 */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) -#define pernet_operations rpl_pernet_operations -struct pernet_operations { +struct rpl_pernet_operations { int (*init)(struct net *net); void (*exit)(struct net *net); int *id; size_t size; + struct pernet_operations ops; }; +#define pernet_operations rpl_pernet_operations extern int rpl_register_pernet_gen_device(struct rpl_pernet_operations *ops); extern void rpl_unregister_pernet_gen_device(struct rpl_pernet_operations *ops); diff --git a/datapath/linux/compat/net_namespace.c b/datapath/linux/compat/net_namespace.c index 4e8a891..39b4a28 100644 --- a/datapath/linux/compat/net_namespace.c +++ b/datapath/linux/compat/net_namespace.c @@ -5,7 +5,7 @@ #undef pernet_operations -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) static int net_assign_generic(struct net *net, int id, void *data); #endif @@ -44,9 +44,10 @@ static void __net_exit compat_exit_net(struct net *net, struct rpl_pernet_operat } #endif -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31) #define DEFINE_PNET_REG_FUNC(PNET_TYPE) \ - static struct rpl_pernet_operations *pnet_##PNET_TYPE; \ + \ +static struct rpl_pernet_operations *pnet_##PNET_TYPE; \ static int __net_init compat_init_net_##PNET_TYPE(struct net *net) \ { \ return compat_init_net(net, pnet_##PNET_TYPE); \ @@ -65,18 +66,20 @@ static struct pernet_operations pnet_compat_##PNET_TYPE = { \ int rpl_register_pernet_##PNET_TYPE(struct rpl_pernet_operations *rpl_pnet) \ { \ pnet_##PNET_TYPE = rpl_pnet; \ - return register_pernet_##PNET_TYPE(pnet_##PNET_TYPE->id, &pnet_compat_##PNET_TYPE); \ + rpl_pnet->ops = pnet_compat_##PNET_TYPE; \ + return register_pernet_##PNET_TYPE(pnet_##PNET_TYPE->id, &rpl_pnet->ops); \ } \ \ -void rpl_unregister_pernet_##PNET_TYPE(struct rpl_pernet_operations *pnet) \ +void rpl_unregister_pernet_##PNET_TYPE(struct rpl_pernet_operations *rpl_pnet) \ { \ - unregister_pernet_##PNET_TYPE(*pnet->id, &pnet_compat_##PNET_TYPE); \ + pnet_##PNET_TYPE = rpl_pnet; \ + unregister_pernet_##PNET_TYPE(*pnet_##PNET_TYPE->id, &rpl_pnet->ops); \ } DEFINE_PNET_REG_FUNC(gen_device); #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) -#define MAX_DATA_COUNT 1 +#define MAX_DATA_COUNT 2 static struct net *net; static void *__ovs_net_data[MAX_DATA_COUNT]; -- 1.7.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev