Backport from the upstream commit, this commit is necessary for using 2.3.x on RHEL with updated kernel, and absolutely more sane than the kernel version adjudgement: commit 572e54faff70760f4bfe4a7cffc9553e6743199e Author: Flavio Leitner <f...@redhat.com> Date: Fri Aug 28 21:52:36 2015 -0300
datapath: check for rx handler register Red Hat Enterprise Linux 6 has backported the netdev RX handler facility so use the netdev_rx_handler_register as an indicator. The handler prototype changed between 2.6.36 and 2.6.39 since there could be backports in any stage, don't look at the kernel version, but at the prototype. Signed-off-by: Flavio Leitner <f...@redhat.com> Signed-off-by: Jesse Gross <je...@nicira.com> Signed-off-by: Wanlong Gao <wanlong....@easystack.cn> --- acinclude.m4 | 4 ++++ datapath/linux/compat/dev-openvswitch.c | 2 +- datapath/linux/compat/include/linux/netdevice.h | 2 +- datapath/vport-netdev.c | 9 +++++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 9819a91..dc0bebe 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -291,6 +291,10 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [can_checksum_protocol]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netdev_features_t]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [pcpu_sw_netstats]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netdev_rx_handler_register]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [net_device_extended]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [rx_handler_func_t.*pskb], + [OVS_DEFINE([HAVE_RX_HANDLER_PSKB])]) OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32]) diff --git a/datapath/linux/compat/dev-openvswitch.c b/datapath/linux/compat/dev-openvswitch.c index 1035fe8..5524634 100644 --- a/datapath/linux/compat/dev-openvswitch.c +++ b/datapath/linux/compat/dev-openvswitch.c @@ -33,7 +33,7 @@ void dev_disable_lro(struct net_device *dev) { } #endif /* HAVE_DEV_DISABLE_LRO */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) || \ +#if !defined HAVE_NETDEV_RX_HANDLER_REGISTER || \ defined HAVE_RHEL_OVS_HOOK static int nr_bridges; diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h index d726390..f9ebb2b 100644 --- a/datapath/linux/compat/include/linux/netdevice.h +++ b/datapath/linux/compat/include/linux/netdevice.h @@ -22,7 +22,7 @@ extern void unregister_netdevice_many(struct list_head *head); extern void dev_disable_lro(struct net_device *dev); #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) || \ +#if !defined HAVE_NETDEV_RX_HANDLER_REGISTER || \ defined HAVE_RHEL_OVS_HOOK #ifdef HAVE_RHEL_OVS_HOOK diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c index 102e6d0..64347a3 100644 --- a/datapath/vport-netdev.c +++ b/datapath/vport-netdev.c @@ -36,7 +36,7 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +#if defined HAVE_RX_HANDLER_PSKB /* 2.6.39 and above or backports */ /* Called with rcu_read_lock and bottom-halves disabled. */ static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb) { @@ -254,7 +254,7 @@ drop: /* Returns null if this device is not attached to a datapath. */ struct vport *ovs_netdev_get_vport(struct net_device *dev) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) || \ +#if defined HAVE_NETDEV_RX_HANDLER_REGISTER || \ defined HAVE_RHEL_OVS_HOOK #if IFF_OVS_DATAPATH != 0 if (likely(dev->priv_flags & IFF_OVS_DATAPATH)) @@ -264,8 +264,13 @@ struct vport *ovs_netdev_get_vport(struct net_device *dev) #ifdef HAVE_RHEL_OVS_HOOK return (struct vport *)rcu_dereference_rtnl(dev->ax25_ptr); #else +#ifdef HAVE_NET_DEVICE_EXTENDED + return (struct vport *) + rcu_dereference_rtnl(netdev_extended(dev)->rx_handler_data); +#else return (struct vport *)rcu_dereference_rtnl(dev->rx_handler_data); #endif +#endif else return NULL; #else -- 2.5.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev