From e2547ab574a82c69482704ef27375f1391deb9af Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Mon, 26 Jun 2017 18:12:37 +0200 Subject: VPP-889: MAP Stats API/CLI crashes when no domains. Change-Id: Ib7824bfc08cb3c8f20258379e1a1f2c159c4f687 Signed-off-by: Ole Troan --- src/vnet/map/map.c | 5 ++++- src/vnet/map/map_api.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c index d246f6c8254..fa13588fe38 100644 --- a/src/vnet/map/map.c +++ b/src/vnet/map/map.c @@ -1106,7 +1106,10 @@ show_map_stats_command_fn (vlib_main_t * vm, unformat_input_t * input, map_domain_t *d; int domains = 0, rules = 0, domaincount = 0, rulecount = 0; if (pool_elts (mm->domains) == 0) - vlib_cli_output (vm, "No MAP domains are configured..."); + { + vlib_cli_output (vm, "No MAP domains are configured..."); + return 0; + } /* *INDENT-OFF* */ pool_foreach(d, mm->domains, ({ diff --git a/src/vnet/map/map_api.c b/src/vnet/map/map_api.c index d618e7a65bf..994a64de480 100644 --- a/src/vnet/map/map_api.c +++ b/src/vnet/map/map_api.c @@ -203,6 +203,12 @@ vl_api_map_summary_stats_t_handler (vl_api_map_summary_stats_t * mp) rmp->context = mp->context; rmp->retval = 0; + if (pool_elts (mm->domains) == 0) + { + rmp->retval = -1; + goto out; + } + memset (total_pkts, 0, sizeof (total_pkts)); memset (total_bytes, 0, sizeof (total_bytes)); @@ -239,6 +245,7 @@ vl_api_map_summary_stats_t_handler (vl_api_map_summary_stats_t * mp) clib_host_to_net_u64 (map_error_counter_get (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK)); +out: vl_msg_api_send_shmem (q, (u8 *) & rmp); } -- cgit 1.2.3-korg