datapath: Add support for kernel 4.4
[cascardo/ovs.git] / datapath / linux / compat / genetlink-openvswitch.c
index ab149c3..5b0ecfa 100644 (file)
@@ -2,26 +2,6 @@
 #include <linux/version.h>
 
 #ifndef HAVE_GENL_NOTIFY_TAKES_FAMILY
-
-#undef genl_notify
-
-void rpl_genl_notify(struct rpl_genl_family *family, struct sk_buff *skb,
-                    struct net *net, u32 portid, u32 group,
-                    struct nlmsghdr *nlh, gfp_t flags)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
-       struct sock *sk = net->genl_sock;
-       int report = 0;
-
-       if (nlh)
-               report = nlmsg_report(nlh);
-
-       nlmsg_notify(sk, skb, portid, group, report, flags);
-#else
-       genl_notify(skb, net, portid, group, nlh, flags);
-#endif
-}
-
 int rpl___genl_register_family(struct rpl_genl_family *f)
 {
        int err;
@@ -52,4 +32,24 @@ error:
        return err;
 
 }
-#endif /* kernel version < 3.13.0 */
+EXPORT_SYMBOL_GPL(rpl___genl_register_family);
+#endif /* HAVE_GENL_NOTIFY_TAKES_FAMILY */
+
+#ifdef HAVE_GENL_NOTIFY_TAKES_NET
+
+#undef genl_notify
+
+void rpl_genl_notify(struct genl_family *family, struct sk_buff *skb,
+                    struct genl_info *info, u32 group, gfp_t flags)
+{
+       struct net *net = genl_info_net(info);
+       u32 portid = info->snd_portid;
+       struct nlmsghdr *nlh = info->nlhdr;
+
+#ifdef HAVE_GENL_NOTIFY_TAKES_FAMILY
+       genl_notify(family, skb, net, portid, group, nlh, flags);
+#else
+       genl_notify(skb, net, portid, group, nlh, flags);
+#endif
+}
+#endif /* HAVE_GENL_NOTIFY_TAKES_NET */