From: Vladimir Sokolovsky Date: Sun, 12 Feb 2017 09:34:18 +0000 (+0200) Subject: compat: Identify existence of netdev_notifier_info_to_dev X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=702032fddbd9e67f2a7df889b8d583e513172b9c;p=~tnikolova%2Fcompat%2F.git compat: Identify existence of netdev_notifier_info_to_dev 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 Signed-off-by: Vladimir Sokolovsky --- diff --git a/config/rdma.m4 b/config/rdma.m4 index 8bcb1bd..2c70b77 100644 --- a/config/rdma.m4 +++ b/config/rdma.m4 @@ -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 + ],[ + 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 + ],[ + 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 diff --git a/include/linux/compat-3.11.h b/include/linux/compat-3.11.h index 7dec516..1d63631 100644 --- a/include/linux/compat-3.11.h +++ b/include/linux/compat-3.11.h @@ -12,13 +12,6 @@ #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 */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 346afa2..261ced8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -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 */