]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/openvswitch/vport-gre.c
openvswitch: Add support for Geneve tunneling.
[mirror_ubuntu-bionic-kernel.git] / net / openvswitch / vport-gre.c
index f49148a07da29037c0799ab122b18b1d4d0599cd..108b82da2fd94169bab809df9d771232fa0c53b5 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,8 +63,10 @@ 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;
        struct tnl_ptk_info tpi;
+       const struct ovs_key_ipv4_tunnel *tun_key;
+
+       tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
 
        skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM));
        if (IS_ERR(skb))
@@ -92,7 +94,7 @@ static __be64 key_to_tunnel_id(__be32 key, __be32 seq)
 static int gre_rcv(struct sk_buff *skb,
                   const struct tnl_ptk_info *tpi)
 {
-       struct ovs_key_ipv4_tunnel tun_key;
+       struct ovs_tunnel_info tun_info;
        struct ovs_net *ovs_net;
        struct vport *vport;
        __be64 key;
@@ -103,10 +105,10 @@ static int gre_rcv(struct sk_buff *skb,
                return PACKET_REJECT;
 
        key = key_to_tunnel_id(tpi->key, tpi->seq);
-       ovs_flow_tun_key_init(&tun_key, ip_hdr(skb), key,
-                             filter_tnl_flags(tpi->flags));
+       ovs_flow_tun_info_init(&tun_info, ip_hdr(skb), key,
+                              filter_tnl_flags(tpi->flags), NULL, 0);
 
-       ovs_vport_receive(vport, skb, &tun_key);
+       ovs_vport_receive(vport, skb, &tun_info);
        return PACKET_RCVD;
 }
 
@@ -129,6 +131,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 +139,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_info)) {
                err = -EINVAL;
                goto error;
        }
 
+       tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
        /* 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 +157,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 +189,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: