From 0338aa4586affadb0c5a79516c870cee2c00c55c Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Sat, 12 Oct 2024 23:21:58 +0100 Subject: [PATCH] Don't log bogus source address when doing fast retry. --- src/cache.c | 2 +- src/forward.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cache.c b/src/cache.c index fed7409..05b666b 100644 --- a/src/cache.c +++ b/src/cache.c @@ -2299,7 +2299,7 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg, if (display_id < 0) display_id = -display_id; - if (flags & F_NOEXTRA) + if (flags & F_NOEXTRA || !daemon->log_source_addr) my_syslog(LOG_INFO, "%s%u %s %s%s%s %s%s", proto, display_id, source, name, gap, verb, dest, extra); else { diff --git a/src/forward.c b/src/forward.c index 50a177f..8f58311 100644 --- a/src/forward.c +++ b/src/forward.c @@ -645,6 +645,7 @@ int fast_retry(time_t now) GETSHORT(udp_size, udpsz); daemon->log_display_id = f->frec_src.log_id; + daemon->log_source_addr = NULL; forward_query(-1, NULL, NULL, 0, header, f->stash_len, ((char *) header) + udp_size, now, f, f->flags & FREC_AD_QUESTION, f->flags & FREC_DO_QUESTION, 1); @@ -896,7 +897,7 @@ static void dnssec_validate(struct frec *forward, struct dns_header *header, int log_resource = 0; daemon->log_display_id = forward->frec_src.log_id; - + /* We've had a reply already, which we're validating. Ignore this duplicate */ if (forward->blocking_query || (forward->flags & FREC_GONE_TO_TCP)) return; @@ -1355,7 +1356,7 @@ void return_reply(time_t now, struct frec *forward, struct dns_header *header, s (void)status; daemon->log_display_id = forward->frec_src.log_id; - daemon->log_source_addr = &forward->frec_src.source; + daemon->log_source_addr = (forward->frec_src.fd != -1) ? &forward->frec_src.source : NULL; /* Don't cache replies where DNSSEC validation was turned off, either the upstream server told us so, or the original query specified it. */ @@ -1937,6 +1938,9 @@ void receive_query(struct listener *listen, time_t now) /* We answered with stale cache data, so forward the query anyway to refresh that. */ m = 0; + + /* Don't mark the query with the source in this case. */ + daemon->log_source_addr = NULL; /* We've already answered the client, so don't send it the answer when it comes back. */