datapath:compat: Fix build failure on old kernels.
authorPravin B Shelar <pshelar@nicira.com>
Fri, 19 Dec 2014 13:15:16 +0000 (05:15 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Fri, 19 Dec 2014 22:42:27 +0000 (14:42 -0800)
Reported by Travis.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
datapath/linux/compat/gre.c
datapath/linux/compat/include/net/gre.h
datapath/linux/compat/include/net/ip_tunnels.h
datapath/linux/compat/include/net/vxlan.h
datapath/linux/compat/ip_tunnels_core.c
datapath/linux/compat/vxlan.c
datapath/vport-geneve.c
datapath/vport-lisp.c

index c7f2551..1cd885b 100644 (file)
@@ -292,6 +292,11 @@ struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum)
        skb_reset_inner_headers(skb);
 
        if (skb_is_gso(skb)) {
+               if (skb_is_encapsulated(skb)) {
+                       err = -ENOSYS;
+                       goto error;
+               }
+
                if (gre_csum)
                        OVS_GSO_CB(skb)->fix_segment = gre_csum_fix;
                else
index 494702e..af1d991 100644 (file)
@@ -104,11 +104,11 @@ static inline int ip_gre_calc_hlen(__be16 o_flags)
        return addend;
 }
 #else
+
 static inline struct sk_buff *rpl_gre_handle_offloads(struct sk_buff *skb,
                                                  bool gre_csum)
 {
-       if ((ovs_skb_get_inner_protocol(skb) || skb->encapsulation) &&
-           skb_is_gso(skb)) {
+       if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
                kfree_skb(skb);
                return ERR_PTR(-ENOSYS);
        }
index d03be75..8fb9527 100644 (file)
@@ -75,4 +75,6 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
 #define TUNNEL_CRIT_OPT        __cpu_to_be16(0x0400)
 #define TUNNEL_OPTIONS_PRESENT __cpu_to_be16(0x0800)
 
+bool skb_is_encapsulated(struct sk_buff *skb);
+
 #endif /* __NET_IP_TUNNELS_H */
index 84afe53..5fc4dea 100644 (file)
@@ -15,8 +15,7 @@ static inline int rpl_vxlan_xmit_skb(struct vxlan_sock *vs,
                    __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
                    __be16 src_port, __be16 dst_port, __be32 vni)
 {
-       if ((ovs_skb_get_inner_protocol(skb) || skb->encapsulation) &&
-            skb_is_gso(skb)) {
+       if (skb_is_gso(skb) && skb_is_encapsulated(skb)) {
                kfree_skb(skb);
                return -ENOSYS;
        }
index 6cf38d0..e71ba4e 100644 (file)
@@ -117,3 +117,12 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
 }
 
 #endif
+
+bool skb_is_encapsulated(struct sk_buff *skb)
+{
+       /* checking for inner protocol should be sufficient on newer kernel, but
+        * old kernel just set encapsulation bit.
+        */
+       /* XXX: set inner protocol for all tunnel in OVS. */
+       return ovs_skb_get_inner_protocol(skb) || skb_encapsulation(skb);
+}
index f13cc89..ff040ac 100644 (file)
@@ -169,6 +169,9 @@ static void vxlan_gso(struct sk_buff *skb)
 static int handle_offloads(struct sk_buff *skb)
 {
        if (skb_is_gso(skb)) {
+               if (skb_is_encapsulated(skb))
+                       return -ENOSYS;
+
                OVS_GSO_CB(skb)->fix_segment = vxlan_gso;
        } else {
                if (skb->ip_summed != CHECKSUM_PARTIAL)
index 7c08577..200cc14 100644 (file)
@@ -326,22 +326,25 @@ static void geneve_fix_segment(struct sk_buff *skb)
 
 static int handle_offloads(struct sk_buff *skb)
 {
-       if (skb_is_gso(skb))
+       if (skb_is_gso(skb)) {
+               if (skb_is_encapsulated(skb))
+                       return -ENOSYS;
                OVS_GSO_CB(skb)->fix_segment = geneve_fix_segment;
-       else if (skb->ip_summed != CHECKSUM_PARTIAL)
+       } else if (skb->ip_summed != CHECKSUM_PARTIAL) {
                skb->ip_summed = CHECKSUM_NONE;
+       }
        return 0;
 }
 #else
 static int handle_offloads(struct sk_buff *skb)
 {
-       if (skb->encapsulation && skb_is_gso(skb)) {
-               kfree_skb(skb);
-               return -ENOSYS;
-       }
-
        if (skb_is_gso(skb)) {
-               int err = skb_unclone(skb, GFP_ATOMIC);
+               int err;
+
+               if (skb_is_encapsulated(skb))
+                       return -ENOSYS;
+
+               err = skb_unclone(skb, GFP_ATOMIC);
                if (unlikely(err))
                        return err;
 
index 1eaeddb..a067e05 100644 (file)
@@ -408,23 +408,26 @@ static void lisp_fix_segment(struct sk_buff *skb)
 
 static int handle_offloads(struct sk_buff *skb)
 {
-       if (skb_is_gso(skb))
+       if (skb_is_gso(skb)) {
+               if (skb_is_encapsulated(skb))
+                       return -ENOSYS;
+
                OVS_GSO_CB(skb)->fix_segment = lisp_fix_segment;
-       else if (skb->ip_summed != CHECKSUM_PARTIAL)
+       } else if (skb->ip_summed != CHECKSUM_PARTIAL) {
                skb->ip_summed = CHECKSUM_NONE;
+       }
        return 0;
 }
 #else
 static int handle_offloads(struct sk_buff *skb)
 {
-       if ((ovs_skb_get_inner_protocol(skb) || skb->encapsulation) &&
-           skb_is_gso(skb)) {
-               kfree_skb(skb);
-               return -ENOSYS;
-       }
-
        if (skb_is_gso(skb)) {
-               int err = skb_unclone(skb, GFP_ATOMIC);
+               int err;
+
+               if (skb_is_encapsulated(skb))
+                       return -ENOSYS;
+
+               err = skb_unclone(skb, GFP_ATOMIC);
                if (unlikely(err))
                        return err;