BUG/MINOR: resolvers: Always attach server on matching record on resolution
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Jun 2021 13:16:48 +0000 (15:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Jul 2021 16:14:20 +0000 (18:14 +0200)
commitb0865b5366e9cda605bdbf17320a238b864bb159
treefbddd22a5eb240ae4ce28d353538575b8d8701d0
parent035a491476cb980a56d1824ede091d60e0c0cbd4
BUG/MINOR: resolvers: Always attach server on matching record on resolution

On A/AAAA resolution, for a given server, if a record is matching, we must
always attach the server to this record. Before it was only done if the
server IP was not the same than the record one. However, it is a problem if
the server IP was not set for a previous resolution. From the libc during
startup for instance. In this case, the server IP is not updated and the
server is not attached to any record. It remains in this state while a
matching record is found in the DNS response. It is especially a problem
when the resolution is used for server-templates.

This bug was introduced by the commit bd78c912f ("MEDIUM: resolvers: add a
ref on server to the used A/AAAA answer item").

This patch should solve the issue #1305. It must be backported to all
versions containing the above commit.

(cherry picked from commit d7bb23490c1a71542c7e98b7c44d92df081c7e52)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2558d5aac1147b6e5c028152fc5382492dc6807c)
[cf: Changes applied in src/dns.c instead of src/resolvers.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/dns.c