datapath: Extend compatibility code for genl_register_mc_group().
[openvswitch] / datapath / linux-2.6 / compat-2.6 / genetlink.inc
1 /* -*- c -*- */
2
3 #include <net/genetlink.h>
4 #include <linux/version.h>
5
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
7 #include <linux/mutex.h>
8
9 static DEFINE_MUTEX(mc_group_mutex);
10
11 int genl_register_mc_group(struct genl_family *family,
12                            struct genl_multicast_group *grp)
13 {
14         static int next_group = GENL_FIRST_MCGROUP;
15
16         mutex_lock(&mc_group_mutex);
17         grp->id = next_group;
18         grp->family = family;
19
20         if (++next_group > GENL_LAST_MCGROUP)
21                 next_group = GENL_FIRST_MCGROUP;
22         mutex_unlock(&mc_group_mutex);
23
24         return 0;
25 }
26 #endif /* kernel < 2.6.23 */