]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: new flag to report that no IP can be found in a DNS response packet
authorBaptiste Assmann <bedis9@gmail.com>
Tue, 8 Sep 2015 22:51:08 +0000 (00:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Sep 2015 13:42:55 +0000 (15:42 +0200)
Some DNS response may be valid from a protocol point of view but may not
contain any IP addresses.
This patch gives a new flag to the function dns_get_ip_from_response to
report such case.
It's up to the upper layer to decide what to do with this information.

include/types/dns.h
src/dns.c
src/server.c

index 59b59c7654c7df3d985b2d9614776daedbd3a0d6..f8edb734c53e9b1507e6dca4b521df56beadf4a4 100644 (file)
@@ -212,6 +212,7 @@ enum {
                                         *    matching preference was found */
        DNS_UPD_CNAME,                  /* CNAME without any IP provided in the response */
        DNS_UPD_NAME_ERROR,             /* name in the response did not match the query */
+       DNS_UPD_NO_IP_FOUND,            /* no IP could be found in the response */
 };
 
 #endif /* _TYPES_DNS_H */
index 4dfe697906f482665750d0e024ecee0d881cc20c..d002f1b93919b6f27d2bb809e2c5528074287555 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -724,6 +724,11 @@ int dns_get_ip_from_response(unsigned char *resp, unsigned char *resp_end,
                return DNS_UPD_CNAME;
        }
 
+       /* no IP found in the response */
+       if (!newip4 && !newip6) {
+               return DNS_UPD_NO_IP_FOUND;
+       }
+
        /* case when the caller looks first for an IPv4 address */
        if (family_priority == AF_INET) {
                if (newip4) {
index 4e06ad22af4a868a07d6dc5d00e79e9e4c6db5f0..8bc3165c786dcb9aa8bf07a42c1297a3c27cf3ed 100644 (file)
@@ -2049,6 +2049,13 @@ int snr_resolution_cb(struct dns_resolution *resolution, struct dns_nameserver *
                        }
                        goto invalid;
 
+               case DNS_UPD_NO_IP_FOUND:
+                       if (resolution->status != RSLV_STATUS_OTHER) {
+                               resolution->status = RSLV_STATUS_OTHER;
+                               resolution->last_status_change = now_ms;
+                       }
+                       goto stop_resolution;
+
                default:
                        goto invalid;