From 370404c827390a6e6d967513cec2bc256f343a27 Mon Sep 17 00:00:00 2001
From: James Page <james.page@ubuntu.com>
Date: Wed, 21 Aug 2013 10:15:30 +0100
Subject: [PATCH 5/5] datapath: Add support for Linux 3.11

Use netdev_notifier_info_to_dev in dp_device_event, provide
for < 3.11 in compat layer.  This fix was based on this commit
from the 3.11 kernel:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/net/openvswitch?id=351638e7deeed2ec8ce451b53d33921b3da68f83

Signed-off-by: James Page <james.page@ubuntu.com>
---
 FAQ                                             |  2 +-
 datapath/datapath.c                             |  4 ++--
 datapath/dp_notify.c                            |  4 ++--
 datapath/linux/compat/include/linux/netdevice.h | 11 +++++++++++
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/FAQ b/FAQ
index 4bbb07e..59f5ca8 100644
--- a/FAQ
+++ b/FAQ
@@ -148,7 +148,7 @@ A: The following table lists the Linux kernel versions against which the
        1.9.x      2.6.18 to 3.8
        1.10.x     2.6.18 to 3.8
        1.11.x     2.6.18 to 3.8
-       1.12.x     2.6.18 to 3.10
+       1.12.x     2.6.18 to 3.11
 
    Open vSwitch userspace should also work with the Linux kernel module
    built into Linux 3.3 and later.
diff --git a/datapath/datapath.c b/datapath/datapath.c
index d0f2fc1..1377e3f 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -61,8 +61,8 @@
 #include "vport-internal_dev.h"
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
-    LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
-#error Kernels before 2.6.18 or after 3.9 are not supported by this version of Open vSwitch.
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
+#error Kernels before 2.6.18 or after 3.11 are not supported by this version of Open vSwitch.
 #endif
 
 #define REHASH_FLOW_INTERVAL (10 * 60 * HZ)
diff --git a/datapath/dp_notify.c b/datapath/dp_notify.c
index c9eeafe..c3056f5 100644
--- a/datapath/dp_notify.c
+++ b/datapath/dp_notify.c
@@ -26,8 +26,8 @@
 static int dp_device_event(struct notifier_block *unused, unsigned long event,
 			   void *ptr)
 {
-	struct net_device *dev = ptr;
-	struct vport *vport;
+	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+	struct vport *vport = NULL;
 
 	if (ovs_is_internal_dev(dev))
 		vport = ovs_internal_dev_get_vport(dev);
diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h
index 0c2f2f4..16d19b2 100644
--- a/datapath/linux/compat/include/linux/netdevice.h
+++ b/datapath/linux/compat/include/linux/netdevice.h
@@ -154,4 +154,15 @@ static inline int rpl_netif_needs_gso(struct sk_buff *skb, int features)
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+
+/* Simply pass through the passed parameter for Linux < 3.11.0 */
+static inline struct net_device *
+netdev_notifier_info_to_dev(void *info)
+{
+    return info;
+}
+
+#endif
+
 #endif
-- 
1.8.3.2

