openvswitch: Use tun_key only for egress tunnel path.
[firefly-linux-kernel-4.4.55.git] / net / openvswitch / vport-gre.c
index f49148a07da29037c0799ab122b18b1d4d0599cd..309cca6e816f54791afc24470a9b6eb40a37dd69 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2013 Nicira, Inc.
+ * Copyright (c) 2007-2014 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -63,7 +63,7 @@ static __be16 filter_tnl_flags(__be16 flags)
 static struct sk_buff *__build_header(struct sk_buff *skb,
                                      int tunnel_hlen)
 {
-       const struct ovs_key_ipv4_tunnel *tun_key = OVS_CB(skb)->tun_key;
+       const struct ovs_key_ipv4_tunnel *tun_key = OVS_CB(skb)->egress_tun_key;
        struct tnl_ptk_info tpi;
 
        skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM));
@@ -129,6 +129,7 @@ static int gre_err(struct sk_buff *skb, u32 info,
 static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
 {
        struct net *net = ovs_dp_get_net(vport->dp);
+       struct ovs_key_ipv4_tunnel *tun_key;
        struct flowi4 fl;
        struct rtable *rt;
        int min_headroom;
@@ -136,16 +137,17 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
        __be16 df;
        int err;
 
-       if (unlikely(!OVS_CB(skb)->tun_key)) {
+       if (unlikely(!OVS_CB(skb)->egress_tun_key)) {
                err = -EINVAL;
                goto error;
        }
 
+       tun_key = OVS_CB(skb)->egress_tun_key;
        /* Route lookup */
        memset(&fl, 0, sizeof(fl));
-       fl.daddr = OVS_CB(skb)->tun_key->ipv4_dst;
-       fl.saddr = OVS_CB(skb)->tun_key->ipv4_src;
-       fl.flowi4_tos = RT_TOS(OVS_CB(skb)->tun_key->ipv4_tos);
+       fl.daddr = tun_key->ipv4_dst;
+       fl.saddr = tun_key->ipv4_src;
+       fl.flowi4_tos = RT_TOS(tun_key->ipv4_tos);
        fl.flowi4_mark = skb->mark;
        fl.flowi4_proto = IPPROTO_GRE;
 
@@ -153,7 +155,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
        if (IS_ERR(rt))
                return PTR_ERR(rt);
 
-       tunnel_hlen = ip_gre_calc_hlen(OVS_CB(skb)->tun_key->tun_flags);
+       tunnel_hlen = ip_gre_calc_hlen(tun_key->tun_flags);
 
        min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
                        + tunnel_hlen + sizeof(struct iphdr)
@@ -185,15 +187,14 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
                goto err_free_rt;
        }
 
-       df = OVS_CB(skb)->tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ?
+       df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ?
                htons(IP_DF) : 0;
 
        skb->ignore_df = 1;
 
        return iptunnel_xmit(skb->sk, rt, skb, fl.saddr,
-                            OVS_CB(skb)->tun_key->ipv4_dst, IPPROTO_GRE,
-                            OVS_CB(skb)->tun_key->ipv4_tos,
-                            OVS_CB(skb)->tun_key->ipv4_ttl, df, false);
+                            tun_key->ipv4_dst, IPPROTO_GRE,
+                            tun_key->ipv4_tos, tun_key->ipv4_ttl, df, false);
 err_free_rt:
        ip_rt_put(rt);
 error: