datapath: Simplify vport_send() error handling.
[cascardo/ovs.git] / datapath / linux / compat / vxlan.c
index b8b8fa7..0389b28 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -43,6 +42,7 @@
 #include <net/arp.h>
 #include <net/ndisc.h>
 #include <net/ip.h>
+#include <net/gre.h>
 #include <net/ip_tunnels.h>
 #include <net/icmp.h>
 #include <net/udp.h>
@@ -58,6 +58,7 @@
 #include "datapath.h"
 #include "gso.h"
 #include "vlan.h"
+#ifndef USE_KERNEL_TUNNEL_API
 
 #define VXLAN_HLEN (sizeof(struct udphdr) + sizeof(struct vxlanhdr))
 
@@ -165,15 +166,9 @@ static void vxlan_gso(struct sk_buff *skb)
        skb->ip_summed = CHECKSUM_NONE;
 }
 
-static int handle_offloads(struct sk_buff *skb)
+static struct sk_buff *handle_offloads(struct sk_buff *skb)
 {
-       if (skb_is_gso(skb)) {
-               OVS_GSO_CB(skb)->fix_segment = vxlan_gso;
-       } else {
-               if (skb->ip_summed != CHECKSUM_PARTIAL)
-                       skb->ip_summed = CHECKSUM_NONE;
-       }
-       return 0;
+       return ovs_iptunnel_handle_offloads(skb, false, vxlan_gso);
 }
 
 int vxlan_xmit_skb(struct vxlan_sock *vs,
@@ -192,8 +187,10 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
 
        /* Need space for new headers (invalidates iph ptr) */
        err = skb_cow_head(skb, min_headroom);
-       if (unlikely(err))
+       if (unlikely(err)) {
+               kfree_skb(skb);
                return err;
+       }
 
        if (vlan_tx_tag_present(skb)) {
                if (unlikely(!__vlan_put_tag(skb,
@@ -222,11 +219,12 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
 
        vxlan_set_owner(vs->sock->sk, skb);
 
-       err = handle_offloads(skb);
-       if (err)
-               return err;
+       skb = handle_offloads(skb);
+       if (IS_ERR(skb))
+               return PTR_ERR(skb);
 
-       return iptunnel_xmit(rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, false);
+       return iptunnel_xmit(vs->sock->sk, rt, skb, src, dst, IPPROTO_UDP,
+                            tos, ttl, df, false);
 }
 
 static void rcu_free_vs(struct rcu_head *rcu)