summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-04-16 07:15:35 +0000
committerDamjan Marion <dmarion@me.com>2019-04-18 07:52:27 +0000
commit5a8844bdbf4b055812cce2d7755a175b2cc90b75 (patch)
tree89a401d65c1d8fd3dd0d29b13ac087fa3e5a48cb /src
parent06a6a30f911383523931cd05c515f08aead7fbd0 (diff)
GRE: API update
Change-Id: I5010cd34123c6498230dedac6ba8dd774a1085f9 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c165
-rw-r--r--src/vnet/gre/gre.api57
-rw-r--r--src/vnet/gre/gre.h12
-rw-r--r--src/vnet/gre/gre_api.c133
-rw-r--r--src/vnet/gre/interface.c22
-rw-r--r--src/vpp/api/custom_dump.c26
6 files changed, 211 insertions, 204 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 0e2fec32218..bff81567c6c 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2466,8 +2466,8 @@ static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
vam->result_ready = 1;
}
-static void vl_api_gre_add_del_tunnel_reply_t_handler
- (vl_api_gre_add_del_tunnel_reply_t * mp)
+static void vl_api_gre_tunnel_add_del_reply_t_handler
+ (vl_api_gre_tunnel_add_del_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
@@ -2483,8 +2483,8 @@ static void vl_api_gre_add_del_tunnel_reply_t_handler
}
}
-static void vl_api_gre_add_del_tunnel_reply_t_handler_json
- (vl_api_gre_add_del_tunnel_reply_t * mp)
+static void vl_api_gre_tunnel_add_del_reply_t_handler_json
+ (vl_api_gre_tunnel_add_del_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
@@ -5413,7 +5413,7 @@ _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
_(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
_(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
-_(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
+_(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
_(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
@@ -13292,16 +13292,17 @@ api_geneve_tunnel_dump (vat_main_t * vam)
}
static int
-api_gre_add_del_tunnel (vat_main_t * vam)
+api_gre_tunnel_add_del (vat_main_t * vam)
{
unformat_input_t *line_input = vam->input;
- vl_api_gre_add_del_tunnel_t *mp;
- ip4_address_t src4, dst4;
- ip6_address_t src6, dst6;
+ vl_api_address_t src = { }, dst =
+ {
+ };
+ vl_api_gre_tunnel_add_del_t *mp;
+ vl_api_gre_tunnel_type_t t_type;
u8 is_add = 1;
u8 ipv4_set = 0;
u8 ipv6_set = 0;
- u8 t_type = GRE_TUNNEL_TYPE_L3;
u8 src_set = 0;
u8 dst_set = 0;
u32 outer_fib_id = 0;
@@ -13309,10 +13310,7 @@ api_gre_add_del_tunnel (vat_main_t * vam)
u32 instance = ~0;
int ret;
- clib_memset (&src4, 0, sizeof src4);
- clib_memset (&dst4, 0, sizeof dst4);
- clib_memset (&src6, 0, sizeof src6);
- clib_memset (&dst6, 0, sizeof dst6);
+ t_type = GRE_API_TUNNEL_TYPE_L3;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -13320,32 +13318,20 @@ api_gre_add_del_tunnel (vat_main_t * vam)
is_add = 0;
else if (unformat (line_input, "instance %d", &instance))
;
- else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
- {
- src_set = 1;
- ipv4_set = 1;
- }
- else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
- {
- dst_set = 1;
- ipv4_set = 1;
- }
- else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
+ else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
{
src_set = 1;
- ipv6_set = 1;
}
- else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
+ else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
{
dst_set = 1;
- ipv6_set = 1;
}
else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
;
else if (unformat (line_input, "teb"))
- t_type = GRE_TUNNEL_TYPE_TEB;
+ t_type = GRE_API_TUNNEL_TYPE_TEB;
else if (unformat (line_input, "erspan %d", &session_id))
- t_type = GRE_TUNNEL_TYPE_ERSPAN;
+ t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
else
{
errmsg ("parse error '%U'", format_unformat_error, line_input);
@@ -13363,31 +13349,17 @@ api_gre_add_del_tunnel (vat_main_t * vam)
errmsg ("tunnel dst address not specified");
return -99;
}
- if (ipv4_set && ipv6_set)
- {
- errmsg ("both IPv4 and IPv6 addresses specified");
- return -99;
- }
+ M (GRE_TUNNEL_ADD_DEL, mp);
- M (GRE_ADD_DEL_TUNNEL, mp);
+ clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
+ clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
- if (ipv4_set)
- {
- clib_memcpy (&mp->src_address, &src4, 4);
- clib_memcpy (&mp->dst_address, &dst4, 4);
- }
- else
- {
- clib_memcpy (&mp->src_address, &src6, 16);
- clib_memcpy (&mp->dst_address, &dst6, 16);
- }
- mp->instance = htonl (instance);
- mp->outer_fib_id = htonl (outer_fib_id);
+ mp->tunnel.instance = htonl (instance);
+ mp->tunnel.outer_fib_id = htonl (outer_fib_id);
mp->is_add = is_add;
- mp->session_id = htons ((u16) session_id);
- mp->tunnel_type = t_type;
- mp->is_ipv6 = ipv6_set;
+ mp->tunnel.session_id = htons ((u16) session_id);
+ mp->tunnel.type = htonl (t_type);
S (mp);
W (ret);
@@ -13398,15 +13370,34 @@ static void vl_api_gre_tunnel_details_t_handler
(vl_api_gre_tunnel_details_t * mp)
{
vat_main_t *vam = &vat_main;
- ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
- ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
- ntohl (mp->sw_if_index),
- ntohl (mp->instance),
- format_ip46_address, &src, IP46_TYPE_ANY,
- format_ip46_address, &dst, IP46_TYPE_ANY,
- mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
+ ntohl (mp->tunnel.sw_if_index),
+ ntohl (mp->tunnel.instance),
+ format_vl_api_address, &mp->tunnel.src,
+ format_vl_api_address, &mp->tunnel.dst,
+ mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
+ ntohl (mp->tunnel.session_id));
+}
+
+static void
+vat_json_object_add_address (vat_json_node_t * node,
+ const char *str, const vl_api_address_t * addr)
+{
+ if (ADDRESS_IP6 == addr->af)
+ {
+ struct in6_addr ip6;
+
+ clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
+ vat_json_object_add_ip6 (node, str, ip6);
+ }
+ else
+ {
+ struct in_addr ip4;
+
+ clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
+ vat_json_object_add_ip4 (node, str, ip4);
+ }
}
static void vl_api_gre_tunnel_details_t_handler_json
@@ -13425,26 +13416,16 @@ static void vl_api_gre_tunnel_details_t_handler_json
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
- if (!mp->is_ipv6)
- {
- clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
- vat_json_object_add_ip4 (node, "src_address", ip4);
- clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
- vat_json_object_add_ip4 (node, "dst_address", ip4);
- }
- else
- {
- clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
- vat_json_object_add_ip6 (node, "src_address", ip6);
- clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
- vat_json_object_add_ip6 (node, "dst_address", ip6);
- }
- vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
- vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
- vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
- vat_json_object_add_uint (node, "session_id", mp->session_id);
+ vat_json_object_add_uint (node, "sw_if_index",
+ ntohl (mp->tunnel.sw_if_index));
+ vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
+
+ vat_json_object_add_address (node, "src", &mp->tunnel.src);
+ vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
+ vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
+ vat_json_object_add_uint (node, "outer_fib_id",
+ ntohl (mp->tunnel.outer_fib_id));
+ vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
}
static int
@@ -15267,26 +15248,6 @@ vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
#define vl_api_ipsec_sa_details_t_endian vl_noop_handler
#define vl_api_ipsec_sa_details_t_print vl_noop_handler
-static void
-vat_json_object_add_address (vat_json_node_t * node,
- const vl_api_address_t * addr)
-{
- if (ADDRESS_IP6 == addr->af)
- {
- struct in6_addr ip6;
-
- clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "ip_address", ip6);
- }
- else
- {
- struct in_addr ip4;
-
- clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
- vat_json_object_add_ip4 (node, "ip_address", ip4);
- }
-}
-
static void vl_api_ipsec_sa_details_t_handler_json
(vl_api_ipsec_sa_details_t * mp)
{
@@ -15325,8 +15286,8 @@ static void vl_api_ipsec_sa_details_t_handler_json
mp->entry.crypto_key.length);
vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
mp->entry.integrity_key.length);
- vat_json_object_add_address (node, &mp->entry.tunnel_src);
- vat_json_object_add_address (node, &mp->entry.tunnel_dst);
+ vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
+ vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
vat_json_object_add_uint (node, "replay_window",
clib_net_to_host_u64 (mp->replay_window));
}
@@ -19506,7 +19467,7 @@ static void vl_api_ip_neighbor_details_t_handler_json
vat_json_object_add_string_copy (node, "link_layer",
format (0, "%U", format_vl_api_mac_address,
&mp->neighbor.mac_address));
- vat_json_object_add_address (node, &mp->neighbor.ip_address);
+ vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
}
static int
@@ -22519,7 +22480,7 @@ _(geneve_add_del_tunnel, \
"vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
_(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
_(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
-_(gre_add_del_tunnel, \
+_(gre_tunnel_add_del, \
"src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
"[teb | erspan <session-id>] [del]") \
_(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
diff --git a/src/vnet/gre/gre.api b/src/vnet/gre/gre.api
index 28c970154ae..17552cf344d 100644
--- a/src/vnet/gre/gre.api
+++ b/src/vnet/gre/gre.api
@@ -1,5 +1,6 @@
+/* Hey Emacs use -*- mode: C -*- */
/*
- * Copyright (c) 2015-2016 Cisco and/or its affiliates.
+ * Copyright (c) 2015-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:
@@ -13,35 +14,54 @@
* limitations under the License.
*/
-option version = "1.0.1";
+option version = "2.0.0";
-/** \brief Create or delete a GRE tunnel
+import "vnet/ip/ip_types.api";
+
+/** \brief A GRE tunnel type
+*/
+enum gre_tunnel_type
+{
+ GRE_API_TUNNEL_TYPE_L3,
+ GRE_API_TUNNEL_TYPE_TEB,
+ GRE_API_TUNNEL_TYPE_ERSPAN,
+};
+
+/** \brief A GRE tunnel
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param is_add - Use 1 to create the tunnel, 0 to remove it
- @param is_ipv6 - Use 0 for IPv4, 1 for IPv6
@param tunnel_type - 0: L3, 1: TEB, 2: ERSPAN
@param instance - optional unique custom device instance, else ~0.
- @param src_address - Source IP address
- @param dst_address - Destination IP address, can be multicast
+ @param src - Source IP address
+ @param dst - Destination IP address, can be multicast
@param outer_fib_id - Encap FIB table ID
@param session_id - session for ERSPAN tunnel, range 0-1023
+ @param sw_if_index - ignored on create/delete, present in details.
*/
-define gre_add_del_tunnel
+typedef gre_tunnel
{
u32 client_index;
u32 context;
u8 is_add;
u8 is_ipv6;
- u8 tunnel_type;
- u32 instance; /* If non-~0, specifies a custom dev instance */
- u8 src_address[16];
- u8 dst_address[16];
- u32 outer_fib_id;
u16 session_id;
+ vl_api_gre_tunnel_type_t type;
+ u32 instance;
+ u32 outer_fib_id;
+ u32 sw_if_index;
+ vl_api_address_t src;
+ vl_api_address_t dst;
+};
+
+define gre_tunnel_add_del
+{
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ vl_api_gre_tunnel_t tunnel;
};
-define gre_add_del_tunnel_reply
+define gre_tunnel_add_del_reply
{
u32 context;
i32 retval;
@@ -58,14 +78,7 @@ define gre_tunnel_dump
define gre_tunnel_details
{
u32 context;
- u32 sw_if_index;
- u32 instance;
- u8 is_ipv6;
- u8 tunnel_type;
- u8 src_address[16];
- u8 dst_address[16];
- u32 outer_fib_id;
- u16 session_id;
+ vl_api_gre_tunnel_t tunnel;
};
/*
diff --git a/src/vnet/gre/gre.h b/src/vnet/gre/gre.h
index a1a03dfb535..99fe4ace5b4 100644
--- a/src/vnet/gre/gre.h
+++ b/src/vnet/gre/gre.h
@@ -55,10 +55,10 @@ typedef enum gre_tunnel_type_t_
* receiving ERSPAN packets from a GRE ERSPAN tunnel in VPP.
*/
GRE_TUNNEL_TYPE_ERSPAN = 2,
-
- GRE_TUNNEL_TYPE_N
} gre_tunnel_type_t;
+#define GRE_TUNNEL_TYPE_N (GRE_TUNNEL_TYPE_ERSPAN + 1)
+
#define GRE_TUNNEL_TYPE_NAMES { \
[GRE_TUNNEL_TYPE_L3] = "L3", \
[GRE_TUNNEL_TYPE_TEB] = "TEB", \
@@ -347,16 +347,16 @@ gre_register_input_protocol (vlib_main_t * vm, gre_protocol_t protocol,
typedef struct
{
u8 is_add;
- u8 tunnel_type;
+ gre_tunnel_type_t type;
u8 is_ipv6;
u32 instance;
ip46_address_t src, dst;
u32 outer_fib_id;
u16 session_id;
-} vnet_gre_add_del_tunnel_args_t;
+} vnet_gre_tunnel_add_del_args_t;
-int vnet_gre_add_del_tunnel
- (vnet_gre_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
+extern int vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
+ u32 * sw_if_indexp);
static inline void
gre_mk_key4 (ip4_address_t src,
diff --git a/src/vnet/gre/gre_api.c b/src/vnet/gre/gre_api.c
index 0de6a9ff464..0d6c33bfda6 100644
--- a/src/vnet/gre/gre_api.c
+++ b/src/vnet/gre/gre_api.c
@@ -25,6 +25,7 @@
#include <vnet/gre/gre.h>
#include <vnet/fib/fib_table.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -45,50 +46,93 @@
#include <vlibapi/api_helper_macros.h>
#define foreach_vpe_api_msg \
-_(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
+_(GRE_TUNNEL_ADD_DEL, gre_tunnel_add_del) \
_(GRE_TUNNEL_DUMP, gre_tunnel_dump)
-static void vl_api_gre_add_del_tunnel_t_handler
- (vl_api_gre_add_del_tunnel_t * mp)
+static int
+gre_tunnel_type_decode (vl_api_gre_tunnel_type_t in, gre_tunnel_type_t * out)
{
- vl_api_gre_add_del_tunnel_reply_t *rmp;
- int rv = 0;
- vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
- u32 sw_if_index = ~0;
+ in = clib_net_to_host_u32 (in);
- /* Check src & dst are different */
- if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
- (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
+ switch (in)
{
- rv = VNET_API_ERROR_SAME_SRC_DST;
- goto out;
+ case GRE_API_TUNNEL_TYPE_L3:
+ *out = GRE_TUNNEL_TYPE_L3;
+ return (0);
+ case GRE_API_TUNNEL_TYPE_TEB:
+ *out = GRE_TUNNEL_TYPE_TEB;
+ return (0);
+ case GRE_API_TUNNEL_TYPE_ERSPAN:
+ *out = GRE_TUNNEL_TYPE_ERSPAN;
+ return (0);
}
- clib_memset (a, 0, sizeof (*a));
- a->is_add = mp->is_add;
- a->tunnel_type = mp->tunnel_type;
- a->is_ipv6 = mp->is_ipv6;
- a->instance = ntohl (mp->instance);
- a->session_id = ntohs (mp->session_id);
+ return (VNET_API_ERROR_INVALID_VALUE);
+}
+
+static vl_api_gre_tunnel_type_t
+gre_tunnel_type_encode (gre_tunnel_type_t in)
+{
+ vl_api_gre_tunnel_type_t out = GRE_API_TUNNEL_TYPE_L3;
- /* ip addresses sent in network byte order */
- if (!mp->is_ipv6)
+ switch (in)
{
- clib_memcpy (&(a->src.ip4), mp->src_address, 4);
- clib_memcpy (&(a->dst.ip4), mp->dst_address, 4);
+ case GRE_TUNNEL_TYPE_L3:
+ out = GRE_API_TUNNEL_TYPE_L3;
+ break;
+ case GRE_TUNNEL_TYPE_TEB:
+ out = GRE_API_TUNNEL_TYPE_TEB;
+ break;
+ case GRE_TUNNEL_TYPE_ERSPAN:
+ out = GRE_API_TUNNEL_TYPE_ERSPAN;
+ break;
}
- else
+
+ out = clib_net_to_host_u32 (out);
+
+ return (out);
+}
+
+static void vl_api_gre_tunnel_add_del_t_handler
+ (vl_api_gre_tunnel_add_del_t * mp)
+{
+ vnet_gre_tunnel_add_del_args_t _a = { }, *a = &_a;
+ vl_api_gre_tunnel_add_del_reply_t *rmp;
+ u32 sw_if_index = ~0;
+ ip46_type_t itype[2];
+ int rv = 0;
+
+ itype[0] = ip_address_decode (&mp->tunnel.src, &a->src);
+ itype[1] = ip_address_decode (&mp->tunnel.dst, &a->dst);
+
+ if (itype[0] != itype[1])
{
- clib_memcpy (&(a->src.ip6), mp->src_address, 16);
- clib_memcpy (&(a->dst.ip6), mp->dst_address, 16);
+ rv = VNET_API_ERROR_INVALID_PROTOCOL;
+ goto out;
}
- a->outer_fib_id = ntohl (mp->outer_fib_id);
- rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
+ if (ip46_address_is_equal (&a->src, &a->dst))
+ {
+ rv = VNET_API_ERROR_SAME_SRC_DST;
+ goto out;
+ }
+
+ rv = gre_tunnel_type_decode (mp->tunnel.type, &a->type);
+
+ if (rv)
+ goto out;
+
+ a->is_add = mp->is_add;
+ a->is_ipv6 = (itype[0] == IP46_TYPE_IP6);
+ a->instance = ntohl (mp->tunnel.instance);
+ a->session_id = ntohs (mp->tunnel.session_id);
+ a->outer_fib_id = ntohl (mp->tunnel.outer_fib_id);
+
+ rv = vnet_gre_tunnel_add_del (a, &sw_if_index);
out:
/* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
+ REPLY_MACRO2(VL_API_GRE_TUNNEL_ADD_DEL_REPLY,
({
rmp->sw_if_index = ntohl (sw_if_index);
}));
@@ -99,32 +143,23 @@ static void send_gre_tunnel_details
(gre_tunnel_t * t, vl_api_registration_t * reg, u32 context)
{
vl_api_gre_tunnel_details_t *rmp;
- u8 is_ipv6 = t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
- fib_table_t *ft;
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = htons (VL_API_GRE_TUNNEL_DETAILS);
- if (!is_ipv6)
- {
- clib_memcpy (rmp->src_address, &(t->tunnel_src.ip4.as_u8), 4);
- clib_memcpy (rmp->dst_address, &(t->tunnel_dst.fp_addr.ip4.as_u8), 4);
- ft = fib_table_get (t->outer_fib_index, FIB_PROTOCOL_IP4);
- rmp->outer_fib_id = htonl (ft->ft_table_id);
- }
- else
- {
- clib_memcpy (rmp->src_address, &(t->tunnel_src.ip6.as_u8), 16);
- clib_memcpy (rmp->dst_address, &(t->tunnel_dst.fp_addr.ip6.as_u8), 16);
- ft = fib_table_get (t->outer_fib_index, FIB_PROTOCOL_IP6);
- rmp->outer_fib_id = htonl (ft->ft_table_id);
- }
- rmp->tunnel_type = t->type;
- rmp->instance = htonl (t->user_instance);
- rmp->sw_if_index = htonl (t->sw_if_index);
- rmp->session_id = htons (t->session_id);
+
+ ip_address_encode (&t->tunnel_src, IP46_TYPE_ANY, &rmp->tunnel.src);
+ ip_address_encode (&t->tunnel_dst.fp_addr, IP46_TYPE_ANY, &rmp->tunnel.dst);
+
+ rmp->tunnel.outer_fib_id =
+ htonl (fib_table_get_table_id
+ (t->outer_fib_index, t->tunnel_dst.fp_proto));
+
+ rmp->tunnel.type = gre_tunnel_type_encode (t->type);
+ 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);
rmp->context = context;
- rmp->is_ipv6 = is_ipv6;
vl_api_send_msg (reg, (u8 *) rmp);
}
diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c
index 4f5f528acf9..2025838d9ad 100644
--- a/src/vnet/gre/interface.c
+++ b/src/vnet/gre/interface.c
@@ -51,7 +51,7 @@ format_gre_tunnel (u8 * s, va_list * args)
}
static gre_tunnel_t *
-gre_tunnel_db_find (const vnet_gre_add_del_tunnel_args_t * a,
+gre_tunnel_db_find (const vnet_gre_tunnel_add_del_args_t * a,
u32 outer_fib_index, gre_tunnel_key_t * key)
{
gre_main_t *gm = &gre_main;
@@ -60,13 +60,13 @@ gre_tunnel_db_find (const vnet_gre_add_del_tunnel_args_t * a,
if (!a->is_ipv6)
{
gre_mk_key4 (a->src.ip4, a->dst.ip4, outer_fib_index,
- a->tunnel_type, a->session_id, &key->gtk_v4);
+ a->type, a->session_id, &key->gtk_v4);
p = hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
}
else
{
gre_mk_key6 (&a->src.ip6, &a->dst.ip6, outer_fib_index,
- a->tunnel_type, a->session_id, &key->gtk_v6);
+ a->type, a->session_id, &key->gtk_v6);
p = hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6);
}
@@ -172,7 +172,7 @@ gre_tunnel_restack (gre_tunnel_t * gt)
}
static int
-vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
+vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
u32 outer_fib_index, u32 * sw_if_indexp)
{
gre_main_t *gm = &gre_main;
@@ -208,7 +208,7 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
t->dev_instance = t_idx; /* actual */
t->user_instance = u_idx; /* name */
- t->type = a->tunnel_type;
+ t->type = a->type;
if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
t->session_id = a->session_id;
@@ -310,7 +310,7 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
}
static int
-vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
+vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
u32 outer_fib_index, u32 * sw_if_indexp)
{
gre_main_t *gm = &gre_main;
@@ -362,7 +362,7 @@ vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
}
int
-vnet_gre_add_del_tunnel (vnet_gre_add_del_tunnel_args_t * a,
+vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
u32 * sw_if_indexp)
{
u32 outer_fib_index;
@@ -423,7 +423,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
+ vnet_gre_tunnel_add_del_args_t _a, *a = &_a;
ip46_address_t src, dst;
u32 instance = ~0;
u32 outer_fib_id = 0;
@@ -512,7 +512,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
clib_memset (a, 0, sizeof (*a));
a->is_add = is_add;
a->outer_fib_id = outer_fib_id;
- a->tunnel_type = t_type;
+ a->type = t_type;
a->session_id = session_id;
a->is_ipv6 = ipv6_set;
a->instance = instance;
@@ -527,7 +527,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
clib_memcpy (&a->dst.ip6, &dst.ip6, sizeof (dst.ip6));
}
- rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
+ rv = vnet_gre_tunnel_add_del (a, &sw_if_index);
switch (rv)
{
@@ -554,7 +554,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm,
goto done;
default:
error =
- clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
+ clib_error_return (0, "vnet_gre_tunnel_add_del returned %d", rv);
goto done;
}
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 9e150e91a7b..5f6ba063bac 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1931,28 +1931,26 @@ static void *vl_api_geneve_tunnel_dump_t_print
FINISH;
}
-static void *vl_api_gre_add_del_tunnel_t_print
- (vl_api_gre_add_del_tunnel_t * mp, void *handle)
+static void *vl_api_gre_tunnel_add_del_t_print
+ (vl_api_gre_tunnel_add_del_t * mp, void *handle)
{
u8 *s;
- ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
- ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
- s = format (0, "SCRIPT: gre_add_del_tunnel ");
+ s = format (0, "SCRIPT: gre_tunnel_add_del ");
- s = format (s, "dst %U ", format_ip46_address, &dst, IP46_TYPE_ANY);
- s = format (s, "src %U ", format_ip46_address, &src, IP46_TYPE_ANY);
+ s = format (s, "dst %U ", format_vl_api_address, &mp->tunnel.dst);
+ s = format (s, "src %U ", format_vl_api_address, &mp->tunnel.src);
- s = format (s, "instance %d ", ntohl (mp->instance));
+ s = format (s, "instance %d ", ntohl (mp->tunnel.instance));
- if (mp->tunnel_type == GRE_TUNNEL_TYPE_TEB)
+ if (mp->tunnel.type == GRE_TUNNEL_TYPE_TEB)
s = format (s, "teb ");
- if (mp->tunnel_type == GRE_TUNNEL_TYPE_ERSPAN)
- s = format (s, "erspan %d ", ntohs (mp->session_id));
+ if (mp->tunnel.type == GRE_TUNNEL_TYPE_ERSPAN)
+ s = format (s, "erspan %d ", ntohs (mp->tunnel.session_id));
- if (mp->outer_fib_id)
- s = format (s, "outer-fib-id %d ", ntohl (mp->outer_fib_id));
+ if (mp->tunnel.outer_fib_id)
+ s = format (s, "outer-fib-id %d ", ntohl (mp->tunnel.outer_fib_id));
if (mp->is_add == 0)
s = format (s, "del ");
@@ -3846,7 +3844,7 @@ _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
_(VXLAN_OFFLOAD_RX, vxlan_offload_rx) \
_(GENEVE_ADD_DEL_TUNNEL, geneve_add_del_tunnel) \
_(GENEVE_TUNNEL_DUMP, geneve_tunnel_dump) \
-_(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
+_(GRE_TUNNEL_ADD_DEL, gre_tunnel_add_del) \
_(GRE_TUNNEL_DUMP, gre_tunnel_dump) \
_(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
_(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \