[ovs-dev] [PATCH] datapath: Move kernel version check to version.h.

Jesse Gross jesse at nicira.com
Thu Aug 9 22:39:05 UTC 2012


The check for supported kernel versions is currently in datapath.c
but sometimes compatibility problems are hit before getting that far.
When this happens users get compiler errors and generally no
descriptive text.  This moves the check to version.h, which is almost
certainly included before any offending code.

Suggested-by: Pravin B Shelar <pshelar at nicira.com>
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c                           |    5 -----
 datapath/linux/Modules.mk                     |    1 +
 datapath/linux/compat/include/linux/version.h |   11 +++++++++++
 3 files changed, 12 insertions(+), 5 deletions(-)
 create mode 100644 datapath/linux/compat/include/linux/version.h

diff --git a/datapath/datapath.c b/datapath/datapath.c
index e98c84b..a9d9a3c 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -60,11 +60,6 @@
 #include "tunnel.h"
 #include "vport-internal_dev.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
-    LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-#error Kernels before 2.6.18 or after 3.5 are not supported by this version of Open vSwitch.
-#endif
-
 #define REHASH_FLOW_INTERVAL (10 * 60 * HZ)
 static void rehash_flow_table(struct work_struct *work);
 static DECLARE_DELAYED_WORK(rehash_flow_wq, rehash_flow_table);
diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
index 8ce6115..6283ff7 100644
--- a/datapath/linux/Modules.mk
+++ b/datapath/linux/Modules.mk
@@ -55,6 +55,7 @@ openvswitch_headers += \
 	linux/compat/include/linux/types.h \
 	linux/compat/include/linux/u64_stats_sync.h \
 	linux/compat/include/linux/udp.h \
+	linux/compat/include/linux/version.h \
 	linux/compat/include/linux/workqueue.h \
 	linux/compat/include/net/checksum.h \
 	linux/compat/include/net/dst.h \
diff --git a/datapath/linux/compat/include/linux/version.h b/datapath/linux/compat/include/linux/version.h
new file mode 100644
index 0000000..cdca86e
--- /dev/null
+++ b/datapath/linux/compat/include/linux/version.h
@@ -0,0 +1,11 @@
+#ifndef __LINUX_VERSION_WRAPPER_H
+#define __LINUX_VERSION_WRAPPER_H 1
+
+#include_next <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+#error Kernels before 2.6.18 or after 3.5 are not supported by this version of Open vSwitch.
+#endif
+
+#endif
-- 
1.7.9.5




More information about the dev mailing list