Add support for LISP tunneling
[sliver-openvswitch.git] / datapath / vport-vxlan.c
index 137e5d8..388d9fb 100644 (file)
@@ -35,7 +35,6 @@
 #include "datapath.h"
 #include "tunnel.h"
 #include "vport.h"
-#include "vport-generic.h"
 
 #define VXLAN_FLAGS 0x08000000  /* struct vxlanhdr.vx_flags required value. */
 
@@ -91,21 +90,6 @@ static inline struct vxlanhdr *vxlan_hdr(const struct sk_buff *skb)
        return (struct vxlanhdr *)(udp_hdr(skb) + 1);
 }
 
-/* Compute source port for outgoing packet.
- * Currently we use the flow hash.
- */
-static u16 get_src_port(struct sk_buff *skb)
-{
-       int low;
-       int high;
-       unsigned int range;
-       u32 hash = OVS_CB(skb)->flow->hash;
-
-        inet_get_local_port_range(&low, &high);
-        range = (high - low) + 1;
-       return (((u64) hash * range) >> 32) + low;
-}
-
 static struct sk_buff *vxlan_build_header(const struct vport *vport,
                                          const struct tnl_mutable_config *mutable,
                                          struct dst_entry *dst,
@@ -121,7 +105,7 @@ static struct sk_buff *vxlan_build_header(const struct vport *vport,
        tnl_get_param(mutable, tun_key, &flags, &out_key);
 
        udph->dest = mutable->dst_port;
-       udph->source = htons(get_src_port(skb));
+       udph->source = htons(ovs_tnl_get_src_port(skb));
        udph->check = 0;
        udph->len = htons(skb->len - skb_transport_offset(skb));
 
@@ -167,10 +151,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
        iph = ip_hdr(skb);
        vport = ovs_tnl_find_port(dev_net(skb->dev), iph->daddr, iph->saddr,
                key, TNL_T_PROTO_VXLAN, &mutable);
-       if (unlikely(!vport)) {
-               icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
+       if (unlikely(!vport))
                goto error;
-       }
 
        if (mutable->flags & TNL_F_IN_KEY_MATCH || !mutable->key.daddr)
                tunnel_flags = OVS_TNL_F_KEY;
@@ -222,7 +204,7 @@ static int vxlan_socket_init(struct vxlan_port *vxlan_port, struct net *net)
        return 0;
 
 error_sock:
-       sock_release(vxlan_port->vxlan_rcv_socket);
+       sk_release_kernel(vxlan_port->vxlan_rcv_socket->sk);
 error:
        pr_warn("cannot register vxlan protocol handler\n");
        return err;
@@ -234,7 +216,7 @@ static void vxlan_tunnel_release(struct vxlan_port *vxlan_port)
 
        if (vxlan_port->count == 0) {
                /* Release old socket */
-               sock_release(vxlan_port->vxlan_rcv_socket);
+               sk_release_kernel(vxlan_port->vxlan_rcv_socket->sk);
                list_del(&vxlan_port->list);
                kfree(vxlan_port);
        }
@@ -268,6 +250,7 @@ static int vxlan_tunnel_setup(struct net *net, struct nlattr *options,
        if (vxlan_port) {
                vxlan_port->count++;
                err = 0;
+               *vxport = vxlan_port;
                goto out;
        }
 
@@ -372,14 +355,9 @@ const struct vport_ops ovs_vxlan_vport_ops = {
        .flags          = VPORT_F_TUN_ID,
        .create         = vxlan_tnl_create,
        .destroy        = vxlan_tnl_destroy,
-       .set_addr       = ovs_tnl_set_addr,
        .get_name       = ovs_tnl_get_name,
-       .get_addr       = ovs_tnl_get_addr,
        .get_options    = ovs_tnl_get_options,
        .set_options    = vxlan_set_options,
-       .get_dev_flags  = ovs_vport_gen_get_dev_flags,
-       .is_running     = ovs_vport_gen_is_running,
-       .get_operstate  = ovs_vport_gen_get_operstate,
        .send           = ovs_tnl_send,
 };
 #else