]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: resolvers: rework dns stats prototype because specific to resolvers
authorEmeric Brun <ebrun@haproxy.com>
Wed, 6 Jan 2021 15:01:02 +0000 (16:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 13 Feb 2021 08:43:18 +0000 (09:43 +0100)
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
src/dns.c
src/stats.c

index fdce4239abdf6f47646bdd8d5a86d706d899d391..29c65eb45dbb0b941c032b66b149a3b240cd7052 100644 (file)
@@ -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
index 72436a6dd01708fb2762f862e41858d1ab43c9f8..40d48452d5ab71c309cac761db645d60569ca69a 100644 (file)
--- 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 <appctx.ctx.stats.obj1> as a pointer to the current resolver and <obj2>
  * 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;
index 2450183bcc4314e9fc0f2c03dda650b6711a14e0..a6fe8bfb62e050c721967c2cfa0440efb385e5f9 100644 (file)
@@ -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;