From: Christopher Faulet Date: Wed, 10 Mar 2021 14:07:27 +0000 (+0100) Subject: BUG/MINOR; resolvers: Ignore DNS resolution for expired SRV item X-Git-Tag: v2.4-dev12~25 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=49531e8471a1c1ae9e1c7a6c1aeeb00713024beb;p=haproxy-2.5.git 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. --- diff --git a/src/server.c b/src/server.c index f1ba3cf..3b4d41e 100644 --- a/src/server.c +++ b/src/server.c @@ -3126,7 +3126,25 @@ int snr_resolution_cb(struct resolv_requester *requester, struct dns_counters *c if (!s) return 1; + if (s->srvrq) { + struct resolv_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->resolv_requester->resolution; + if (!resolution) + return 1; /* initializing variables */ firstip = NULL; /* pointer to the first valid response found */ @@ -3191,6 +3209,7 @@ int snr_resolution_cb(struct resolv_requester *requester, struct dns_counters *c srv_update_addr(s, firstip, firstip_sin_family, (char *) chk->area); update_status: + snr_update_srv_status(s, has_no_ip); return 1;