aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/nsh/nsh_pop.c2
-rw-r--r--src/vat/api_format.c200
-rw-r--r--src/vnet/gre/gre.h2
-rw-r--r--src/vnet/gre/gre_api.c95
-rw-r--r--src/vnet/ipsec/esp_decrypt.c2
-rw-r--r--src/vnet/mpls/pg.c1
-rw-r--r--src/vnet/vnet_all_api_h.h1
-rw-r--r--src/vpp/api/custom_dump.c42
8 files changed, 33 insertions, 312 deletions
diff --git a/src/plugins/nsh/nsh_pop.c b/src/plugins/nsh/nsh_pop.c
index 188c513af27..46b3521ab32 100644
--- a/src/plugins/nsh/nsh_pop.c
+++ b/src/plugins/nsh/nsh_pop.c
@@ -18,7 +18,7 @@
#include <vnet/vnet.h>
#include <vnet/plugin/plugin.h>
#include <nsh/nsh.h>
-#include <vnet/gre/gre.h>
+#include <vnet/gre/packet.h>
#include <vnet/vxlan/vxlan.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
#include <vnet/l2/l2_classify.h>
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 366e60e1290..3f4d74f656f 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -28,7 +28,6 @@
#include <vnet/ip/ip_types_api.h>
#include <vnet/l2/l2_input.h>
#include <vnet/vxlan/vxlan.h>
-#include <vnet/gre/gre.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
#include <vnet/udp/udp_local.h>
@@ -2397,40 +2396,6 @@ static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
vam->result_ready = 1;
}
-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);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
-}
-
-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;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
static void vl_api_create_vhost_user_if_reply_t_handler
(vl_api_create_vhost_user_if_reply_t * mp)
{
@@ -3451,8 +3416,6 @@ _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
_(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
_(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
-_(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) \
_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
@@ -9710,165 +9673,6 @@ api_vxlan_tunnel_dump (vat_main_t * vam)
}
static int
-api_gre_tunnel_add_del (vat_main_t * vam)
-{
- unformat_input_t *line_input = vam->input;
- 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 src_set = 0;
- u8 dst_set = 0;
- u32 outer_table_id = 0;
- u32 session_id = 0;
- u32 instance = ~0;
- int ret;
-
- t_type = GRE_API_TUNNEL_TYPE_L3;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "del"))
- is_add = 0;
- else if (unformat (line_input, "instance %d", &instance))
- ;
- else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
- {
- src_set = 1;
- }
- else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
- {
- dst_set = 1;
- }
- else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
- ;
- else if (unformat (line_input, "teb"))
- t_type = GRE_API_TUNNEL_TYPE_TEB;
- else if (unformat (line_input, "erspan %d", &session_id))
- t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
- else
- {
- errmsg ("parse error '%U'", format_unformat_error, line_input);
- return -99;
- }
- }
-
- if (src_set == 0)
- {
- errmsg ("tunnel src address not specified");
- return -99;
- }
- if (dst_set == 0)
- {
- errmsg ("tunnel dst address not specified");
- return -99;
- }
-
- M (GRE_TUNNEL_ADD_DEL, mp);
-
- clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
- clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
-
- mp->tunnel.instance = htonl (instance);
- mp->tunnel.outer_table_id = htonl (outer_table_id);
- mp->is_add = is_add;
- mp->tunnel.session_id = htons ((u16) session_id);
- mp->tunnel.type = htonl (t_type);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static void vl_api_gre_tunnel_details_t_handler
- (vl_api_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
- 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_table_id),
- ntohl (mp->tunnel.session_id));
-}
-
-static void vl_api_gre_tunnel_details_t_handler_json
- (vl_api_gre_tunnel_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- 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_table_id",
- ntohl (mp->tunnel.outer_table_id));
- vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
-}
-
-static int
-api_gre_tunnel_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_gre_tunnel_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- sw_if_index = ~0;
- }
-
- if (!vam->json_output)
- {
- print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
- "sw_if_index", "instance", "src_address", "dst_address",
- "tunnel_type", "outer_fib_id", "session_id");
- }
-
- /* Get list of gre-tunnel interfaces */
- M (GRE_TUNNEL_DUMP, mp);
-
- mp->sw_if_index = htonl (sw_if_index);
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
api_l2_fib_clear_table (vat_main_t * vam)
{
// unformat_input_t * i = vam->input;
@@ -15218,10 +15022,6 @@ _(vxlan_add_del_tunnel, \
"{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
"vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
_(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
-_(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>]") \
_(l2_fib_clear_table, "") \
_(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
_(l2_interface_vlan_tag_rewrite, \
diff --git a/src/vnet/gre/gre.h b/src/vnet/gre/gre.h
index 0fe1f840241..ea085bf0fa1 100644
--- a/src/vnet/gre/gre.h
+++ b/src/vnet/gre/gre.h
@@ -286,6 +286,8 @@ typedef struct
/* Record used instances */
uword *instance_used;
+
+ u16 msg_id_base;
} gre_main_t;
/**
diff --git a/src/vnet/gre/gre_api.c b/src/vnet/gre/gre_api.c
index 934fc661b47..f4c8efa7ecd 100644
--- a/src/vnet/gre/gre_api.c
+++ b/src/vnet/gre/gre_api.c
@@ -28,28 +28,12 @@
#include <vnet/tunnel/tunnel_types_api.h>
#include <vnet/ip/ip_types_api.h>
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
+#include <vnet/gre/gre.api_enum.h>
+#include <vnet/gre/gre.api_types.h>
+#define REPLY_MSG_ID_BASE gre_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
-_(GRE_TUNNEL_ADD_DEL, gre_tunnel_add_del) \
-_(GRE_TUNNEL_DUMP, gre_tunnel_dump)
-
static int
gre_tunnel_type_decode (vl_api_gre_tunnel_type_t in, gre_tunnel_type_t * out)
{
@@ -143,30 +127,28 @@ out:
}
static void send_gre_tunnel_details
- (gre_tunnel_t * t, vl_api_registration_t * reg, u32 context)
+ (gre_tunnel_t * t, vl_api_gre_tunnel_dump_t * mp)
{
vl_api_gre_tunnel_details_t *rmp;
+ int rv = 0;
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = htons (VL_API_GRE_TUNNEL_DETAILS);
-
- 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_table_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.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);
-
- rmp->context = context;
-
- vl_api_send_msg (reg, (u8 *) rmp);
+ /* *INDENT-OFF* */
+ REPLY_MACRO_DETAILS2(VL_API_GRE_TUNNEL_DETAILS,
+ ({
+ 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_table_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.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);
+ }));
+ /* *INDENT-ON* */
}
static void
@@ -188,10 +170,11 @@ vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
/* *INDENT-OFF* */
pool_foreach (t, gm->tunnels,
({
- send_gre_tunnel_details(t, reg, mp->context);
+ send_gre_tunnel_details(t, mp);
}));
/* *INDENT-ON* */
}
+
else
{
if ((sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index)) ||
@@ -200,7 +183,7 @@ vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
return;
}
t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
- send_gre_tunnel_details (t, reg, mp->context);
+ send_gre_tunnel_details (t, mp);
}
}
@@ -211,37 +194,17 @@ vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
* added the client registration handlers.
* See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
*/
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
- foreach_vl_msg_name_crc_gre;
-#undef _
-}
+/* API definitions */
+#include <vnet/format_fns.h>
+#include <vnet/gre/gre.api.c>
static clib_error_t *
gre_api_hookup (vlib_main_t * vm)
{
- api_main_t *am = vlibapi_get_main ();
-
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_vpe_api_msg;
-#undef _
-
/*
* Set up the (msg_name, crc, message-id) table
*/
- setup_message_id_table (am);
+ gre_main.msg_id_base = setup_message_id_table ();
return 0;
}
diff --git a/src/vnet/ipsec/esp_decrypt.c b/src/vnet/ipsec/esp_decrypt.c
index 45d08a683e2..879e8f4fb73 100644
--- a/src/vnet/ipsec/esp_decrypt.c
+++ b/src/vnet/ipsec/esp_decrypt.c
@@ -25,7 +25,7 @@
#include <vnet/ipsec/ipsec_io.h>
#include <vnet/ipsec/ipsec_tun.h>
-#include <vnet/gre/gre.h>
+#include <vnet/gre/packet.h>
#define foreach_esp_decrypt_next \
_(DROP, "error-drop") \
diff --git a/src/vnet/mpls/pg.c b/src/vnet/mpls/pg.c
index 6ff86e32f67..e543bbb7ebe 100644
--- a/src/vnet/mpls/pg.c
+++ b/src/vnet/mpls/pg.c
@@ -17,7 +17,6 @@
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
-#include <vnet/gre/gre.h>
#include <vnet/mpls/mpls.h>
typedef struct {
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index e48d4395436..2a5b6bd557e 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -37,7 +37,6 @@
#include <vnet/devices/af_packet/af_packet.api.h>
#include <vnet/devices/virtio/vhost_user.api.h>
#include <vnet/devices/tap/tapv2.api.h>
-#include <vnet/gre/gre.api.h>
#include <vnet/interface.api.h>
#include <vnet/l2/l2.api.h>
#include <vnet/span/span.api.h>
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index f530da2166e..447b9d230e6 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -27,7 +27,6 @@
#include <vnet/l2/l2_input.h>
#include <vnet/srv6/sr.h>
#include <vnet/srmpls/sr_mpls.h>
-#include <vnet/gre/gre.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
#include <vnet/classify/policer_classify.h>
#include <vnet/policer/xlate.h>
@@ -1539,45 +1538,6 @@ static void *vl_api_sw_interface_set_vxlan_gbp_bypass_t_print
FINISH;
}
-static void *vl_api_gre_tunnel_add_del_t_print
- (vl_api_gre_tunnel_add_del_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: gre_tunnel_add_del ");
-
- 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 ", (mp->tunnel.instance));
-
- if (mp->tunnel.type == GRE_API_TUNNEL_TYPE_TEB)
- s = format (s, "teb ");
-
- if (mp->tunnel.type == GRE_API_TUNNEL_TYPE_ERSPAN)
- s = format (s, "erspan %d ", (mp->tunnel.session_id));
-
- if (mp->tunnel.outer_table_id)
- s = format (s, "outer-table-id %d ", mp->tunnel.outer_table_id);
-
- if (mp->is_add == 0)
- s = format (s, "del ");
-
- FINISH;
-}
-
-static void *vl_api_gre_tunnel_dump_t_print
- (vl_api_gre_tunnel_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: gre_tunnel_dump ");
-
- s = format (s, "sw_if_index %d ", (mp->sw_if_index));
-
- FINISH;
-}
-
static void *vl_api_l2_fib_clear_table_t_print
(vl_api_l2_fib_clear_table_t * mp, void *handle)
{
@@ -3092,8 +3052,6 @@ _(ADD_NODE_NEXT, add_node_next) \
_(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
_(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
_(VXLAN_OFFLOAD_RX, vxlan_offload_rx) \
-_(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) \
_(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \