datapath: Add support for kernels 3.13
[sliver-openvswitch.git] / datapath / linux / compat / genetlink-openvswitch.c
1 #include <net/genetlink.h>
2 #include <linux/version.h>
3
4 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
5
6 #undef genl_notify
7
8 void rpl_genl_notify(struct rpl_genl_family *family, struct sk_buff *skb,
9                      struct net *net, u32 portid, u32 group,
10                      struct nlmsghdr *nlh, gfp_t flags)
11 {
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
13         struct sock *sk = net->genl_sock;
14         int report = 0;
15
16         if (nlh)
17                 report = nlmsg_report(nlh);
18
19         nlmsg_notify(sk, skb, portid, group, report, flags);
20 #else
21         genl_notify(skb, net, portid, group, nlh, flags);
22 #endif
23 }
24
25 int rpl___genl_register_family(struct rpl_genl_family *f)
26 {
27         int err;
28
29         f->compat_family.id = f->id;
30         f->compat_family.hdrsize = f->hdrsize;
31         strncpy(f->compat_family.name, f->name, GENL_NAMSIZ);
32         f->compat_family.version = f->version;
33         f->compat_family.maxattr = f->maxattr;
34         f->compat_family.netnsok = f->netnsok;
35 #ifdef HAVE_PARALLEL_OPS
36         f->compat_family.parallel_ops = f->parallel_ops;
37 #endif
38         err = genl_register_family_with_ops(&f->compat_family,
39                                             (struct genl_ops *) f->ops, f->n_ops);
40         if (err)
41                 goto error;
42
43         if (f->mcgrps) {
44                 /* Need to Fix GROUP_ID() for more than one group. */
45                 BUG_ON(f->n_mcgrps > 1);
46                 err = genl_register_mc_group(&f->compat_family,
47                                              (struct genl_multicast_group *) f->mcgrps);
48                 if (err)
49                         goto error;
50         }
51 error:
52         return err;
53
54 }
55 #endif /* kernel version < 3.13.0 */