]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: fix wrong score computation in dns_get_ip_from_response
authorBaptiste Assmann <bedis9@gmail.com>
Fri, 22 Jun 2018 11:03:50 +0000 (13:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Jul 2018 15:56:34 +0000 (17:56 +0200)
dns_get_ip_from_response() is used to compare the caller current IP to
the IP available in the records returned by the DNS server.
A scoring system is in place to get the best IP address available.
That said, in the current implementation, there are a couple of issues:
1. a comment does not match what the code does
2. the code does not match what the commet says (score value is not
   incremented with '2')

This patch fixes both issues.

Backport status: 1.8

src/dns.c

index c86e57d9c829f53e4fba8367a30425c08962c96e..018c86a8847b1a9fa69167105f6bf5246ed2a3aa 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1024,10 +1024,13 @@ int dns_get_ip_from_response(struct dns_response_packet *dns_p,
                }
 
                /* Check if the IP found in the record is already affected to a
-                * member of a group.  If yes, the score should be incremented
+                * member of a group.  If not, the score should be incremented
                 * by 2. */
-               if (owner && snr_check_ip_callback(owner, ip, &ip_type))
+               if (owner && snr_check_ip_callback(owner, ip, &ip_type)) {
                        continue;
+               } else {
+                       score += 2;
+               }
 
                /* Check for current ip matching. */
                if (ip_type == currentip_sin_family &&