From d1890de500d012d512ac7a680a2a0dc5e8acf444 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 17 Dec 2013 10:22:40 -0800 Subject: [PATCH] datapath: Check for backported netdev_features_t. This is apparently used by CentOS 6.5. Reported-by: Phil Daws Reported-by: Edouard Bourguignon Signed-off-by: Jesse Gross --- acinclude.m4 | 1 + datapath/linux/compat/include/linux/netdevice.h | 13 +++++++------ datapath/linux/compat/netdevice.c | 13 ++++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 321b3b026..a7383878e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -228,6 +228,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ 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/netdevice.h], [netdev_features_t]) OVS_GREP_IFELSE([$KSRC/include/linux/rcupdate.h], [rcu_read_lock_held], [], [OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h], diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h index b303f39db..e04f308cf 100644 --- a/datapath/linux/compat/include/linux/netdevice.h +++ b/datapath/linux/compat/include/linux/netdevice.h @@ -60,12 +60,17 @@ static inline struct net_device *dev_get_by_index_rcu(struct net *net, int ifind #define NETIF_F_FSO 0 #endif +#ifndef HAVE_NETDEV_FEATURES_T +typedef u32 netdev_features_t; +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) #define skb_gso_segment rpl_skb_gso_segment -struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features); +struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, + netdev_features_t features); #define netif_skb_features rpl_netif_skb_features -u32 rpl_netif_skb_features(struct sk_buff *skb); +netdev_features_t rpl_netif_skb_features(struct sk_buff *skb); #define netif_needs_gso rpl_netif_needs_gso static inline int rpl_netif_needs_gso(struct sk_buff *skb, int features) @@ -75,10 +80,6 @@ static inline int rpl_netif_needs_gso(struct sk_buff *skb, int features) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) -typedef u32 netdev_features_t; -#endif - #ifndef HAVE___SKB_GSO_SEGMENT static inline struct sk_buff *__skb_gso_segment(struct sk_buff *skb, netdev_features_t features, diff --git a/datapath/linux/compat/netdevice.c b/datapath/linux/compat/netdevice.c index 3d28a9ba0..1dc5abf2d 100644 --- a/datapath/linux/compat/netdevice.c +++ b/datapath/linux/compat/netdevice.c @@ -3,7 +3,7 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) #ifndef HAVE_CAN_CHECKSUM_PROTOCOL -static bool can_checksum_protocol(unsigned long features, __be16 protocol) +static bool can_checksum_protocol(netdev_features_t features, __be16 protocol) { return ((features & NETIF_F_GEN_CSUM) || ((features & NETIF_F_V4_CSUM) && @@ -31,7 +31,9 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb) return 0; } -static u32 harmonize_features(struct sk_buff *skb, __be16 protocol, u32 features) +static netdev_features_t harmonize_features(struct sk_buff *skb, + __be16 protocol, + netdev_features_t features) { if (!can_checksum_protocol(features, protocol)) { features &= ~NETIF_F_ALL_CSUM; @@ -43,12 +45,12 @@ static u32 harmonize_features(struct sk_buff *skb, __be16 protocol, u32 features return features; } -u32 rpl_netif_skb_features(struct sk_buff *skb) +netdev_features_t rpl_netif_skb_features(struct sk_buff *skb) { unsigned long vlan_features = skb->dev->vlan_features; __be16 protocol = skb->protocol; - u32 features = skb->dev->features; + netdev_features_t features = skb->dev->features; if (protocol == htons(ETH_P_8021Q)) { struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; @@ -68,7 +70,8 @@ u32 rpl_netif_skb_features(struct sk_buff *skb) } } -struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features) +struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, + netdev_features_t features) { int vlan_depth = ETH_HLEN; __be16 type = skb->protocol; -- 2.20.1