datapath: Add missing definitions for building GRE on older kernels
authorJustin Pettit <jpettit@nicira.com>
Tue, 15 Dec 2009 19:20:58 +0000 (11:20 -0800)
committerJustin Pettit <jpettit@nicira.com>
Mon, 4 Jan 2010 22:07:26 +0000 (14:07 -0800)
acinclude.m4
datapath/linux-2.6/compat-2.6/include/linux/in.h
datapath/linux-2.6/compat-2.6/include/linux/skbuff.h
datapath/linux-2.6/compat-2.6/include/linux/stddef.h [new file with mode: 0644]
datapath/linux-2.6/compat-2.6/include/linux/types.h
datapath/linux-2.6/compat-2.6/include/net/netlink.h

index e4fa5e6210538a52a5db5103fa4e3301f187c77c..490936e1de2a0556706511d4cf5af6541ef99386 100644 (file)
@@ -139,6 +139,8 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
   rm -f datapath/linux-2.6/kcompat.h.new
   mkdir -p datapath/linux-2.6
   : > datapath/linux-2.6/kcompat.h.new
+  OVS_GREP_IFELSE([$KSRC26/include/linux/types.h], [bool],
+                  [OVS_DEFINE([HAVE_BOOL_TYPE])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_transport_header],
                   [OVS_DEFINE([HAVE_SKBUFF_HEADER_HELPERS])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [raw],
@@ -154,6 +156,10 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
                   [OVS_DEFINE([HAVE_CSUM_UNFOLD])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_cow],
                   [OVS_DEFINE([HAVE_SKB_COW])])
+  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_get_be16],
+                  [OVS_DEFINE([HAVE_NLA_GET_BE16])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/in.h], [ipv4_is_multicast],
+                  [OVS_DEFINE([HAVE_IPV4_IS_MULTICAST])])
   # Check for the proto_data_valid member in struct sk_buff.  The [^@]
   # is necessary because some versions of this header remove the
   # member but retain the kerneldoc comment that describes it (which
index 2cfe6450e11f541a66498ad19500b9492306c94f..fd5c3c67369a14d695903dd4729b1a8544818533 100644 (file)
@@ -3,14 +3,13 @@
 
 #include_next <linux/in.h>
 
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#ifndef HAVE_IPV4_IS_MULTICAST
 
 static inline bool ipv4_is_multicast(__be32 addr)
 {
        return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
 }
 
-#endif /* linux kernel < 2.6.25 */
+#endif /* !HAVE_IPV4_IS_MULTICAST */
 
 #endif
index edeba5ae26b334e650ffed79f392fc0b2a19bdaf..d8205c6a24408383bee5b8833879e8bfd1197ce8 100644 (file)
@@ -149,6 +149,11 @@ static inline unsigned char *skb_network_header(const struct sk_buff *skb)
        return skb->nh.raw;
 }
 
+static inline void skb_reset_network_header(struct sk_buff *skb)
+{
+       skb->nh.raw = skb->data;
+}
+
 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
 {
        skb->nh.raw = skb->data + offset;
diff --git a/datapath/linux-2.6/compat-2.6/include/linux/stddef.h b/datapath/linux-2.6/compat-2.6/include/linux/stddef.h
new file mode 100644 (file)
index 0000000..9b68f71
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __LINUX_STDDEF_WRAPPER_H
+#define __LINUX_STDDEF_WRAPPER_H 1
+
+#include_next <linux/stddef.h>
+
+#ifdef __KERNEL__
+
+#ifndef HAVE_BOOL_TYPE
+enum {
+       false   = 0,
+       true    = 1
+};
+#endif /* !HAVE_BOOL_TYPE */
+
+#endif /* __KERNEL__ */
+
+#endif
index c1f375eb308cf71abd0e72e6ca3846fc1b5eda88..d88baf71ce9ffca51d62ccaedf9e3e0332e712aa 100644 (file)
@@ -11,4 +11,8 @@ typedef __u32 __bitwise __wsum;
 
 #endif /* linux kernel < 2.6.20 */
 
+#ifndef HAVE_BOOL_TYPE
+typedef _Bool bool;
+#endif /* !HAVE_BOOL_TYPE */
+
 #endif
index e0d594d78f7bac91351b2ac215778b8ce11d031e..2f979fecbe0a3c99c0e02546da86a4f9efad71ea 100644 (file)
@@ -19,4 +19,22 @@ static inline int VERIFY_NUL_STRING(struct nlattr *attr)
 }
 #endif /* !HAVE_NLA_NUL_STRING */
 
+
+#ifndef NLA_PUT_BE16
+#define NLA_PUT_BE16(skb, attrtype, value) \
+        NLA_PUT_TYPE(skb, __be16, attrtype, value)
+#endif  /* !NLA_PUT_BE16 */
+
+
+#ifndef HAVE_NLA_GET_BE16
+/**
+ * nla_get_be16 - return payload of __be16 attribute
+ * @nla: __be16 netlink attribute
+ */
+static inline __be16 nla_get_be16(struct nlattr *nla)
+{
+        return *(__be16 *) nla_data(nla);
+}
+#endif  /* !HAVE_NLA_GET_BE16 */
+
 #endif /* net/netlink.h */