datapath: Use tun_info only for egress tunnel path.
[cascardo/ovs.git] / datapath / vport-vxlan.c
index ab2b6f7..6678400 100644 (file)
@@ -60,7 +60,7 @@ static inline struct vxlan_port *vxlan_vport(const struct vport *vport)
 /* Called with rcu_read_lock and BH disabled. */
 static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, __be32 vx_vni)
 {
-       struct ovs_key_ipv4_tunnel tun_key;
+       struct ovs_tunnel_info tun_info;
        struct vport *vport = vs->data;
        struct iphdr *iph;
        __be64 key;
@@ -68,9 +68,9 @@ static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, __be32 vx_vni)
        /* Save outer tunnel values */
        iph = ip_hdr(skb);
        key = cpu_to_be64(ntohl(vx_vni) >> 8);
-       ovs_flow_tun_key_init(&tun_key, iph, key, TUNNEL_KEY);
+       ovs_flow_tun_info_init(&tun_info, iph, key, TUNNEL_KEY, NULL, 0);
 
-       ovs_vport_receive(vport, skb, &tun_key);
+       ovs_vport_receive(vport, skb, &tun_info);
 }
 
 static int vxlan_get_options(const struct vport *vport, struct sk_buff *skb)
@@ -124,7 +124,7 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
        vxlan_port = vxlan_vport(vport);
        strncpy(vxlan_port->name, parms->name, IFNAMSIZ);
 
-       vs = vxlan_sock_add(net, htons(dst_port), vxlan_rcv, vport, true);
+       vs = vxlan_sock_add(net, htons(dst_port), vxlan_rcv, vport, true, false);
        if (IS_ERR(vs)) {
                ovs_vport_free(vport);
                return (void *)vs;
@@ -139,6 +139,8 @@ error:
 
 static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
 {
+       struct ovs_key_ipv4_tunnel *tun_key;
+       struct net *net = ovs_dp_get_net(vport->dp);
        struct vxlan_port *vxlan_port = vxlan_vport(vport);
        __be16 dst_port = inet_sport(vxlan_port->vs->sock->sk);
        struct rtable *rt;
@@ -149,38 +151,36 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
        int port_max;
        int err;
 
-       if (unlikely(!OVS_CB(skb)->tun_key)) {
+       if (unlikely(!OVS_CB(skb)->egress_tun_info)) {
                err = -EINVAL;
                goto error;
        }
 
+       tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
+
        /* Route lookup */
-       saddr = OVS_CB(skb)->tun_key->ipv4_src;
+       saddr = tun_key->ipv4_src;
        rt = find_route(ovs_dp_get_net(vport->dp),
-                       &saddr,
-                       OVS_CB(skb)->tun_key->ipv4_dst,
-                       IPPROTO_UDP,
-                       OVS_CB(skb)->tun_key->ipv4_tos,
+                       &saddr, tun_key->ipv4_dst,
+                       IPPROTO_UDP, tun_key->ipv4_tos,
                        skb->mark);
        if (IS_ERR(rt)) {
                err = PTR_ERR(rt);
                goto error;
        }
 
-       df = OVS_CB(skb)->tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ?
-               htons(IP_DF) : 0;
-
+       df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
        skb->local_df = 1;
 
-       inet_get_local_port_range(&port_min, &port_max);
+       inet_get_local_port_range(net, &port_min, &port_max);
        src_port = vxlan_src_port(port_min, port_max, skb);
 
        err = vxlan_xmit_skb(vxlan_port->vs, rt, skb,
-                            saddr, OVS_CB(skb)->tun_key->ipv4_dst,
-                            OVS_CB(skb)->tun_key->ipv4_tos,
-                            OVS_CB(skb)->tun_key->ipv4_ttl, df,
+                            saddr, tun_key->ipv4_dst,
+                            tun_key->ipv4_tos,
+                            tun_key->ipv4_ttl, df,
                             src_port, dst_port,
-                            htonl(be64_to_cpu(OVS_CB(skb)->tun_key->tun_id) << 8));
+                            htonl(be64_to_cpu(tun_key->tun_id) << 8));
        if (err < 0)
                ip_rt_put(rt);
 error: