Hi Paul, I'm not an expert on that code, but it looks to me like you're right - the outer loop should use combined_counter_vec.
-Matt On Fri, Mar 20, 2026 at 1:19 PM G. Paul Ziemba via lists.fd.io <pz-vpp-dev= [email protected]> wrote: > I'm doing a bit of refactoring in vpp/app/vpp_get_stats.c and I am > scratching my head over the following bit of code. Please note > simple_counter_vec vs. combined_counter_vec. > > It seems to me that the outer loop should also use combined_counter_vec. > Is my view correct? I'll make a fix. > > vpp/app/vpp_get_stats.c stat_poll_loop() > case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED: > for (k = 0; k < vec_len (res[i].simple_counter_vec); k++) > for (j = 0; j < vec_len (res[i].combined_counter_vec[k]); > j++) > fformat (stdout, "[%d]: %llu packets, %llu bytes %s\n", > j, res[i].combined_counter_vec[k][j].packets, > res[i].combined_counter_vec[k][j].bytes, > res[i].name); > break; > > The same kind of iterating is also present here: > > vpp/app/dump_metrics.c print_metric_v1() > case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED: > fformat (stream, "# TYPE %s_packets counter\n", prom_string > (res->name)); > fformat (stream, "# TYPE %s_bytes counter\n", prom_string > (res->name)); > for (k = 0; k < vec_len (res->simple_counter_vec); k++) > for (j = 0; j < vec_len (res->combined_counter_vec[k]); j++) > { > fformat (stream, > "%s_packets{thread=\"%d\",interface=\"%d\"} %lld\n", > prom_string (res->name), k, j, > res->combined_counter_vec[k][j].packets); > fformat (stream, "%s_bytes{thread=\"%d\",interface=\"%d\"} > %lld\n", > prom_string (res->name), k, j, > res->combined_counter_vec[k][j].bytes); > } > break; > > This other piece of code seems correct: > > vpp/app/vpp_get_stats.c main() > case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED: > if (res[i].combined_counter_vec == 0) > continue; > for (k = 0; k < vec_len (res[i].combined_counter_vec); k++) > for (j = 0; j < vec_len (res[i].combined_counter_vec[k]); > j++) > -- > G. Paul Ziemba > FreeBSD unix: > 11:16AM up 36 days, 14:10, 26 users, load averages: 0.45, 0.43, 0.34 > > > >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#26903): https://lists.fd.io/g/vpp-dev/message/26903 Mute This Topic: https://lists.fd.io/mt/118422723/21656 Group Owner: [email protected] Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/14379924/21656/631435203/xyzzy [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
