Merge branch 'master' into next
[cascardo/ovs.git] / datapath / linux-2.6 / compat-2.6 / net_namespace-ip_gre.c
1 #include <linux/version.h>
2 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
3
4 #include <linux/sched.h>
5 #include <net/net_namespace.h>
6 #include <net/netns/generic.h>
7
8 /* This trivial implementation assumes that there is only a single pernet
9  * generic device registered and that the caller is well behaved.  It only
10  * weakly attempts to check that these conditions are true. */
11
12 static bool device_registered;
13 static void *ng_data;
14
15 int register_pernet_gen_device(int *id, struct pernet_operations *ops)
16 {
17         BUG_ON(device_registered);
18
19         *id = 1;
20         device_registered = true;
21
22         if (ops->init == NULL)
23                 return 0;
24         return ops->init(NULL);
25 }
26
27 void unregister_pernet_gen_device(int id, struct pernet_operations *ops)
28 {
29         device_registered = false;
30         if (ops->exit)
31                 ops->exit(NULL);
32 }
33
34 int net_assign_generic(struct net *net, int id, void *data)
35 {
36         BUG_ON(id != 1);
37
38         ng_data = data;
39         return 0;
40 }
41
42 void *net_generic(struct net *net, int id)
43 {
44         BUG_ON(id != 1);
45
46         return ng_data;
47 }
48
49 #endif /* kernel < 2.6.26 */