datapath: Add basic MPLS support to kernel
[cascardo/ovs.git] / datapath / linux / compat / netdevice.c
index 3d28a9b..72bdec5 100644 (file)
@@ -1,9 +1,12 @@
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
 
+#include "mpls.h"
+#include "gso.h"
+
 #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 +34,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 +48,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;
@@ -67,8 +72,11 @@ u32 rpl_netif_skb_features(struct sk_buff *skb)
                return harmonize_features(skb, protocol, features);
        }
 }
+#endif /* kernel version < 2.6.38 */
 
-struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
+struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb,
+                                   netdev_features_t features)
 {
        int vlan_depth = ETH_HLEN;
        __be16 type = skb->protocol;
@@ -86,6 +94,9 @@ struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features)
                vlan_depth += VLAN_HLEN;
        }
 
+       if (eth_p_mpls(type))
+               type = ovs_skb_get_inner_protocol(skb);
+
        /* this hack needed to get regular skb_gso_segment() */
 #undef skb_gso_segment
        skb_proto = skb->protocol;
@@ -95,4 +106,4 @@ struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, u32 features)
        skb->protocol = skb_proto;
        return skb_gso;
 }
-#endif /* kernel version < 2.6.38 */
+#endif /* kernel version < 3.16.0 */