File: net_namespace.h

package info (click to toggle)
openvswitch 2.3.0%2Bgit20140819-3
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 24,156 kB
  • sloc: sh: 223,720; ansic: 153,459; python: 13,272; xml: 12,432; perl: 408; makefile: 382
file content (52 lines) | stat: -rw-r--r-- 1,689 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __NET_NET_NAMESPACE_WRAPPER_H
#define __NET_NET_NAMESPACE_WRAPPER_H 1

#include_next <net/net_namespace.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
/* for 2.6.32* */
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

#define register_pernet_device rpl_register_pernet_gen_device
#define unregister_pernet_device rpl_unregister_pernet_gen_device

int compat_init_net(struct net *net, struct rpl_pernet_operations *pnet);
void compat_exit_net(struct net *net, struct rpl_pernet_operations *pnet);

#define DEFINE_COMPAT_PNET_REG_FUNC(TYPE)					\
									\
static struct rpl_pernet_operations *pnet_gen_##TYPE;			\
static int compat_init_net_gen_##TYPE(struct net *net)	\
{									\
	return compat_init_net(net, pnet_gen_##TYPE);			\
}									\
									\
static void compat_exit_net_gen_##TYPE(struct net *net)	\
{									\
	compat_exit_net(net, pnet_gen_##TYPE);				\
}									\
									\
static int rpl_register_pernet_gen_##TYPE(struct rpl_pernet_operations *rpl_pnet)	\
{										\
	pnet_gen_##TYPE = rpl_pnet;						\
	rpl_pnet->ops.init = compat_init_net_gen_##TYPE;			\
	rpl_pnet->ops.exit = compat_exit_net_gen_##TYPE;			\
	return register_pernet_gen_##TYPE(pnet_gen_##TYPE->id, &rpl_pnet->ops); \
}											\
											\
static void rpl_unregister_pernet_gen_##TYPE(struct rpl_pernet_operations *rpl_pnet)		\
{											\
	unregister_pernet_gen_##TYPE(*pnet_gen_##TYPE->id, &rpl_pnet->ops);		\
}
#else
#define DEFINE_COMPAT_PNET_REG_FUNC(TYPE)
#endif /* 2.6.33 */

#endif /* net/net_namespace.h wrapper */