diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index d3a1f6442..0cd5a6c0f 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -626,8 +626,6 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) } list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE)) continue; @@ -664,8 +662,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) if ((px->flags & PR_FL_DISABLED) || px->uuid <= 0 || !(px->cap & PR_CAP_FE)) goto next_px2; - counters = EXTRA_COUNTERS_GET(px->extra_counters_fe, mod); - if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num)) + if (!mod->fill_stats(mod, px->extra_counters_fe, stats + ctx->field_num, &ctx->mod_field_num)) return -1; val = stats[ctx->field_num + ctx->mod_field_num]; @@ -817,8 +814,6 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx) } list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI)) continue; @@ -864,8 +859,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx) labels[lb_idx+1].name = ist("mod"); labels[lb_idx+1].value = ist2(mod->name, strlen(mod->name)); - counters = EXTRA_COUNTERS_GET(li->extra_counters, mod); - if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num)) + if (!mod->fill_stats(mod, li->extra_counters, stats + ctx->field_num, &ctx->mod_field_num)) return -1; val = stats[ctx->field_num + ctx->mod_field_num]; @@ -1113,8 +1107,6 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) } list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE)) continue; @@ -1151,8 +1143,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) if ((px->flags & PR_FL_DISABLED) || px->uuid <= 0 || !(px->cap & PR_CAP_BE)) goto next_px2; - counters = EXTRA_COUNTERS_GET(px->extra_counters_be, mod); - if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num)) + if (!mod->fill_stats(mod, px->extra_counters_be, stats + ctx->field_num, &ctx->mod_field_num)) return -1; val = stats[ctx->field_num + ctx->mod_field_num]; @@ -1420,8 +1411,6 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) } list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV)) continue; @@ -1471,8 +1460,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) goto next_sv2; - counters = EXTRA_COUNTERS_GET(sv->extra_counters, mod); - if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num)) + if (!mod->fill_stats(mod, sv->extra_counters, stats + ctx->field_num, &ctx->mod_field_num)) goto error; val = stats[ctx->field_num + ctx->mod_field_num]; diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 8c857a23b..1479c4efd 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -521,8 +521,8 @@ struct stats_module { struct list list; const char *name; - /* functor used to generate the stats module using counters provided through data parameter */ - int (*fill_stats)(void *data, struct field *, unsigned int *); + /* function used to generate the stats module using counters provided through data parameter */ + int (*fill_stats)(struct stats_module *, struct extra_counters *, struct field *, unsigned int *); struct stat_col *stats; /* statistics provided by the module */ void *counters; /* initial values of allocated counters */ diff --git a/src/h3_stats.c b/src/h3_stats.c index f50f5af0b..c89ce584e 100644 --- a/src/h3_stats.c +++ b/src/h3_stats.c @@ -129,9 +129,10 @@ static struct h3_counters { long long qpack_decoder_stream_error; /* total number of QPACK_DECODER_STREAM_ERROR errors received */ } h3_counters; -static int h3_fill_stats(void *data, struct field *stats, unsigned int *selected_field) +static int h3_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct h3_counters *counters = data; + struct h3_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < H3_STATS_COUNT; current_field++) { diff --git a/src/mux_h1.c b/src/mux_h1.c index 430ff0da1..fc81636ad 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -272,9 +272,10 @@ static struct h1_counters { #endif } h1_counters; -static int h1_fill_stats(void *data, struct field *stats, unsigned int *selected_field) +static int h1_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct h1_counters *counters = data; + struct h1_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < H1_STATS_COUNT; current_field++) { diff --git a/src/mux_h2.c b/src/mux_h2.c index c6e8c993e..07ccf8548 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -371,9 +371,10 @@ static struct h2_counters { long long total_streams; /* total number of streams */ } h2_counters; -static int h2_fill_stats(void *data, struct field *stats, unsigned int *selected_field) +static int h2_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct h2_counters *counters = data; + struct h2_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < H2_STATS_COUNT; current_field++) { diff --git a/src/quic_stats.c b/src/quic_stats.c index daee9456d..3f2b53941 100644 --- a/src/quic_stats.c +++ b/src/quic_stats.c @@ -92,9 +92,10 @@ static struct stat_col quic_stats[] = { struct quic_counters quic_counters; -static int quic_fill_stats(void *data, struct field *stats, unsigned int *selected_field) +static int quic_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct quic_counters *counters = data; + struct quic_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < QUIC_STATS_COUNT; current_field++) { diff --git a/src/resolvers.c b/src/resolvers.c index 0c1cda053..d653482b7 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -122,9 +122,10 @@ static struct stat_col resolv_stats[] = { static struct dns_counters dns_counters; -static int resolv_fill_stats(void *d, struct field *stats, unsigned int *selected_field) +static int resolv_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct dns_counters *counters = d; + struct dns_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < RSLV_STAT_END; current_field++) { @@ -2804,9 +2805,7 @@ static int stats_dump_resolv_to_buffer(struct stconn *sc, memset(stats, 0, sizeof(struct field) * stats_count); list_for_each_entry(mod, stat_modules, list) { - struct counters_node *counters = EXTRA_COUNTERS_GET(ns->extra_counters, mod); - - if (!mod->fill_stats(counters, stats + idx, NULL)) + if (!mod->fill_stats(mod, ns->extra_counters, stats + idx, NULL)) continue; idx += mod->stats_count; } @@ -4080,7 +4079,7 @@ static int rslv_promex_fill_ts(void *unused, void *metric_ctx, unsigned int id, labels[1].name = ist("nameserver"); labels[1].value = ist(ns->id); - ret = resolv_fill_stats(ns->counters, stats, &id); + ret = resolv_fill_stats(&rslv_stats_module, ns->extra_counters, stats, &id); if (ret == 1) *field = stats[id]; return ret; diff --git a/src/ssl_sock.c b/src/ssl_sock.c index eb5617985..f841bb11c 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -194,9 +194,10 @@ static struct stat_col ssl_stats[] = { static struct ssl_counters ssl_counters; -static int ssl_fill_stats(void *data, struct field *stats, unsigned int *selected_field) +static int ssl_fill_stats(struct stats_module *mod, struct extra_counters *ctr, + struct field *stats, unsigned int *selected_field) { - struct ssl_counters *counters = data; + struct ssl_counters *counters = EXTRA_COUNTERS_GET(ctr, mod); unsigned int current_field = (selected_field != NULL ? *selected_field : 0); for (; current_field < SSL_ST_STATS_COUNT; current_field++) { diff --git a/src/stats-proxy.c b/src/stats-proxy.c index 8d15d7bdf..278a4bf9c 100644 --- a/src/stats-proxy.c +++ b/src/stats-proxy.c @@ -548,8 +548,6 @@ static int stats_dump_fe_line(struct stconn *sc, struct proxy *px) return 0; list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (ctx->flags & STAT_F_FMT_FILE) continue; @@ -558,8 +556,7 @@ static int stats_dump_fe_line(struct stconn *sc, struct proxy *px) continue; } - counters = EXTRA_COUNTERS_GET(px->extra_counters_fe, mod); - if (!mod->fill_stats(counters, line + stats_count, NULL)) + if (!mod->fill_stats(mod, px->extra_counters_fe, line + stats_count, NULL)) continue; stats_count += mod->stats_count; } @@ -699,8 +696,6 @@ static int stats_dump_li_line(struct stconn *sc, struct proxy *px, struct listen return 0; list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (ctx->flags & STAT_F_FMT_FILE) continue; @@ -709,8 +704,7 @@ static int stats_dump_li_line(struct stconn *sc, struct proxy *px, struct listen continue; } - counters = EXTRA_COUNTERS_GET(l->extra_counters, mod); - if (!mod->fill_stats(counters, line + stats_count, NULL)) + if (!mod->fill_stats(mod, l->extra_counters, line + stats_count, NULL)) continue; stats_count += mod->stats_count; } @@ -1137,8 +1131,6 @@ static int stats_dump_sv_line(struct stconn *sc, struct proxy *px, struct server return 0; list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - void *counters; - if (ctx->flags & STAT_F_FMT_FILE) continue; @@ -1150,8 +1142,7 @@ static int stats_dump_sv_line(struct stconn *sc, struct proxy *px, struct server continue; } - counters = EXTRA_COUNTERS_GET(sv->extra_counters, mod); - if (!mod->fill_stats(counters, line + stats_count, NULL)) + if (!mod->fill_stats(mod, sv->extra_counters, line + stats_count, NULL)) continue; stats_count += mod->stats_count; } @@ -1378,8 +1369,6 @@ static int stats_dump_be_line(struct stconn *sc, struct proxy *px) return 0; list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) { - struct extra_counters *counters; - if (ctx->flags & STAT_F_FMT_FILE) continue; @@ -1391,8 +1380,7 @@ static int stats_dump_be_line(struct stconn *sc, struct proxy *px) continue; } - counters = EXTRA_COUNTERS_GET(px->extra_counters_be, mod); - if (!mod->fill_stats(counters, line + stats_count, NULL)) + if (!mod->fill_stats(mod, px->extra_counters_be, line + stats_count, NULL)) continue; stats_count += mod->stats_count; }