From 47eca42f8cce9df9a326dc90002e3d01b0e06e97 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 29 Sep 2026 09:28:02 +0200 Subject: [PATCH] BUG/MINOR: resolvers: preserve nameserver identity on "clear counters all" The resolvers statistics module stores the nameserver's id, its parent resolvers' id and the nameserver's puid in the counters structure, next to the counters themselves. "clear counters all" resets all counters by copying the module's template over them in resolv_stats_clear_counters(), which also clears these fields. As a result, "show stat domain resolvers" reports empty "id" and "pid" fields for all nameservers afterwards, and ns_puid becomes zero, so that server address changes performed by a DNS resolution are then attributed to the wrong nameserver (SERVER_INETADDR_UPDATER_DNS_RESOLVER(counters->ns_puid)). This can be reproduced with any resolvers section: > clear counters all > show stat domain resolvers # id,pid,sent,... ,,0,0,... Let's restore these fields after the reset, as done when allocating the counters. This patch should be backported to all stable branches. --- src/resolvers.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/resolvers.c b/src/resolvers.c index 67726b035..addc98836 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -3094,6 +3094,13 @@ void resolv_stats_clear_counters(int clrall, struct list *stat_modules) list_for_each_entry(ns, &resolvers->nameservers, list) { counters = EXTRA_COUNTERS_GET(ns->extra_counters, mod); memcpy(counters, mod->counters, mod->counters_size); + + /* restore the identity fields which are not counters */ + if (mod == &rslv_stats_module) { + ns->counters->id = ns->id; + ns->counters->ns_puid = ns->puid; + ns->counters->pid = resolvers->id; + } } } } -- 2.47.3