tunnel: Common types for IP tunnels 41/24141/4
authorNeale Ranns <nranns@cisco.com>
Sun, 29 Dec 2019 23:55:18 +0000 (23:55 +0000)
committerDamjan Marion <dmarion@me.com>
Mon, 27 Jan 2020 20:40:30 +0000 (20:40 +0000)
Type: refactor

Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: I18dcdb7af3e327f6cacdbcb1e52b89f13d6ba6e2

25 files changed:
MAINTAINERS
src/plugins/ikev2/ikev2.c
src/vnet/CMakeLists.txt
src/vnet/gre/gre.api
src/vnet/gre/gre.h
src/vnet/gre/gre_api.c
src/vnet/gre/interface.c
src/vnet/gre/node.c
src/vnet/ipip/ipip.api
src/vnet/ipip/ipip.c
src/vnet/ipip/ipip.h
src/vnet/ipip/ipip_api.c
src/vnet/ipip/ipip_cli.c
src/vnet/ipip/ipip_types_api.c [deleted file]
src/vnet/ipip/node.c
src/vnet/ipsec/ipsec_api.c
src/vnet/ipsec/ipsec_cli.c
src/vnet/tunnel/tunnel.c [new file with mode: 0644]
src/vnet/tunnel/tunnel.h [new file with mode: 0644]
src/vnet/tunnel/tunnel_types.api [moved from src/vnet/ipip/ipip_types.api with 66% similarity]
src/vnet/tunnel/tunnel_types_api.c [new file with mode: 0644]
src/vnet/tunnel/tunnel_types_api.h [moved from src/vnet/ipip/ipip_types_api.h with 64% similarity]
test/test_gre.py
test/test_ipip.py
test/vpp_gre_interface.py

index 069a7f2..c0af54c 100644 (file)
@@ -287,6 +287,11 @@ Y: src/vnet/ipip/FEATURE.yaml
 M:     Ole Troan <otroan@employees.org>
 F:     src/vnet/ipip/
 
+VNET tunnel
+I:     tunnel
+M:     Neale Ranns <nranns@cisco.com>
+F:     src/vnet/tunnel'
+
 VNET TLS and TLS engine plugins
 I:     tls
 M:     Florin Coras <fcoras@cisco.com>
index b94311b..6e3ca7d 100644 (file)
@@ -1545,7 +1545,8 @@ ikev2_add_tunnel_from_main (ikev2_add_ipsec_tunnel_args_t * a)
 
   rv = ipip_add_tunnel (IPIP_TRANSPORT_IP4, ~0,
                        &a->local_ip, &a->remote_ip, 0,
-                       IPIP_TUNNEL_FLAG_NONE, IP_DSCP_CS0, &sw_if_index);
+                       TUNNEL_ENCAP_DECAP_FLAG_NONE, IP_DSCP_CS0,
+                       &sw_if_index);
 
   if (rv == VNET_API_ERROR_IF_ALREADY_EXISTS)
     {
index 04a8b1d..16d5cac 100644 (file)
@@ -734,7 +734,6 @@ list(APPEND VNET_SOURCES
   ipip/sixrd.c
   ipip/ipip_api.c
   ipip/ipip_cli.c
-  ipip/ipip_types_api.c
 )
 
 list(APPEND VNET_MULTIARCH_SOURCES
@@ -743,14 +742,28 @@ list(APPEND VNET_MULTIARCH_SOURCES
 
 list(APPEND VNET_HEADERS
   ipip/ipip.h
-  ipip/ipip_types_api.h
 )
 
 list(APPEND VNET_API_FILES
-  ipip/ipip_types.api
   ipip/ipip.api
 )
 
+##############################################################################
+# Tunnel infra
+##############################################################################
+list(APPEND VNET_SOURCES
+  tunnel/tunnel.c
+  tunnel/tunnel_types_api.c
+)
+
+list(APPEND VNET_API_FILES
+  tunnel/tunnel_types.api
+)
+
+list(APPEND VNET_HEADERS
+  tunnel/tunnel.h
+)
+
 ##############################################################################
 # Tunnel protocol: l2tpv3
 ##############################################################################
index d79beeb..0a98178 100644 (file)
  * limitations under the License.
  */
 
-option version = "2.0.1";
+option version = "2.0.2";
 
 import "vnet/interface_types.api";
+import "vnet/tunnel/tunnel_types.api";
 import "vnet/ip/ip_types.api";
 
 /** \brief A GRE tunnel type
@@ -28,16 +29,6 @@ enum gre_tunnel_type : u8
   GRE_API_TUNNEL_TYPE_ERSPAN,
 };
 
-/** \brief A GRE tunnel mode
-*/
-enum gre_tunnel_mode : u8
-{
-  /* point-to-point */
-  GRE_API_TUNNEL_MODE_P2P,
-  /* multi-point */
-  GRE_API_TUNNEL_MODE_MP,
-};
-
 /** \brief A GRE tunnel
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request
@@ -52,7 +43,7 @@ enum gre_tunnel_mode : u8
 typedef gre_tunnel
 {
   vl_api_gre_tunnel_type_t type;
-  vl_api_gre_tunnel_mode_t mode;
+  vl_api_tunnel_mode_t mode;
   u16 session_id;
   u32 instance;
   u32 outer_table_id;
index 6989cf4..7f6ff0b 100644 (file)
@@ -24,6 +24,7 @@
 #include <vnet/pg/pg.h>
 #include <vnet/ip/format.h>
 #include <vnet/adj/adj_types.h>
+#include <vnet/tunnel/tunnel.h>
 
 extern vnet_hw_interface_class_t gre_hw_interface_class;
 extern vnet_hw_interface_class_t mgre_hw_interface_class;
@@ -61,18 +62,6 @@ typedef enum gre_tunnel_type_t_
 
 extern u8 *format_gre_tunnel_type (u8 * s, va_list * args);
 
-#define foreach_gre_tunnel_mode \
-  _(P2P, "point-to-point")      \
-  _(MP, "multi-point")          \
-
-typedef enum gre_tunnel_mode_t_
-{
-#define _(n, s) GRE_TUNNEL_MODE_##n,
-  foreach_gre_tunnel_mode
-#undef _
-} __clib_packed gre_tunnel_mode_t;
-
-extern u8 *format_gre_tunnel_mode (u8 * s, va_list * args);
 
 /**
  * A GRE payload protocol registration
@@ -107,7 +96,7 @@ typedef struct gre_tunnel_key_common_t_
       u32 fib_index;
       u16 session_id;
       gre_tunnel_type_t type;
-      gre_tunnel_mode_t mode;
+      tunnel_mode_t mode;
     };
     u64 as_u64;
   };
@@ -215,7 +204,7 @@ typedef struct
   u32 hw_if_index;
   u32 sw_if_index;
   gre_tunnel_type_t type;
-  gre_tunnel_mode_t mode;
+  tunnel_mode_t mode;
 
   /**
    * an L2 tunnel always rquires an L2 midchain. cache here for DP.
@@ -363,7 +352,7 @@ typedef struct
 {
   u8 is_add;
   gre_tunnel_type_t type;
-  gre_tunnel_mode_t mode;
+  tunnel_mode_t mode;
   u8 is_ipv6;
   u32 instance;
   ip46_address_t src, dst;
@@ -379,7 +368,7 @@ gre_mk_key4 (ip4_address_t src,
             ip4_address_t dst,
             u32 fib_index,
             gre_tunnel_type_t ttype,
-            gre_tunnel_mode_t tmode, u16 session_id, gre_tunnel_key4_t * key)
+            tunnel_mode_t tmode, u16 session_id, gre_tunnel_key4_t * key)
 {
   key->gtk_src = src;
   key->gtk_dst = dst;
@@ -402,7 +391,7 @@ gre_mk_key6 (const ip6_address_t * src,
             const ip6_address_t * dst,
             u32 fib_index,
             gre_tunnel_type_t ttype,
-            gre_tunnel_mode_t tmode, u16 session_id, gre_tunnel_key6_t * key)
+            tunnel_mode_t tmode, u16 session_id, gre_tunnel_key6_t * key)
 {
   key->gtk_src = *src;
   key->gtk_dst = *dst;
index be91f75..619b5fc 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <vnet/gre/gre.h>
 #include <vnet/fib/fib_table.h>
+#include <vnet/tunnel/tunnel_types_api.h>
 #include <vnet/ip/ip_types_api.h>
 
 #include <vnet/vnet_msg_enum.h>
@@ -83,40 +84,6 @@ gre_tunnel_type_encode (gre_tunnel_type_t in)
   return (out);
 }
 
-static int
-gre_tunnel_mode_decode (vl_api_gre_tunnel_mode_t in, gre_tunnel_mode_t * out)
-{
-  switch (in)
-    {
-#define _(n, v)                                           \
-      case GRE_API_TUNNEL_MODE_##n:                       \
-        *out = GRE_TUNNEL_MODE_##n;                       \
-        return (0);
-      foreach_gre_tunnel_mode
-#undef _
-    }
-
-  return (VNET_API_ERROR_INVALID_VALUE_2);
-}
-
-static vl_api_gre_tunnel_mode_t
-gre_tunnel_mode_encode (gre_tunnel_mode_t in)
-{
-  vl_api_gre_tunnel_mode_t out = GRE_API_TUNNEL_MODE_P2P;
-
-  switch (in)
-    {
-#define _(n, v)                                           \
-      case GRE_TUNNEL_MODE_##n:                           \
-        out = GRE_API_TUNNEL_MODE_##n;                    \
-        break;
-      foreach_gre_tunnel_mode
-#undef _
-    }
-
-  return (out);
-}
-
 static void vl_api_gre_tunnel_add_del_t_handler
   (vl_api_gre_tunnel_add_del_t * mp)
 {
@@ -146,7 +113,7 @@ static void vl_api_gre_tunnel_add_del_t_handler
   if (rv)
     goto out;
 
-  rv = gre_tunnel_mode_decode (mp->tunnel.mode, &a->mode);
+  rv = tunnel_mode_decode (mp->tunnel.mode, &a->mode);
 
   if (rv)
     goto out;
@@ -185,7 +152,7 @@ static void send_gre_tunnel_details
           (t->outer_fib_index, t->tunnel_dst.fp_proto));
 
   rmp->tunnel.type = gre_tunnel_type_encode (t->type);
-  rmp->tunnel.mode = gre_tunnel_mode_encode (t->mode);
+  rmp->tunnel.mode = tunnel_mode_encode (t->mode);
   rmp->tunnel.instance = htonl (t->user_instance);
   rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
   rmp->tunnel.session_id = htons (t->session_id);
index fab12b4..59bf21d 100644 (file)
@@ -44,23 +44,6 @@ format_gre_tunnel_type (u8 * s, va_list * args)
   return (s);
 }
 
-u8 *
-format_gre_tunnel_mode (u8 * s, va_list * args)
-{
-  gre_tunnel_mode_t mode = va_arg (*args, int);
-
-  switch (mode)
-    {
-#define _(n, v) case GRE_TUNNEL_MODE_##n:       \
-      s = format (s, "%s", v);                  \
-      break;
-      foreach_gre_tunnel_mode
-#undef _
-    }
-
-  return (s);
-}
-
 static u8 *
 format_gre_tunnel (u8 * s, va_list * args)
 {
@@ -73,7 +56,7 @@ format_gre_tunnel (u8 * s, va_list * args)
              t->outer_fib_index, t->sw_if_index);
 
   s = format (s, "payload %U ", format_gre_tunnel_type, t->type);
-  s = format (s, "%U ", format_gre_tunnel_mode, t->mode);
+  s = format (s, "%U ", format_tunnel_mode, t->mode);
 
   if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
     s = format (s, "session %d ", t->session_id);
@@ -212,12 +195,12 @@ gre_nhrp_mk_key (const gre_tunnel_t * t,
     gre_mk_key4 (t->tunnel_src.ip4,
                 nh->fp_addr.ip4,
                 nhrp_entry_get_fib_index (ne),
-                t->type, GRE_TUNNEL_MODE_P2P, 0, &key->gtk_v4);
+                t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v4);
   else
     gre_mk_key6 (&t->tunnel_src.ip6,
                 &nh->fp_addr.ip6,
                 nhrp_entry_get_fib_index (ne),
-                t->type, GRE_TUNNEL_MODE_P2P, 0, &key->gtk_v6);
+                t->type, TUNNEL_MODE_P2P, 0, &key->gtk_v6);
 }
 
 static void
@@ -336,7 +319,7 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
 
   if (t->type == GRE_TUNNEL_TYPE_L3)
     {
-      if (t->mode == GRE_TUNNEL_MODE_P2P)
+      if (t->mode == TUNNEL_MODE_P2P)
        hw_if_index =
          vnet_register_interface (vnm, gre_device_class.index, t_idx,
                                   gre_hw_interface_class.index, t_idx);
@@ -404,7 +387,7 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
 
   gre_tunnel_db_add (t, &key);
 
-  if (t->mode == GRE_TUNNEL_MODE_MP)
+  if (t->mode == TUNNEL_MODE_MP)
     nhrp_walk_itf (t->sw_if_index, gre_tunnel_add_nhrp_walk, t);
 
   if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
@@ -460,7 +443,7 @@ vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
   if (NULL == t)
     return VNET_API_ERROR_NO_SUCH_ENTRY;
 
-  if (t->mode == GRE_TUNNEL_MODE_MP)
+  if (t->mode == TUNNEL_MODE_MP)
     nhrp_walk_itf (t->sw_if_index, gre_tunnel_delete_nhrp_walk, t);
 
   sw_if_index = t->sw_if_index;
@@ -518,7 +501,7 @@ vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
   if (a->session_id > GTK_SESSION_ID_MAX)
     return VNET_API_ERROR_INVALID_SESSION_ID;
 
-  if (a->mode == GRE_TUNNEL_MODE_MP && !ip46_address_is_zero (&a->dst))
+  if (a->mode == TUNNEL_MODE_MP && !ip46_address_is_zero (&a->dst))
     return (VNET_API_ERROR_INVALID_DST_ADDRESS);
 
   if (a->is_add)
@@ -572,7 +555,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
   u32 instance = ~0;
   u32 outer_table_id = 0;
   gre_tunnel_type_t t_type = GRE_TUNNEL_TYPE_L3;
-  gre_tunnel_mode_t t_mode = GRE_TUNNEL_MODE_P2P;
+  tunnel_mode_t t_mode = TUNNEL_MODE_P2P;
   u32 session_id = 0;
   int rv;
   u8 is_add = 1;
@@ -596,7 +579,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
       else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
        ;
       else if (unformat (line_input, "multipoint"))
-       t_mode = GRE_TUNNEL_MODE_MP;
+       t_mode = TUNNEL_MODE_MP;
       else if (unformat (line_input, "teb"))
        t_type = GRE_TUNNEL_TYPE_TEB;
       else if (unformat (line_input, "erspan %d", &session_id))
@@ -615,7 +598,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
       goto done;
     }
 
-  if (t_mode != GRE_TUNNEL_MODE_MP && ip46_address_is_zero (&dst))
+  if (t_mode != TUNNEL_MODE_MP && ip46_address_is_zero (&dst))
     {
       error = clib_error_return (0, "destination address not specified");
       goto done;
index 14fb087..9252306 100644 (file)
@@ -245,11 +245,11 @@ gre_input (vlib_main_t * vm,
          gre_mk_key6 (&ip6[0]->dst_address,
                       &ip6[0]->src_address,
                       vnet_buffer (b[0])->ip.fib_index,
-                      type[0], GRE_TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
+                      type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
          gre_mk_key6 (&ip6[1]->dst_address,
                       &ip6[1]->src_address,
                       vnet_buffer (b[1])->ip.fib_index,
-                      type[1], GRE_TUNNEL_MODE_P2P, 0, &key[1].gtk_v6);
+                      type[1], TUNNEL_MODE_P2P, 0, &key[1].gtk_v6);
          matched[0] = gre_match_key6 (&cached_key.gtk_v6, &key[0].gtk_v6);
          matched[1] = gre_match_key6 (&cached_key.gtk_v6, &key[1].gtk_v6);
        }
@@ -258,11 +258,11 @@ gre_input (vlib_main_t * vm,
          gre_mk_key4 (ip4[0]->dst_address,
                       ip4[0]->src_address,
                       vnet_buffer (b[0])->ip.fib_index,
-                      type[0], GRE_TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
+                      type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
          gre_mk_key4 (ip4[1]->dst_address,
                       ip4[1]->src_address,
                       vnet_buffer (b[1])->ip.fib_index,
-                      type[1], GRE_TUNNEL_MODE_P2P, 0, &key[1].gtk_v4);
+                      type[1], TUNNEL_MODE_P2P, 0, &key[1].gtk_v4);
          matched[0] = gre_match_key4 (&cached_key.gtk_v4, &key[0].gtk_v4);
          matched[1] = gre_match_key4 (&cached_key.gtk_v4, &key[1].gtk_v4);
        }
@@ -381,7 +381,7 @@ gre_input (vlib_main_t * vm,
          gre_mk_key6 (&ip6[0]->dst_address,
                       &ip6[0]->src_address,
                       vnet_buffer (b[0])->ip.fib_index,
-                      type[0], GRE_TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
+                      type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v6);
          matched[0] = gre_match_key6 (&cached_key.gtk_v6, &key[0].gtk_v6);
        }
       else
@@ -389,7 +389,7 @@ gre_input (vlib_main_t * vm,
          gre_mk_key4 (ip4[0]->dst_address,
                       ip4[0]->src_address,
                       vnet_buffer (b[0])->ip.fib_index,
-                      type[0], GRE_TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
+                      type[0], TUNNEL_MODE_P2P, 0, &key[0].gtk_v4);
          matched[0] = gre_match_key4 (&cached_key.gtk_v4, &key[0].gtk_v4);
        }
 
index baf0e50..8ba3136 100644 (file)
  *
  */
 
-option version = "2.0.0";
+option version = "2.0.1";
 
 import "vnet/interface_types.api";
 import "vnet/ip/ip_types.api";
-import "vnet/ipip/ipip_types.api";
+import "vnet/tunnel/tunnel_types.api";
 
 /**
  * An IP{v4,v6} over IP{v4,v6} tunnel.
@@ -66,7 +66,7 @@ typedef ipip_tunnel
   vl_api_interface_index_t sw_if_index; /* ignored on create, set in
                                           details/dump */
   u32 table_id;
-  vl_api_ipip_tunnel_flags_t flags;
+  vl_api_tunnel_encap_decap_flags_t flags;
   vl_api_ip_dscp_t dscp; /* DSCP value for the tunnel encap,
                             ignored if ECNAP_COPY_DSCP flag is set */
 };
index d68e815..05460fb 100644 (file)
@@ -75,9 +75,9 @@ ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index,
       ip4->src_address.as_u32 = t->tunnel_src.ip4.as_u32;
       ip4->dst_address.as_u32 = t->tunnel_dst.ip4.as_u32;
       ip4->checksum = ip4_header_checksum (ip4);
-      if (!(t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP))
+      if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
        ip4_header_set_dscp (ip4, t->dscp);
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_SET_DF)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_SET_DF)
        ip4_header_set_df (ip4);
       break;
 
@@ -92,7 +92,7 @@ ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index,
       ip6->src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
       ip6->dst_address.as_u64[0] = t->tunnel_dst.ip6.as_u64[0];
       ip6->dst_address.as_u64[1] = t->tunnel_dst.ip6.as_u64[1];
-      if (!(t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP))
+      if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
        ip6_set_dscp_network_order (ip6, t->dscp);
       break;
 
@@ -116,11 +116,11 @@ ipip4_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
     {
     case VNET_LINK_IP6:
       ip4->protocol = IP_PROTOCOL_IPV6;
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
        ip4_header_set_dscp (ip4,
                             ip6_dscp_network_order ((ip6_header_t *) (ip4 +
                                                                       1)));
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN)
        ip4_header_set_ecn (ip4,
                            ip6_ecn_network_order ((ip6_header_t *) (ip4 +
                                                                     1)));
@@ -128,11 +128,11 @@ ipip4_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
 
     case VNET_LINK_IP4:
       ip4->protocol = IP_PROTOCOL_IP_IN_IP;
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
        ip4_header_set_dscp (ip4, ip4_header_get_dscp (ip4 + 1));
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN)
        ip4_header_set_ecn (ip4, ip4_header_get_ecn (ip4 + 1));
-      if ((t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DF) &&
+      if ((t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DF) &&
          ip4_header_get_df (ip4 + 1))
        ip4_header_set_df (ip4);
       break;
@@ -163,18 +163,18 @@ ipip6_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
     {
     case VNET_LINK_IP6:
       ip6->protocol = IP_PROTOCOL_IPV6;
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
        ip6_set_dscp_network_order (ip6, ip6_dscp_network_order (ip6 + 1));
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN)
        ip6_set_ecn_network_order (ip6, ip6_ecn_network_order (ip6 + 1));
       break;
 
     case VNET_LINK_IP4:
       ip6->protocol = IP_PROTOCOL_IP_IN_IP;
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
        ip6_set_dscp_network_order
          (ip6, ip4_header_get_dscp ((ip4_header_t *) (ip6 + 1)));
-      if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
+      if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN)
        ip6_set_ecn_network_order
          (ip6, ip4_header_get_ecn ((ip4_header_t *) (ip6 + 1)));
       break;
@@ -265,20 +265,6 @@ ipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
   ipip_tunnel_stack (ai);
 }
 
-u8 *
-format_ipip_tunnel_flags (u8 * s, va_list * args)
-{
-  ipip_tunnel_flags_t f = va_arg (*args, int);
-
-  if (f == IPIP_TUNNEL_FLAG_NONE)
-    return (format (s, "none"));
-
-#define _(a,b,c) if (f & IPIP_TUNNEL_FLAG_##a) s = format(s, "%s ", b);
-  forech_ipip_tunnel_flag
-#undef _
-    return (s);
-}
-
 static u8 *
 format_ipip_tunnel_name (u8 * s, va_list * args)
 {
@@ -413,7 +399,7 @@ ipip_tunnel_db_remove (ipip_tunnel_t * t)
 int
 ipip_add_tunnel (ipip_transport_t transport,
                 u32 instance, ip46_address_t * src, ip46_address_t * dst,
-                u32 fib_index, ipip_tunnel_flags_t flags,
+                u32 fib_index, tunnel_encap_decap_flags_t flags,
                 ip_dscp_t dscp, u32 * sw_if_indexp)
 {
   ipip_main_t *gm = &ipip_main;
index be94450..a3732f7 100644 (file)
@@ -22,7 +22,7 @@
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/ip/format.h>
 #include <vnet/ip/ip.h>
-#include <vnet/vnet.h>
+#include <vnet/tunnel/tunnel.h>
 
 extern vnet_hw_interface_class_t ipip_hw_interface_class;
 
@@ -64,28 +64,6 @@ typedef enum
   IPIP_MODE_6RD,
 } ipip_mode_t;
 
-/**
- * Keep these idenitical to those in ipip.api
- */
-#define forech_ipip_tunnel_flag                     \
-  _(NONE, "none", 0x0)                              \
-  _(ENCAP_COPY_DF, "encap-copy-df", 0x1)            \
-  _(ENCAP_SET_DF, "encap-set-df", 0x2)              \
-  _(ENCAP_COPY_DSCP, "encap-copy-dscp", 0x4)        \
-  _(ENCAP_COPY_ECN, "encap-copy-ecn", 0x8)          \
-  _(DECAP_COPY_ECN, "decap-copy-ecn", 0x10)
-
-typedef enum ipip_tunnel_flags_t_
-{
-#define _(a,b,c) IPIP_TUNNEL_FLAG_##a = c,
-  forech_ipip_tunnel_flag
-#undef _
-} __clib_packed ipip_tunnel_flags_t;
-
-#define IPIP_TUNNEL_FLAG_MASK (0x1f)
-
-extern u8 *format_ipip_tunnel_flags (u8 * s, va_list * args);
-
 /**
  * @brief A representation of a IPIP tunnel
  */
@@ -104,7 +82,7 @@ typedef struct
   u32 sw_if_index;
   u32 dev_instance;            /* Real device instance in tunnel vector */
   u32 user_instance;           /* Instance name being shown to user */
-  ipip_tunnel_flags_t flags;
+  tunnel_encap_decap_flags_t flags;
   ip_dscp_t dscp;
 
   struct
@@ -166,7 +144,7 @@ sixrd_get_addr_net (const ipip_tunnel_t * t, u64 dal)
 
 int ipip_add_tunnel (ipip_transport_t transport, u32 instance,
                     ip46_address_t * src, ip46_address_t * dst,
-                    u32 fib_index, ipip_tunnel_flags_t flags,
+                    u32 fib_index, tunnel_encap_decap_flags_t flags,
                     ip_dscp_t dscp, u32 * sw_if_indexp);
 int ipip_del_tunnel (u32 sw_if_index);
 int sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
index 47ff159..4f6aa7f 100644 (file)
@@ -22,7 +22,7 @@
 #include <vnet/ipip/ipip.h>
 #include <vnet/vnet.h>
 #include <vnet/ip/ip_types_api.h>
-#include <vnet/ipip/ipip_types_api.h>
+#include <vnet/tunnel/tunnel_types_api.h>
 
 #include <vnet/ipip/ipip.api_enum.h>
 #include <vnet/ipip/ipip.api_types.h>
@@ -37,7 +37,7 @@ vl_api_ipip_add_tunnel_t_handler (vl_api_ipip_add_tunnel_t * mp)
   vl_api_ipip_add_tunnel_reply_t *rmp;
   int rv = 0;
   u32 fib_index, sw_if_index = ~0;
-  ipip_tunnel_flags_t flags;
+  tunnel_encap_decap_flags_t flags;
   ip46_address_t src, dst;
   ip46_type_t itype[2];
 
@@ -56,7 +56,7 @@ vl_api_ipip_add_tunnel_t_handler (vl_api_ipip_add_tunnel_t * mp)
       goto out;
     }
 
-  rv = ipip_tunnel_flags_decode (mp->tunnel.flags, &flags);
+  rv = tunnel_encap_decap_flags_decode (mp->tunnel.flags, &flags);
 
   if (rv)
     goto out;
@@ -119,7 +119,7 @@ send_ipip_tunnel_details (ipip_tunnel_t * t, vl_api_ipip_tunnel_dump_t * mp)
     rmp->tunnel.instance = htonl (t->user_instance);
     rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
     rmp->tunnel.dscp = ip_dscp_encode(t->dscp);
-    rmp->tunnel.flags = ipip_tunnel_flags_encode(t->flags);
+    rmp->tunnel.flags = tunnel_encap_decap_flags_encode(t->flags);
   }));
     /* *INDENT-ON* */
 }
index e252f3a..09f2eba 100644 (file)
@@ -82,7 +82,7 @@ static clib_error_t *create_ipip_tunnel_command_fn(vlib_main_t *vm,
                            &src,
                            &dst,
                            fib_index,
-                           IPIP_TUNNEL_FLAG_NONE,
+                           TUNNEL_ENCAP_DECAP_FLAG_NONE,
                            IP_DSCP_CS0,
                            &sw_if_index);
     }
@@ -192,7 +192,7 @@ static u8 *format_ipip_tunnel(u8 *s, va_list *args) {
 
   s = format(s, "table-ID %d sw-if-idx %d flags [%U] dscp %U",
              table_id, t->sw_if_index,
-             format_ipip_tunnel_flags, t->flags,
+             format_tunnel_encap_decap_flags, t->flags,
              format_ip_dscp, t->dscp);
 
   return s;
diff --git a/src/vnet/ipip/ipip_types_api.c b/src/vnet/ipip/ipip_types_api.c
deleted file mode 100644 (file)
index 5625b85..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ipip_api.c - ipip api
- *
- * Copyright (c) 2018 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vnet/api_errno.h>
-#include <vnet/ipip/ipip_types_api.h>
-
-#include <vnet/ipip/ipip_types.api_enum.h>
-#include <vnet/ipip/ipip_types.api_types.h>
-
-
-STATIC_ASSERT (sizeof (vl_api_ipip_tunnel_flags_t) ==
-              sizeof (ipip_tunnel_flags_t),
-              "IPIP tunnel API and internal flags enum size differ");
-
-int
-ipip_tunnel_flags_decode (vl_api_ipip_tunnel_flags_t f,
-                         ipip_tunnel_flags_t * o)
-{
-  if (f & ~IPIP_TUNNEL_FLAG_MASK)
-    /* unknown flags set */
-    return (VNET_API_ERROR_INVALID_VALUE_2);
-
-  *o = (ipip_tunnel_flags_t) f;
-  return (0);
-}
-
-vl_api_ipip_tunnel_flags_t
-ipip_tunnel_flags_encode (ipip_tunnel_flags_t f)
-{
-  return ((vl_api_ipip_tunnel_flags_t) f);
-}
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
index cd26b8a..bc0250a 100644 (file)
@@ -161,7 +161,7 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node,
            {
              next0 = IPIP_INPUT_NEXT_IP6_INPUT;
 
-             if (t0->flags & IPIP_TUNNEL_FLAG_DECAP_COPY_ECN)
+             if (t0->flags & TUNNEL_ENCAP_DECAP_FLAG_DECAP_COPY_ECN)
                {
                  if (is_ipv6)
                    ip6_set_ecn_network_order ((ip60 + 1),
@@ -174,7 +174,7 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node,
          else if (inner_protocol0 == IP_PROTOCOL_IP_IN_IP)
            {
              next0 = IPIP_INPUT_NEXT_IP4_INPUT;
-             if (t0->flags & IPIP_TUNNEL_FLAG_DECAP_COPY_ECN)
+             if (t0->flags & TUNNEL_ENCAP_DECAP_FLAG_DECAP_COPY_ECN)
                {
                  if (is_ipv6)
                    ip4_header_set_ecn_w_chksum ((ip4_header_t *) (ip60 + 1),
index 4252acd..87f5931 100644 (file)
@@ -646,7 +646,8 @@ vl_api_ipsec_tunnel_if_add_del_t_handler (vl_api_ipsec_tunnel_if_add_del_t *
                            (mp->renumber ? ntohl (mp->show_instance) : ~0),
                            &local_ip,
                            &remote_ip, fib_index,
-                           IPIP_TUNNEL_FLAG_NONE, IP_DSCP_CS0, &sw_if_index);
+                           TUNNEL_ENCAP_DECAP_FLAG_NONE, IP_DSCP_CS0,
+                           &sw_if_index);
 
       if (rv)
        goto done;
index e412160..f04ccc8 100644 (file)
@@ -842,7 +842,8 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm,
       rv =
        ipip_add_tunnel (ipv6_set ? IPIP_TRANSPORT_IP6 : IPIP_TRANSPORT_IP4,
                         instance, &local_ip, &remote_ip, fib_index,
-                        IPIP_TUNNEL_FLAG_NONE, IP_DSCP_CS0, &sw_if_index);
+                        TUNNEL_ENCAP_DECAP_FLAG_NONE, IP_DSCP_CS0,
+                        &sw_if_index);
       rv |=
        ipsec_sa_add_and_lock (ipsec_tun_mk_local_sa_id (sw_if_index),
                               local_spi, IPSEC_PROTOCOL_ESP, crypto_alg,
diff --git a/src/vnet/tunnel/tunnel.c b/src/vnet/tunnel/tunnel.c
new file mode 100644 (file)
index 0000000..83b1046
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * tunnel.h: shared definitions for tunnels.
+ *
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/tunnel/tunnel.h>
+
+u8 *
+format_tunnel_mode (u8 * s, va_list * args)
+{
+  tunnel_mode_t mode = va_arg (*args, int);
+
+  switch (mode)
+    {
+#define _(n, v) case TUNNEL_MODE_##n:       \
+        s = format (s, "%s", v);            \
+        break;
+      foreach_tunnel_mode
+#undef _
+    }
+
+  return (s);
+}
+
+u8 *
+format_tunnel_encap_decap_flags (u8 * s, va_list * args)
+{
+  tunnel_encap_decap_flags_t f = va_arg (*args, int);
+
+  if (f == TUNNEL_ENCAP_DECAP_FLAG_NONE)
+    return (format (s, "none"));
+
+#define _(a,b,c) if (f & TUNNEL_ENCAP_DECAP_FLAG_##a) s = format(s, "%s ", b);
+  forech_tunnel_encap_decap_flag
+#undef _
+    return (s);
+}
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tunnel/tunnel.h b/src/vnet/tunnel/tunnel.h
new file mode 100644 (file)
index 0000000..e3390f5
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * tunnel.h: shared definitions for tunnels.
+ *
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TUNNEL_H__
+#define __TUNNEL_H__
+
+#include <vlib/vlib.h>
+
+#define foreach_tunnel_mode \
+  _(P2P, "point-to-point")      \
+  _(MP, "multi-point")          \
+
+typedef enum tunnel_mode_t_
+{
+#define _(n, s) TUNNEL_MODE_##n,
+  foreach_tunnel_mode
+#undef _
+} __clib_packed tunnel_mode_t;
+
+extern u8 *format_tunnel_mode (u8 * s, va_list * args);
+
+/**
+ * Keep these idenitical to those in ipip.api
+ */
+#define forech_tunnel_encap_decap_flag                     \
+  _(NONE, "none", 0x0)                              \
+  _(ENCAP_COPY_DF, "encap-copy-df", 0x1)            \
+  _(ENCAP_SET_DF, "encap-set-df", 0x2)              \
+  _(ENCAP_COPY_DSCP, "encap-copy-dscp", 0x4)        \
+  _(ENCAP_COPY_ECN, "encap-copy-ecn", 0x8)          \
+  _(DECAP_COPY_ECN, "decap-copy-ecn", 0x10)
+
+typedef enum tunnel_encap_decap_flags_t_
+{
+#define _(a,b,c) TUNNEL_ENCAP_DECAP_FLAG_##a = c,
+  forech_tunnel_encap_decap_flag
+#undef _
+} __clib_packed tunnel_encap_decap_flags_t;
+
+#define TUNNEL_FLAG_MASK (0x1f)
+
+extern u8 *format_tunnel_encap_decap_flags (u8 * s, va_list * args);
+
+#endif
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
similarity index 66%
rename from src/vnet/ipip/ipip_types.api
rename to src/vnet/tunnel/tunnel_types.api
index 3e52fe7..103948d 100644 (file)
 /**
  * Flags controlling tunnel behaviour
  */
-enum ipip_tunnel_flags : u8
+enum tunnel_encap_decap_flags : u8
 {
-  IPIP_TUNNEL_API_FLAG_NONE = 0,
+  TUNNEL_API_ENCAP_DECAP_FLAG_NONE = 0,
   /** at encap, copy the DF bit of the payload into the tunnel header */
-  IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF = 0x1,
+  TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DF = 0x1,
   /** at encap, set the DF bit in the tunnel header */
-  IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF = 0x2,
+  TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_SET_DF = 0x2,
   /** at encap, copy the DSCP bits of the payload into the tunnel header */
-  IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP = 0x4,
+  TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP = 0x4,
   /** at encap, copy the ECN bit of the payload into the tunnel header */
-  IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN = 0x8,
+  TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN = 0x8,
   /** at decap, copy the ECN bit of the tunnel header into the payload */
-  IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN = 0x10,
+  TUNNEL_API_ENCAP_DECAP_FLAG_DECAP_COPY_ECN = 0x10,
 };
+
+/**
+ * tunnel mode
+ */
+enum tunnel_mode : u8
+{
+  /** point-to-point */
+  TUNNEL_API_MODE_P2P,
+  /** multi-point */
+  TUNNEL_API_MODE_MP,
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tunnel/tunnel_types_api.c b/src/vnet/tunnel/tunnel_types_api.c
new file mode 100644 (file)
index 0000000..1d48178
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * tunnel_api.c - tunnel api
+ *
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/api_errno.h>
+#include <vnet/tunnel/tunnel_types_api.h>
+
+#include <vnet/tunnel/tunnel_types.api_enum.h>
+#include <vnet/tunnel/tunnel_types.api_types.h>
+
+
+STATIC_ASSERT (sizeof (vl_api_tunnel_encap_decap_flags_t) ==
+              sizeof (tunnel_encap_decap_flags_t),
+              "tunnel API and internal flags enum size differ");
+
+int
+tunnel_encap_decap_flags_decode (vl_api_tunnel_encap_decap_flags_t f,
+                                tunnel_encap_decap_flags_t * o)
+{
+  if (f & ~TUNNEL_FLAG_MASK)
+    /* unknown flags set */
+    return (VNET_API_ERROR_INVALID_VALUE_2);
+
+  *o = (tunnel_encap_decap_flags_t) f;
+  return (0);
+}
+
+vl_api_tunnel_encap_decap_flags_t
+tunnel_encap_decap_flags_encode (tunnel_encap_decap_flags_t f)
+{
+  return ((vl_api_tunnel_encap_decap_flags_t) f);
+}
+
+int
+tunnel_mode_decode (vl_api_tunnel_mode_t in, tunnel_mode_t * out)
+{
+  switch (in)
+    {
+#define _(n, v)                                       \
+      case TUNNEL_API_MODE_##n:                       \
+        *out = TUNNEL_MODE_##n;                       \
+        return (0);
+      foreach_tunnel_mode
+#undef _
+    }
+
+  return (VNET_API_ERROR_INVALID_VALUE_2);
+}
+
+vl_api_tunnel_mode_t
+tunnel_mode_encode (tunnel_mode_t in)
+{
+  vl_api_tunnel_mode_t out = TUNNEL_API_MODE_P2P;
+
+  switch (in)
+    {
+#define _(n, v)                                       \
+      case TUNNEL_MODE_##n:                           \
+        out = TUNNEL_API_MODE_##n;                    \
+        break;
+      foreach_tunnel_mode
+#undef _
+    }
+
+  return (out);
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
similarity index 64%
rename from src/vnet/ipip/ipip_types_api.h
rename to src/vnet/tunnel/tunnel_types_api.h
index 17b1f1b..06439dc 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __IPIP_TYPES_API_H__
-#define __IPIP_TYPES_API_H__
+#ifndef __TUNNEL_TYPES_API_H__
+#define __TUNNEL_TYPES_API_H__
 
 /**
  * Conversion functions to/from (decode/encode) API types to VPP internal types
  */
 
-#include <vnet/ipip/ipip.h>
-#include <vnet/ipip/ipip.api_types.h>
+#include <vnet/tunnel/tunnel.h>
+#include <vnet/tunnel/tunnel_types.api_types.h>
 
 /**
  * These enum decode/encodes use 'int' as the type for the enum because
  * one cannot forward declare an enum
  */
-extern int ipip_tunnel_flags_decode (u8 _f, ipip_tunnel_flags_t * out);
-extern u8 ipip_tunnel_flags_encode (ipip_tunnel_flags_t f);
+extern int tunnel_encap_decap_flags_decode (vl_api_tunnel_encap_decap_flags_t
+                                           _f,
+                                           tunnel_encap_decap_flags_t * out);
+extern vl_api_tunnel_encap_decap_flags_t
+tunnel_encap_decap_flags_encode (tunnel_encap_decap_flags_t f);
+
+extern int tunnel_mode_decode (vl_api_tunnel_mode_t in, tunnel_mode_t * out);
+extern vl_api_tunnel_mode_t tunnel_mode_encode (tunnel_mode_t in);
 
 #endif
 
index f4b4ee2..f8c4100 100644 (file)
@@ -1014,8 +1014,8 @@ class TestGRE(VppTestCase):
             gre_if = VppGreInterface(self,
                                      itf.local_ip4,
                                      "0.0.0.0",
-                                     mode=(VppEnum.vl_api_gre_tunnel_mode_t.
-                                           GRE_API_TUNNEL_MODE_MP))
+                                     mode=(VppEnum.vl_api_tunnel_mode_t.
+                                           TUNNEL_API_MODE_MP))
             gre_if.add_vpp_config()
             gre_if.admin_up()
             gre_if.config_ip4()
@@ -1117,8 +1117,8 @@ class TestGRE(VppTestCase):
             gre_if = VppGreInterface(self,
                                      itf.local_ip6,
                                      "::",
-                                     mode=(VppEnum.vl_api_gre_tunnel_mode_t.
-                                           GRE_API_TUNNEL_MODE_MP))
+                                     mode=(VppEnum.vl_api_tunnel_mode_t.
+                                           TUNNEL_API_MODE_MP))
             gre_if.add_vpp_config()
             gre_if.admin_up()
             gre_if.config_ip6()
index cb4166a..869dbaa 100644 (file)
@@ -116,7 +116,7 @@ class TestIPIP(VppTestCase):
 
         self.pg1.generate_remote_hosts(5)
         self.pg1.configure_ipv4_neighbors()
-        e = VppEnum.vl_api_ipip_tunnel_flags_t
+        e = VppEnum.vl_api_tunnel_encap_decap_flags_t
         d = VppEnum.vl_api_ip_dscp_t
         self.p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
         self.p_payload = UDP(sport=1234, dport=1234) / Raw(b'X' * 100)
@@ -133,15 +133,17 @@ class TestIPIP(VppTestCase):
             self.pg0,
             self.pg0.local_ip4,
             self.pg1.remote_hosts[0].ip4,
-            flags=e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP).add_vpp_config()
+            flags=e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
+        tun_dscp.add_vpp_config()
         # IPv4 transport that copies the DCSP and ECN from the payload
         tun_dscp_ecn = VppIpIpTunInterface(
             self,
             self.pg0,
             self.pg0.local_ip4,
             self.pg1.remote_hosts[1].ip4,
-            flags=(e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP |
-                   e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN)).add_vpp_config()
+            flags=(e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN))
+        tun_dscp_ecn.add_vpp_config()
         # IPv4 transport that copies the ECN from the payload and sets the
         # DF bit on encap. copies the ECN on decap
         tun_ecn = VppIpIpTunInterface(
@@ -149,9 +151,10 @@ class TestIPIP(VppTestCase):
             self.pg0,
             self.pg0.local_ip4,
             self.pg1.remote_hosts[2].ip4,
-            flags=(e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN |
-                   e.IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF |
-                   e.IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN)).add_vpp_config()
+            flags=(e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_SET_DF |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_DECAP_COPY_ECN))
+        tun_ecn.add_vpp_config()
         # IPv4 transport that sets a fixed DSCP in the encap and copies
         # the DF bit
         tun = VppIpIpTunInterface(
@@ -160,7 +163,8 @@ class TestIPIP(VppTestCase):
             self.pg0.local_ip4,
             self.pg1.remote_hosts[3].ip4,
             dscp=d.IP_API_DSCP_AF11,
-            flags=e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF).add_vpp_config()
+            flags=e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DF)
+        tun.add_vpp_config()
 
         # array of all the tunnels
         tuns = [tun_dscp, tun_dscp_ecn, tun_ecn, tun]
@@ -657,7 +661,7 @@ class TestIPIP6(VppTestCase):
 
         self.pg1.generate_remote_hosts(5)
         self.pg1.configure_ipv6_neighbors()
-        e = VppEnum.vl_api_ipip_tunnel_flags_t
+        e = VppEnum.vl_api_tunnel_encap_decap_flags_t
         d = VppEnum.vl_api_ip_dscp_t
         self.p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
         self.p_payload = UDP(sport=1234, dport=1234) / Raw(b'X' * 100)
@@ -674,15 +678,17 @@ class TestIPIP6(VppTestCase):
             self.pg0,
             self.pg0.local_ip6,
             self.pg1.remote_hosts[0].ip6,
-            flags=e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP).add_vpp_config()
+            flags=e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
+        tun_dscp.add_vpp_config()
         # IPv4 transport that copies the DCSP and ECN from the payload
         tun_dscp_ecn = VppIpIpTunInterface(
             self,
             self.pg0,
             self.pg0.local_ip6,
             self.pg1.remote_hosts[1].ip6,
-            flags=(e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP |
-                   e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN)).add_vpp_config()
+            flags=(e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN))
+        tun_dscp_ecn.add_vpp_config()
         # IPv4 transport that copies the ECN from the payload and sets the
         # DF bit on encap. copies the ECN on decap
         tun_ecn = VppIpIpTunInterface(
@@ -690,9 +696,10 @@ class TestIPIP6(VppTestCase):
             self.pg0,
             self.pg0.local_ip6,
             self.pg1.remote_hosts[2].ip6,
-            flags=(e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN |
-                   e.IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF |
-                   e.IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN)).add_vpp_config()
+            flags=(e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_SET_DF |
+                   e.TUNNEL_API_ENCAP_DECAP_FLAG_DECAP_COPY_ECN))
+        tun_ecn.add_vpp_config()
         # IPv4 transport that sets a fixed DSCP in the encap and copies
         # the DF bit
         tun = VppIpIpTunInterface(
@@ -701,7 +708,8 @@ class TestIPIP6(VppTestCase):
             self.pg0.local_ip6,
             self.pg1.remote_hosts[3].ip6,
             dscp=d.IP_API_DSCP_AF11,
-            flags=e.IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF).add_vpp_config()
+            flags=e.TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DF)
+        tun.add_vpp_config()
 
         # array of all the tunnels
         tuns = [tun_dscp, tun_dscp_ecn, tun_ecn, tun]
index 905c383..9a9069a 100644 (file)
@@ -24,8 +24,8 @@ class VppGreInterface(VppInterface):
                            GRE_API_TUNNEL_TYPE_L3)
         self.t_mode = mode
         if not self.t_mode:
-            self.t_mode = (VppEnum.vl_api_gre_tunnel_mode_t.
-                           GRE_API_TUNNEL_MODE_P2P)
+            self.t_mode = (VppEnum.vl_api_tunnel_mode_t.
+                           TUNNEL_API_MODE_P2P)
 
     def add_vpp_config(self):
         r = self.test.vapi.gre_tunnel_add_del(