VPP-1324 SIGSEGV vl_msg_api_handler_with_vm_node() 82/13282/4
authorLukasz Majczak <lma@semihalf.com>
Thu, 28 Jun 2018 13:00:40 +0000 (15:00 +0200)
committerOle Trøan <otroan@employees.org>
Fri, 29 Jun 2018 12:32:00 +0000 (12:32 +0000)
Increase local arrays sizes to the correct number and gather missing statistics.

Change-Id: If44d43f258730e9a18f50fb59fc526c214d2be8a
Signed-off-by: Lukasz Majczak <lma@semihalf.com>
src/vpp/stats/stats.api
src/vpp/stats/stats.c

index 5d00908..c66f2e4 100644 (file)
@@ -18,7 +18,7 @@
     This file defines the stats API 
 */
 
-option version = "1.0.1";
+option version = "1.0.2";
 
 import "vnet/interface.api";
 import "vnet/bier/bier.api";
@@ -408,16 +408,18 @@ define vnet_get_summary_stats
 /** \brief Reply for vnet_get_summary_stats request
     @param context - sender context, to match reply w/ request
     @param retval - return code for request
-    @param total_pkts -  
-    @param total_bytes -
+    @param total_pkts - length of the array must match the length of 
+                        the combined counter part of the enum in interface.h
+    @param total_bytes - length of the array must match the length of 
+                         the combined counter part of the enum in interface.h
     @param vector_rate - 
 */
 define vnet_get_summary_stats_reply
 {
   u32 context;
   i32 retval;
-  u64 total_pkts[2];
-  u64 total_bytes[2];
+  u64 total_pkts[8];
+  u64 total_bytes[8];
   f64 vector_rate;
 };
 
index 9f91210..66d9d32 100644 (file)
@@ -3098,9 +3098,10 @@ vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
   vl_api_vnet_get_summary_stats_reply_t *rmp;
   vlib_combined_counter_main_t *cm;
   vlib_counter_t v;
+  vnet_interface_counter_type_t ct;
   int i, which;
-  u64 total_pkts[VLIB_N_RX_TX];
-  u64 total_bytes[VLIB_N_RX_TX];
+  u64 total_pkts[VNET_N_COMBINED_INTERFACE_COUNTER];
+  u64 total_bytes[VNET_N_COMBINED_INTERFACE_COUNTER];
   vl_api_registration_t *reg;
 
   reg = vl_api_client_index_to_registration (mp->client_index);
@@ -3130,10 +3131,17 @@ vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
   }
   vnet_interface_counter_unlock (im);
 
-  rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
-  rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
-  rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
-  rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
+  foreach_rx_combined_interface_counter (ct)
+  {
+    rmp->total_pkts[ct] = clib_host_to_net_u64 (total_pkts[ct]);
+    rmp->total_bytes[ct] = clib_host_to_net_u64 (total_bytes[ct]);
+  }
+
+  foreach_tx_combined_interface_counter (ct)
+  {
+    rmp->total_pkts[ct] = clib_host_to_net_u64 (total_pkts[ct]);
+    rmp->total_bytes[ct] = clib_host_to_net_u64 (total_bytes[ct]);
+  }
   rmp->vector_rate =
     clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));