From db001949af4a2199cbc9bf1ed70152a7dbc58035 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 10 Mar 2021 15:07:27 +0100 Subject: [PATCH] BUG/MINOR; resolvers: Ignore DNS resolution for expired SRV item If no ADD item is found for a SRV item in a SRV response, a DNS resolution is triggered. When it succeeds, we must be sure the SRV item is still alive. Otherwise the DNS resolution must be ignored. This patch depends on the commit "MINOR: resolvers: Move last_seen time of an ADD into its corresponding SRV item". Both must be backported as far as 2.2. (cherry picked from commit 49531e8471a1c1ae9e1c7a6c1aeeb00713024beb) Signed-off-by: Christopher Faulet --- src/server.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/server.c b/src/server.c index dd82d9b..1015eef 100644 --- a/src/server.c +++ b/src/server.c @@ -3828,7 +3828,25 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na if (!s) return 1; + if (s->srvrq) { + struct dns_answer_item *srv_item; + + /* If DNS resolution is disabled ignore it. */ + if (s->flags & SRV_F_NO_RESOLUTION) + return 1; + + /* The server is based on a SRV record, thus, find the + * associated answer record. If not found, it means the SRV item + * has expired and this resolution must be ignored. + */ + srv_item = find_srvrq_answer_record(requester); + if (!srv_item) + return 1; + } + resolution = s->dns_requester->resolution; + if (!resolution) + return 1; /* initializing variables */ firstip = NULL; /* pointer to the first valid response found */ @@ -3893,6 +3911,7 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na update_server_addr(s, firstip, firstip_sin_family, (char *) chk->area); update_status: + snr_update_srv_status(s, has_no_ip); return 1; -- 1.7.10.4