From d3b4495f0d015bd21b065ec5a35f160bb4b9e949 Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Wed, 6 Jan 2021 16:01:02 +0100 Subject: [PATCH] MINOR: resolvers: rework dns stats prototype because specific to resolvers Counters are currently stored into lowlevel nameservers struct but most of them are resolving layer data and increased in the upper layer So this patch renames the prototype used to allocate/dump them with prefix 'resolv' waiting for a clean split. --- include/haproxy/dns.h | 10 +++++----- src/dns.c | 18 +++++++++--------- src/stats.c | 10 +++++----- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/haproxy/dns.h b/include/haproxy/dns.h index fdce4239a..29c65eb45 100644 --- a/include/haproxy/dns.h +++ b/include/haproxy/dns.h @@ -48,10 +48,10 @@ void resolv_trigger_resolution(struct resolv_requester *requester); enum act_parse_ret resolv_parse_do_resolve(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err); int check_action_do_resolve(struct act_rule *rule, struct proxy *px, char **err); -int stats_dump_dns(struct stream_interface *si, - struct field *stats, size_t stats_count, - struct list *stat_modules); -void dns_stats_clear_counters(int clrall, struct list *stat_modules); -int dns_allocate_counters(struct list *stat_modules); +int stats_dump_resolvers(struct stream_interface *si, + struct field *stats, size_t stats_count, + struct list *stat_modules); +void resolv_stats_clear_counters(int clrall, struct list *stat_modules); +int resolv_allocate_counters(struct list *stat_modules); #endif // _HAPROXY_DNS_H diff --git a/src/dns.c b/src/dns.c index 72436a6dd..40d48452d 100644 --- a/src/dns.c +++ b/src/dns.c @@ -2379,7 +2379,7 @@ static int resolvers_finalize_config(void) } -static int stats_dump_dns_to_buffer(struct stream_interface *si, +static int stats_dump_resolv_to_buffer(struct stream_interface *si, struct dns_nameserver *ns, struct field *stats, size_t stats_count, struct list *stat_modules) @@ -2414,9 +2414,9 @@ static int stats_dump_dns_to_buffer(struct stream_interface *si, /* Uses as a pointer to the current resolver and * as a pointer to the current nameserver. */ -int stats_dump_dns(struct stream_interface *si, - struct field *stats, size_t stats_count, - struct list *stat_modules) +int stats_dump_resolvers(struct stream_interface *si, + struct field *stats, size_t stats_count, + struct list *stat_modules) { struct appctx *appctx = __objt_appctx(si->end); struct channel *rep = si_ic(si); @@ -2440,9 +2440,9 @@ int stats_dump_dns(struct stream_interface *si, if (buffer_almost_full(&rep->buf)) goto full; - if (!stats_dump_dns_to_buffer(si, ns, - stats, stats_count, - stat_modules)) { + if (!stats_dump_resolv_to_buffer(si, ns, + stats, stats_count, + stat_modules)) { return 0; } } @@ -2457,7 +2457,7 @@ int stats_dump_dns(struct stream_interface *si, return 0; } -void dns_stats_clear_counters(int clrall, struct list *stat_modules) +void resolv_stats_clear_counters(int clrall, struct list *stat_modules) { struct resolvers *resolvers; struct dns_nameserver *ns; @@ -2478,7 +2478,7 @@ void dns_stats_clear_counters(int clrall, struct list *stat_modules) } -int dns_allocate_counters(struct list *stat_modules) +int resolv_allocate_counters(struct list *stat_modules) { struct stats_module *mod; struct resolvers *resolvers; diff --git a/src/stats.c b/src/stats.c index 2450183bc..a6fe8bfb6 100644 --- a/src/stats.c +++ b/src/stats.c @@ -3580,9 +3580,9 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct htx *ht case STAT_ST_LIST: switch (domain) { case STATS_DOMAIN_DNS: - if (!stats_dump_dns(si, stat_l[domain], - stat_count[domain], - &stats_module_list[domain])) { + if (!stats_dump_resolvers(si, stat_l[domain], + stat_count[domain], + &stats_module_list[domain])) { return 0; } break; @@ -4691,7 +4691,7 @@ static int cli_parse_clear_counters(char **args, char *payload, struct appctx *a } } - dns_stats_clear_counters(clrall, &stats_module_list[STATS_DOMAIN_DNS]); + resolv_stats_clear_counters(clrall, &stats_module_list[STATS_DOMAIN_DNS]); memset(activity, 0, sizeof(activity)); return 1; @@ -4940,7 +4940,7 @@ static int allocate_stats_dns_postcheck(void) i += mod->stats_count; } - if (!dns_allocate_counters(&stats_module_list[STATS_DOMAIN_DNS])) { + if (!resolv_allocate_counters(&stats_module_list[STATS_DOMAIN_DNS])) { ha_alert("stats: cannot allocate all counters for dns statistics\n"); err_code |= ERR_ALERT | ERR_FATAL; return err_code;