]> git.openfabrics.org - ~aditr/compat.git/commitdiff
compat: Identify existence of netdev_notifier_info_to_dev
authorVladimir Sokolovsky <vlad@mellanox.com>
Sun, 12 Feb 2017 09:34:18 +0000 (11:34 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Sun, 12 Feb 2017 09:34:18 +0000 (11:34 +0200)
Instead of saying that all kernels under 3.11.0 don't have
implementation of netdev_notifier_info_to_dev() check it specifically.
Otherwise, the 3rd argument to notifier call will be handled in a wrong
way.

Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
config/rdma.m4
include/linux/compat-3.11.h
include/linux/netdevice.h

index 8bcb1bdfff0209d8319a9f69ff281753516e94f4..2c70b771e8932c421faf3b515ca9b17373fcc03f 100644 (file)
@@ -4326,6 +4326,32 @@ AC_DEFUN([LINUX_CONFIG_COMPAT],
                AC_MSG_RESULT(no)
        ])
 
+       AC_MSG_CHECKING([if has netdev_notifier_info_to_dev])
+       LB_LINUX_TRY_COMPILE([
+       #include <linux/netdevice.h>
+       ],[
+               return netdev_notifier_info_to_dev(NULL) ? 1 : 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_NETDEV_NOTIFIER_INFO_TO_DEV, 1,
+                       [netdev_notifier_info_to_dev is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if mm has register_netdevice_notifier_rh])
+       LB_LINUX_TRY_COMPILE([
+       #include <linux/netdevice.h>
+       ],[
+               return register_netdevice_notifier_rh(NULL);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_REGISTER_NETDEVICE_NOTIFIER_RH, 1,
+                       [register_netdevice_notifier_rh is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
 ])
 #
 # COMPAT_CONFIG_HEADERS
index 7dec516e92899e5b4c3825476fd0014001f033e4..1d63631f80d15c547f346d39ec87ee243737cbe1 100644 (file)
 #define PF_IB          AF_IB
 #endif /* AF_IB */
 
-#define netdev_notifier_info_to_dev LINUX_BACKPORT(netdev_notifier_info_to_dev)
-static inline struct net_device *
-netdev_notifier_info_to_dev(void *ptr)
-{
-       return (struct net_device *)ptr;
-}
-
 #if !defined(CONFIG_COMPAT_IFLA_VF_LINK_STATE_MAX)
 enum {
        IFLA_VF_LINK_STATE_AUTO,        /* link state of the uplink */
index 346afa26149be63c516b4f315ef680d10a60b7c0..261ced87ecd2a64deb52e264b5d3e3fdb8c9f230 100644 (file)
@@ -108,4 +108,18 @@ static inline void netif_trans_update(struct net_device *dev)
 }
 #endif
 
+#ifdef HAVE_REGISTER_NETDEVICE_NOTIFIER_RH
+#define register_netdevice_notifier register_netdevice_notifier_rh
+#define unregister_netdevice_notifier unregister_netdevice_notifier_rh
+#endif
+
+#ifndef HAVE_NETDEV_NOTIFIER_INFO_TO_DEV
+#define netdev_notifier_info_to_dev LINUX_BACKPORT(netdev_notifier_info_to_dev)
+static inline struct net_device *
+netdev_notifier_info_to_dev(void *ptr)
+{
+       return (struct net_device *)ptr;
+}
+#endif
+
 #endif /* _COMPAT_LINUX_NETDEVICE_H */