From 42d5dd9595cce35a8825a20be7d71a3a8f6f5640 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Thu, 25 Apr 2013 14:28:16 +0200 Subject: [PATCH] datapath: Account for RHEL6.4 backports in compat layer Explicitly check the availability of several kernel API functions instead of relying on the kernel version to account for Red Hat Enterprise Linux backports. Signed-off-by: Thomas Graf Signed-off-by: Jesse Gross --- acinclude.m4 | 7 +++++++ datapath/linux/compat/include/asm/percpu.h | 2 +- datapath/linux/compat/include/linux/netdevice.h | 2 +- datapath/linux/compat/include/net/netlink.h | 8 +++++++- datapath/linux/compat/netdevice.c | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 2703bc460..34634a2b7 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -224,6 +224,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_disable_lro]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_stats]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_by_index_rcu]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [__skb_gso_segment]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [can_checksum_protocol]) OVS_GREP_IFELSE([$KSRC/include/linux/rcupdate.h], [rcu_read_lock_held], [], [OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h], @@ -268,11 +270,16 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [NLA_NUL_STRING]) OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16]) + OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be16]) + OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be32]) + OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be64]) OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_find_nested]) OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD], [OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])]) + OVS_GREP_IFELSE([$KSRC/include/linux/percpu.h], [this_cpu_ptr]) + OVS_GREP_IFELSE([$KSRC/include/linux/openvswitch.h], [openvswitch_handle_frame_hook], [OVS_DEFINE([HAVE_RHEL_OVS_HOOK])]) diff --git a/datapath/linux/compat/include/asm/percpu.h b/datapath/linux/compat/include/asm/percpu.h index 404b93773..65bce0847 100644 --- a/datapath/linux/compat/include/asm/percpu.h +++ b/datapath/linux/compat/include/asm/percpu.h @@ -3,7 +3,7 @@ #include_next -#ifndef this_cpu_ptr +#if !defined this_cpu_ptr && !defined HAVE_THIS_CPU_PTR #define this_cpu_ptr(ptr) per_cpu_ptr(ptr, smp_processor_id()) #endif diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h index 71aad8704..f8240df5a 100644 --- a/datapath/linux/compat/include/linux/netdevice.h +++ b/datapath/linux/compat/include/linux/netdevice.h @@ -158,7 +158,7 @@ static inline int rpl_netif_needs_gso(struct sk_buff *skb, int features) typedef u32 netdev_features_t; #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) +#ifndef HAVE___SKB_GSO_SEGMENT static inline struct sk_buff *__skb_gso_segment(struct sk_buff *skb, netdev_features_t features, bool tx_path) diff --git a/datapath/linux/compat/include/net/netlink.h b/datapath/linux/compat/include/net/netlink.h index 9616ea96f..308cd69b4 100644 --- a/datapath/linux/compat/include/net/netlink.h +++ b/datapath/linux/compat/include/net/netlink.h @@ -85,15 +85,21 @@ static inline __be64 nla_get_be64(const struct nlattr *nla) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) +#ifndef HAVE_NLA_PUT_BE16 static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) { return nla_put(skb, attrtype, sizeof(__be16), &value); } +#endif + +#ifndef HAVE_NLA_PUT_BE32 static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) { return nla_put(skb, attrtype, sizeof(__be32), &value); } +#endif + +#ifndef HAVE_NLA_PUT_BE64 static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) { return nla_put(skb, attrtype, sizeof(__be64), &value); diff --git a/datapath/linux/compat/netdevice.c b/datapath/linux/compat/netdevice.c index 9e92eeb8d..d26fb5e2a 100644 --- a/datapath/linux/compat/netdevice.c +++ b/datapath/linux/compat/netdevice.c @@ -2,6 +2,7 @@ #include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) +#ifndef HAVE_CAN_CHECKSUM_PROTOCOL static bool can_checksum_protocol(unsigned long features, __be16 protocol) { return ((features & NETIF_F_GEN_CSUM) || @@ -12,6 +13,7 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol) ((features & NETIF_F_FCOE_CRC) && protocol == htons(ETH_P_FCOE))); } +#endif static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb) { -- 2.43.0