[ovs-dev] [PATCH 1/2] datapath: Define kmemdup() for kernels older than 2.6.19

Justin Pettit jpettit at nicira.com
Wed Apr 21 05:50:31 UTC 2010


The new GRE code requires the kmemdup function, but it's not available
on 2.6.18 kernels.  It has been backported to Xen, so only define it for
non-Xen kernels older than 2.6.19.
---
 datapath/linux-2.6/compat-2.6/include/linux/slab.h |   27 ++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 datapath/linux-2.6/compat-2.6/include/linux/slab.h

diff --git a/datapath/linux-2.6/compat-2.6/include/linux/slab.h b/datapath/linux-2.6/compat-2.6/include/linux/slab.h
new file mode 100644
index 0000000..6a74844
--- /dev/null
+++ b/datapath/linux-2.6/compat-2.6/include/linux/slab.h
@@ -0,0 +1,27 @@
+#ifndef __LINUX_SLAB_WRAPPER_H
+#define __LINUX_SLAB_WRAPPER_H 1
+
+#include_next <linux/slab.h>
+
+#include <linux/version.h>
+
+#if !defined(CONFIG_XEN) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+/**
+ * kmemdup - duplicate region of memory
+ *
+ * @src: memory region to duplicate
+ * @len: memory region length
+ * @gfp: GFP mask to use
+ */
+static inline void *kmemdup(const void *src, size_t len, gfp_t gfp)
+{
+        void *p;
+
+        p = kmalloc(len, gfp);
+        if (p)
+                memcpy(p, src, len);
+        return p;
+}
+#endif
+
+#endif
-- 
1.7.0.3





More information about the dev mailing list