Hey Simon, I'm sorry for the noise but - because all good things come in threes - I found a third case that is not covered by my two patches: When the answer and question types are not the same (commonly seen for ANY queries replied to with, e.g., A or AAAA answers).
But maybe you've already found a more elegant way of handling logging. Best, Dominik
From dc21d73e4c681fdfb805104191f8c87c31c19f8e Mon Sep 17 00:00:00 2001 From: Dominik DL6ER <dl...@dl6er.de> Date: Sun, 29 Aug 2021 15:28:55 +0200 Subject: [PATCH] Log non-cacheable replies where answer type != question type (commonly seen for ANY queries) Signed-off-by: Dominik DL6ER <dl...@dl6er.de> --- src/rfc1035.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/rfc1035.c b/src/rfc1035.c index 78aee89..e9c6d5c 100644 --- a/src/rfc1035.c +++ b/src/rfc1035.c @@ -540,6 +540,12 @@ static int print_txt(struct dns_header *header, const size_t qlen, char *name, return 1; } +static void log_non_cached_query(char *name, int aqtype) +{ + char *atype = querystr("non-cached ", aqtype); + log_query(F_FORWARD | F_UPSTREAM, name, NULL, atype); +} + /* Note that the following code can create CNAME chains that don't point to a real record, either because of lack of memory, or lack of SOA records. These are treated by the cache code as expired and cleaned out that way. @@ -636,9 +642,9 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t endrr = p1+ardlen; if (!name_encoding) - { /* Handle non-cacheable PTR. We still want to log them */ - char *atype = querystr("non-cached ", aqtype); - log_query(F_FORWARD | F_UPSTREAM, name, NULL, atype); + { + /* Handle non-cacheable PTR. We still want to log them */ + log_non_cached_query(name, aqtype); p1 = endrr; continue; } @@ -852,13 +858,12 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t return 0; } else - { - char *atype = querystr("non-cached ", aqtype); - log_query(F_FORWARD | F_UPSTREAM, name, NULL, atype); - } + log_non_cached_query(name, aqtype); } } } + else if(qclass == C_IN && res != 2) /* aqtype != qtype */ + log_non_cached_query(name, aqtype); p1 = endrr; if (!CHECK_LEN(header, p1, qlen, 0)) -- 2.25.1
_______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss