X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vlib-api%2Fvlibapi%2Fapi_shared.c;h=2b2d81c27358b6b8ccc038f3a5fbf2fd65462f15;hb=ed1c1835043a1d266a5928c40f41b340f6c968d7;hp=09502c692c3721a32c5a953703ab794eb72f4949;hpb=b2a6e25067a41def7d5795df6d07231b55051ab2;p=vpp.git diff --git a/vlib-api/vlibapi/api_shared.c b/vlib-api/vlibapi/api_shared.c index 09502c692c3..2b2d81c2735 100644 --- a/vlib-api/vlibapi/api_shared.c +++ b/vlib-api/vlibapi/api_shared.c @@ -781,7 +781,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp))) { vlib_cli_output (vm, "File not plausible: %s\n", filename); - close(fd); + close (fd); return; } @@ -847,6 +847,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, if (!cfgp) { vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id); + munmap (hp, file_size); return; } size = cfgp->size; @@ -872,6 +873,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, if (!cfgp) { vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id); + munmap (hp, file_size); return; } size = cfgp->size; @@ -894,6 +896,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, || (am->msg_endian_handlers[msg_id] == 0)) { vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id); + munmap (hp, file_size); return; } endian_fp = am->msg_endian_handlers[msg_id]; @@ -1083,8 +1086,22 @@ api_trace_command_fn (vlib_main_t * vm, } rv = vl_msg_api_trace_save (am, which, fp); fclose (fp); - if (rv < 0) - vlib_cli_output (vm, "ERROR: %d", rv); + if (rv == -1) + vlib_cli_output (vm, "API Trace data not present\n"); + else if (rv == -2) + vlib_cli_output (vm, "File for writing is closed\n"); + else if (rv == -10) + vlib_cli_output (vm, "Error while writing header to file\n"); + else if (rv == -11) + vlib_cli_output (vm, "Error while writing trace to file\n"); + else if (rv == -12) + vlib_cli_output (vm, + "Error while writing end of buffer trace to file\n"); + else if (rv == -13) + vlib_cli_output (vm, + "Error while writing start of buffer trace to file\n"); + else if (rv < 0) + vlib_cli_output (vm, "Unkown error while saving: %d", rv); else vlib_cli_output (vm, "API trace saved to %s\n", chroot_filename); vec_free (chroot_filename); @@ -1295,6 +1312,25 @@ vl_msg_api_get_msg_ids (char *name, int n) return rv; } +void +vl_msg_api_add_msg_name_crc (api_main_t * am, char *string, u32 id) +{ + uword *p; + + if (am->msg_index_by_name_and_crc == 0) + am->msg_index_by_name_and_crc = hash_create_string (0, sizeof (uword)); + + p = hash_get_mem (am->msg_index_by_name_and_crc, string); + if (p) + { + clib_warning ("attempt to redefine '%s' ignored...", string); + return; + } + + hash_set_mem (am->msg_index_by_name_and_crc, string, id); +} + + /* * fd.io coding-style-patch-verification: ON *