[ovs-dev] [PATCH 5/5] datapath: check for rx_handler register

Flavio Leitner fbl at redhat.com
Fri Aug 28 13:37:12 UTC 2015


Red Hat Enterprise Linux 6 has backported the netdev RX
handler facility so use the netdev_rx_handler_register as
an indicator if the kernel is earlier than 2.3.36 or has
the facitilty backported.

Signed-off-by: Flavio Leitner <fbl at redhat.com>
---
 acinclude.m4                                    |  2 ++
 datapath/linux/compat/dev-openvswitch.c         |  2 +-
 datapath/linux/compat/include/linux/netdevice.h |  2 +-
 datapath/vport-netdev.c                         | 12 +++++++++---
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 73bbe8c..f77d4fc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -338,6 +338,8 @@ 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/netfilter.h], [nf_hookfn.*nf_hook_ops],
                   [OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])])
 
diff --git a/datapath/linux/compat/dev-openvswitch.c b/datapath/linux/compat/dev-openvswitch.c
index 256d581..38ec8fe 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 3deb93d..0fb2144 100644
--- a/datapath/linux/compat/include/linux/netdevice.h
+++ b/datapath/linux/compat/include/linux/netdevice.h
@@ -43,7 +43,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 de85087..5d1e74f 100644
--- a/datapath/vport-netdev.c
+++ b/datapath/vport-netdev.c
@@ -38,7 +38,8 @@
 static struct vport_ops ovs_netdev_vport_ops;
 static void netdev_port_receive(struct vport *vport, struct sk_buff *skb);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) || \
+    defined HAVE_NETDEV_RX_HANDLER_REGISTER
 /* Called with rcu_read_lock and bottom-halves disabled. */
 static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb)
 {
@@ -257,7 +258,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
 #ifdef HAVE_OVS_DATAPATH
 	if (likely(dev->priv_flags & IFF_OVS_DATAPATH))
@@ -267,8 +268,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
@@ -294,7 +300,7 @@ void ovs_netdev_exit(void)
 	ovs_vport_ops_unregister(&ovs_netdev_vport_ops);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) && \
+#if !defined HAVE_NETDEV_RX_HANDLER_REGISTER && \
     !defined HAVE_RHEL_OVS_HOOK
 /*
  * Enforces, mutual exclusion with the Linux bridge module, by declaring and
-- 
2.1.0




More information about the dev mailing list