Compatibility fixes for 2.6.18 kernel
authorBen Pfaff <blp@nicira.com>
Sat, 6 Sep 2008 04:23:34 +0000 (21:23 -0700)
committerBen Pfaff <blp@nicira.com>
Sat, 6 Sep 2008 04:46:20 +0000 (21:46 -0700)
Functions added in the 2.6.22 kernel in tcp.h and skbuff.h
have been added to the compatibility headers. Additionally
the data argument was dropped in 2.6.22 for the work queue
macros, requiring them to be redfined for previous kernels.

Based on changes from David Erickson.

datapath/linux-2.6/compat-2.6/include/linux/skbuff.h
datapath/linux-2.6/compat-2.6/include/linux/tcp.h
datapath/linux-2.6/compat-2.6/include/linux/workqueue.h [new file with mode: 0644]

index 878e58dec1bfc1fa3deca84758cce1c861fcd868..9430f5271124b84d2d0c785af2064ba9c61ca725 100644 (file)
@@ -66,6 +66,10 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
        skb->mac.raw = skb->data + offset;
 }
 
+static inline int skb_transport_offset(const struct sk_buff *skb)
+{
+    return skb_transport_header(skb) - skb->data;
+}
 #endif /* linux kernel < 2.6.22 */
 
 #endif
index 528f16afa229e43fd088806d79d37d7609790a04..e8b519771a14222bd6ffb3e5d12b7a3172cb7b49 100644 (file)
@@ -11,6 +11,11 @@ static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
 {
        return (struct tcphdr *)skb_transport_header(skb);
 }
+
+static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
+{
+        return tcp_hdr(skb)->doff * 4;
+}
 #endif /* __KERNEL__ */
 
 #endif /* linux kernel < 2.6.22 */
diff --git a/datapath/linux-2.6/compat-2.6/include/linux/workqueue.h b/datapath/linux-2.6/compat-2.6/include/linux/workqueue.h
new file mode 100644 (file)
index 0000000..1ac3b6e
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef __LINUX_WORKQUEUE_WRAPPER_H
+#define __LINUX_WORKQUEUE_WRAPPER_H 1
+
+#include_next <linux/workqueue.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+
+#ifdef __KERNEL__
+/*
+ * initialize a work-struct's func and data pointers:
+ */
+#undef PREPARE_WORK
+#define PREPARE_WORK(_work, _func)                              \
+        do {                                                    \
+               (_work)->func = (void(*)(void*)) _func;         \
+                (_work)->data = _work;                         \
+        } while (0)
+
+/*
+ * initialize all of a work-struct:
+ */
+#undef INIT_WORK
+#define INIT_WORK(_work, _func)                                 \
+        do {                                                    \
+                INIT_LIST_HEAD(&(_work)->entry);                \
+                (_work)->pending = 0;                           \
+                PREPARE_WORK((_work), (_func));                 \
+                init_timer(&(_work)->timer);                    \
+        } while (0)
+
+#endif /* __KERNEL__ */
+
+#endif /* linux kernel < 2.6.20 */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+/* There is no equivalent to cancel_work_sync() so just flush all
+ * pending work. */
+#define cancel_work_sync(_work) flush_scheduled_work()
+#endif
+
+#endif