From: Justin Pettit Date: Tue, 15 Dec 2009 19:20:58 +0000 (-0800) Subject: datapath: Add missing definitions for building GRE on older kernels X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f3a29be917cad5bcb389ab510d918ae21fea0c5;p=openvswitch datapath: Add missing definitions for building GRE on older kernels --- diff --git a/acinclude.m4 b/acinclude.m4 index e4fa5e62..490936e1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/datapath/linux-2.6/compat-2.6/include/linux/in.h b/datapath/linux-2.6/compat-2.6/include/linux/in.h index 2cfe6450..fd5c3c67 100644 --- a/datapath/linux-2.6/compat-2.6/include/linux/in.h +++ b/datapath/linux-2.6/compat-2.6/include/linux/in.h @@ -3,14 +3,13 @@ #include_next -#include -#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 diff --git a/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h b/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h index edeba5ae..d8205c6a 100644 --- a/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h +++ b/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h @@ -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 index 00000000..9b68f710 --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/linux/stddef.h @@ -0,0 +1,17 @@ +#ifndef __LINUX_STDDEF_WRAPPER_H +#define __LINUX_STDDEF_WRAPPER_H 1 + +#include_next + +#ifdef __KERNEL__ + +#ifndef HAVE_BOOL_TYPE +enum { + false = 0, + true = 1 +}; +#endif /* !HAVE_BOOL_TYPE */ + +#endif /* __KERNEL__ */ + +#endif diff --git a/datapath/linux-2.6/compat-2.6/include/linux/types.h b/datapath/linux-2.6/compat-2.6/include/linux/types.h index c1f375eb..d88baf71 100644 --- a/datapath/linux-2.6/compat-2.6/include/linux/types.h +++ b/datapath/linux-2.6/compat-2.6/include/linux/types.h @@ -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 diff --git a/datapath/linux-2.6/compat-2.6/include/net/netlink.h b/datapath/linux-2.6/compat-2.6/include/net/netlink.h index e0d594d7..2f979fec 100644 --- a/datapath/linux-2.6/compat-2.6/include/net/netlink.h +++ b/datapath/linux-2.6/compat-2.6/include/net/netlink.h @@ -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 */